I have the following rule setup:
rule "Timer stair_light"
when
Item stair_light changed to ON
then
if(stair_light.state==ON) {
if(timer==null) {
// first ON command, so create a timer to turn the light off again
timer = createTimer(now.plusSeconds(10)) [|
stair_light.sendCommand(OFF)
logInfo("/var/log/openhab2/openhab.log", "stair_light turned off automatically by timer")
]
} else {
// subsequent ON command, so reschedule the existing timer
timer.reschedule(now.plusSeconds(10))
}
} else if(stair_light.state==OFF) {
// remove any previously scheduled timer
if(timer!=null) {
timer.cancel
timer = null
}
}
end
This works great (only have it set to 10 seconds for testing) if and only if OpenHab sends the command to turn the lightswitch on. If the actual lightswitch is turned on manually, the timer never turns the light off; I’m not sure if this is by design or something I have mis-configured within OpenHab.
Here is how the item is setup:
Switch stair_light “Stair Light” (AllLights) { zwave=“5:command=switch_binary,refresh_interval=15” }
Light switch is a GE 12727, and the z-wave controler is an Aeotec gen 5 USB stick, OpenHab 2.0 on a raspberry Pi 3 Model B.
Any help would help would with what I might be missing would be fantastic!