I’m about to embark on my journey from OH2.5 to OH3 and have decided I need to tidy up a few of my rules. Pretty much all of my rules have been created by searching the forum to find how to make it work as expected. The rule below is one of those rules that I never really progressed beyond my original idea.
The idea behind the rule is that when someone leaves the house a timer kicks in for 180 seconds and switches off the Kitchen Sonos, but only if there is no Motion detected.
In reality the Sonos is switched off every time a door is closed as someone leaves the house. I think I’ve misunderstood how timers work and just need a little nudge in the right direction.
rule "We've all left the house"
when
Item gDoor_Sensors_GroundFloor changed to CLOSED
then
if(Kitchen_Sonos_State.state == "PLAYING" && Time_Of_Day.state == "DAY") {
myTimer = createTimer(now.plusSeconds(180)) [|
if(myTimer !== null || gMotion_Sensors_GroundFloor.state == OFF) {
if(gDoor_Sensors_GroundFloor.state == CLOSED && gMotion_Sensors_GroundFloor.state == OFF) {
Kitchen_Sonos_Stop.sendCommand(ON)
logInfo(filename, "System Message: The Kitchen Sonos has been switched Off.")
sendPushoverMessage(pushoverBuilder("System Message: The Kitchen Sonos has been switched Off.").withPriority(1))
}
}
myTimer = null
]
}
end