Hello Rich,
Your post is very helpful. Thank you very much.
I am very new to Openhab, and was wondering if you could clarify what you meant by
So to trigger a Rule only when the timer expires you would use Item MyTimer received command OFF
.
I have used your code snippet and would like to use that to create an alert when a door is left open. The first part of my code creates a ding-dong song (to keep my 3 year old from walking out by himself).
I have seen your other post on using groups to reduce the lines of code, but to be honest it’s over my head. And honestly, I’m still trying to figure out this whole OpenHab thing.
so in items, I have created the following switch
Switch FrontDoorOpen_Timer { expire="5m,command=OFF" }
And in my Rules folder, I have:
rule “front_door_open”
when
Item zwave_device_08f074d1_node6_sensor_door changed from CLOSED to OPEN
then
playSound(“chromecast:chromecast:ead9e7276c37c0aaaf5a2c261342d6da”,“Apartment-ding-dong-sound.mp3”)
playSound(“chromecast:chromecast:ecd97d69f28d9f1c0173a27b8c48df78”,“Apartment-ding-dong-sound.mp3”)
Thread::sleep(250)
say(“front door”)
if(FrontDoor_Timer.state == ON) {
// do stuff if Timer is actively running
}
// cancel Timer
FrontDoor_Timer.postUpdate(OFF)
// start Timer
FrontDoor_Timer.sendCommand(ON)
// do some stuff
end
rule “Door Open timer expired”
when
Item FrontDoor_Timer received command OFF
then
// Timer body
say(“the front door has been left open for 5 minutes”)
end
The ding-dong works, but for the life of my I can’t figure out how to change this to only give the alert when the door remains open. Any help would be super appreciated!