I have automation that turns off lights if there’s no motion/presence after some timeout.
If my trigger is “no motion for X seconds” does the rule restart automatically when motion is detected?
E.g. how should the rule/blueprint be triggered so that this scenario is properly handled:
motion detected, sensor goes “blind” for 90 secs (ikea or sonoff sensor)
detector wakes up, state = clear for 5 secs, but then motion is detected again
I’ve read the built-in motion-controlled-light automation and it’s smart, but my question is general, for other sensors too — I’m waiting for the sensor to be stable in state X for time Y and I want the rule to handle short state flips (like the example above but with doors and other binary sensors) properly.
If you are using a State Trigger’s for option to trigger when an entity’s state remains unchanged for X seconds, the trigger uses an internal timer to count down the X seconds. Any change to the entity’s state cause the internal timer to restart the countdown.
The for option behaves the same way in Template and Device Triggers.
let me see if I understand correctly…given automation with trigger motion sensor stopped detecting motion for 10 seconds in restart mode,
the trigger will be re-evaluated when motion sensor detects motion within 10 seconds of being marked as clear?
Here’s a State Trigger configured to detect when the motion detector changes from on to off and then remains off for at least 10 seconds.
- platform: state
entity_id: binary_sensor.motion
from: 'on'
to: 'off'
for:
seconds: 10
The moment it detects the on to off state-change, it starts an internal 10-second timer.
If the binary_sensor’s state remains off throughout the internal timer’s countdown right up to the moment the timer expires, the State Trigger triggers the automation it is used in.
If the binary_sensor’s state changes to on during the countdown, the internal timer is reset. The timer will not be restarted until the State Trigger detects another on to off state-change.