I’ve set up a script and automation to run through Alexa. The script turns on the landing lights for 10 minutes when we go to bed. Then the automation kicks in for motion detection which runs until sunrise. The lights on the landing are huge lights. The routine runs but no matter what I try to change to keep the lights on longer than 20 seconds when no motion is detected seems impossible. Here is the code. Hopefully, someone can see what I am missing.
’
alias: Landing Motion Control (HA)
triggers:
- entity_id: binary_sensor.hue_motion_sensor_1_motion
to: "on"
trigger: state
conditions:
- condition: state
entity_id: input_boolean.alexa_goodnight_v3
state: "on"
- condition: state
entity_id: light.landing
state: "off"
actions:
- entity_id: light.landing
data:
brightness_pct: 25
action: light.turn_on
- wait_for_trigger:
- entity_id: binary_sensor.hue_motion_sensor_1_motion
to: "off"
trigger: state
timeout: "00:02:00"
- entity_id: light.landing
action: light.turn_off
mode: restart
The suggestion was to replace the entire wait_for_trigger with delay.
In other words, your automation will no longer wait for the motion detector to report off but will simply wait for a hard-coded period of time to pass.
FWIW, you may have misunderstood the purpose of the timeout option. The wait_for_trigger will wait for the motion detector to report off up to a maximum about of time specified by timeout. In other words, the wait_for_trigger finished when either the detector reports off or the timeout expires, whichever occurs first.
Not really, I use a combination.
After the Motion-Sensor goes from on → off , wait this delay, and then action.
- alias: Wait until there is no motion from device
wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
continue_on_timeout: false
- alias: Countdown or it restarts upon motion_sensor signal
delay:
hours: 0
minutes: 0
seconds: 10