[SOLVED] Help with Motion sensor goes too off too quick / canceling a timer

Here is a good place to start: Design Pattern: Motion Sensor Timer. It isn’t exactly your case but it is pretty close and it shows how to use the Timers.

If you are using a Timer then

timer?.cancel

The ? is a short hand way to say skip this line if timer is null.

If you are using Design Pattern: Expire Binding Based Timers then

MotionTimer.postUpdate(OFF)

Your overall approach is sound. I personally would recommend using the Expire binding based timers unless you need to use a different amount of time for the Timer based on conditions. Then you don’t even need Rules to handle the OFF command.

Switch Living_Room_Motion (MotionSensors) ...
Switch Living_Room_Motion_Proxy { expire="30s,command=OFF" }
...
rule "Motion sensor triggered"
when
    Member of MotionSensors changed from OFF to ON
then
    sendCommand(triggeringItem.name+"_Proxy", ON)
end

When a member of MotionSensors changes from OFF to ON, we send the ON command to the proxy. The Expire binding will sendCommand OFF to the proxy 30 seconds after the last time it receives an ON command.

1 Like