Hey guys,
this is the intruder part of this thread: Time of Sunrise/Sunset - to make it easier for anybody to search for it and implement it too.
The goal is to have an invasion alarm:
rule "Break-In Alarm"
when
Item Alarm_Invasion received update ON
then
sendCommand(GroupLight, 100) //Turn on all Lights
logInfo("Invasion-Alarm","Invasion alarm - turning all Lights on")
// send notifications
sendTelegram("BotGroup", "Intruder alarm was triggered!!!")
//play sounds?
end
One of the problems I do have is to have the alarm triggered, when the status of an item in the group “GroupDetectorImportant” changes. Dont know if the following could work:
rule "Invasion Detection"
when
Item GroupDetectorImportant received update
then
if (Away_Status == ON) {
sendCommand(Alarm_Invasion, ON)
logInfo("InvasionDetection","Sensor changed, Away Status is On - ALARM!!!")
}
if (Sleeping_Status == ON) {
sendCommand(Alarm_Invasion, ON)
logInfo("InvasionDetection","Sensor changed, Sleeping Status is On - ALARM!!!")
}
if (Away_Status_Smart == ON) {
sendTelegram("BotGroup", "Invasion alarm - no smartphones are online; are you home?")
logInfo("InvasionDetection","Sensor changed, Smart Away Status is On - sending notification!")
}
else {
logInfo("InvasionDetection","Sensor changed, but nothing to do")
}
end
Would be nice if I could answer on that telegram-message to finally trigger the alarm or not. But I could not find anything to read out these messages.
Next thing is a sleep detection:
rule "Sleep Detection"
when
Item GroupLight received update OFF
then
if (NightState == ON) {
sendCommand(Sleeping_Status, ON)
logInfo("Sleep Detection","It is nighttime - switching sleep status")
}
else {
logInfo("Sleep Detection","It is daytime - no sleep detection")
}
end
This does not work - it does not trigger with all lights off and the nightstate being on… Dont know why. I just want the Sleeping_Status to be on when all lights are off and the nightstate is on.
Here is also the nightstate (found it in the wiki (at least I think so)):
rule "Update NightState"
when
Item SunElevation changed
then
if(SunElevation.state > 15){
if(NightState.state != OFF) {
postUpdate(NightState, OFF)
}
}
else {
if(NightState.state != ON) {
postUpdate(NightState, ON)
}
}
end
This is to automatically switch the Sleeping_Status off. Probably I have to integrate a timer here to turn that status off after 1 minute or so:
rule "Wake Up Detection"
when
Item GroupLight received update ON
then
sendCommand(Sleeping_Status, OFF)
logInfo("Wake Up Detection","It is nighttime - switching sleep status")
end
And here is an away detection over smartphones, but I am still very unsure about it. So I just want to use it as backup and only send a telegram-message. I also built a timer in there to check if somebody is really away and not only taking the bin down or so:
var Timer AwayDetectionTimer = null
rule "Away Detection"
when
Item SmartphoneAndy received update or
Item SmartphoneJessy received update
then
if (SmartphoneAndy == OFF && SmartphoneJessy == OFF) {
AwayDetectionTimer = createTimer(now.plusSeconds(600)) [|
if (SmartphoneAndy == OFF && SmartphoneJessy == OFF) {
sendCommand(Away_Status_Smart, ON)
logInfo("AwayDetection","")
}
else {
logInfo("AwayDetection","")
}
]
}
if (SmartphoneAndy == ON || SmartphoneJessy == ON) {
if (Away_Status_Smart == ON) {
sendCommand(Away_Status_Smart, OFF)
logInfo("AwayDetection","")
}
else {
logInfo("AwayDetection","")
}
}
end
Later I also want to add a timer to trigger the alarm (want the basics working first) and so on. The idea is a keypad in HABpanel to deactivate the away-status and also it does not make sense to activate the alarm instantly after a sensor changed. It would also trigger if you open the maindoor - no time to deactivate the status then.
Also I do think it makes sense to have the sleeping status only trigger the alarm instant at the windows, because you could also come home late.
Thank you very much in advance!
Greetings
Andy