when an automation with a delay is triggered again during the delay it will skip all conditions and all delays/wait templates and just execute the actions. To overcome this you can create a timer and turn the lights off when the timer finishes. This way you timer will also be reset on a new motion detection. Search the forum or let me know in case you need some help.
I have managed to get this working but I did it with
a. configuration.yaml holding the timer (im sure that is right)
b. an automation starting lights on with movement picked up by sensor
c. a second automation killing the lights after timer expires. (if I walk into the movment zone the counter starts again).
So function wise this is working fine.
Question. Is the 2 automations how this is done or am I missing something.
The first automation:
Motion detected -> turn on light and start timer
When an already running timer is started it will just start again from the beginning.
- alias: "Turn on guest bathroom light on motion"
trigger:
platform: state
entity_id: binary_sensor.guest_toilet_movement
to: 'on'
action:
- service: timer.start
entity_id: timer.guest_bath_light_timer
- service: light.turn_on
data:
brightness_pct: '100'
color_name: white
entity_id:
- light.lifx_d0_73_d5_38_1a_e2
- light.lifx_d0_73_d5_38_25_6e
- light.lifx_d0_73_d5_51_c5_63
The second automation turns off the light when the timer finishes.
- alias: "Turn off lights after 6 minutes of no motion"
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.guest_bath_light_timer
action:
service: light.turn_off
entity_id:
- light.lifx_d0_73_d5_38_1a_e2
- light.lifx_d0_73_d5_38_25_6e
- light.lifx_d0_73_d5_51_c5_63