Hi everyone,
I’m having trouble with a YAML automation that’s supposed to turn off the lights one minute after my motion sensor goes to the ‘off’ state, but the ‘turn_off’ service isn’t triggering reliably.
Here’s my setup:
- I use a
binary_sensor.motion_11_occupancyfor triggering. - My automation works for turning on the light when motion is detected, but the turn_off part does not activate after the motion sensor goes ‘off’ for one minute.
- My trigger is set with a
for:condition to delay, and actions use templating based ontrigger.id.
Here is the automation:
trigger:
- platform: state
entity_id: binary_sensor.motion_11_occupancy
to: "on"
id: "on"
- platform: state
entity_id: binary_sensor.motion_11_occupancy
to: "off"
for:
hours: 0
minutes: 1
seconds: 0
id: "off"
action:
- service: "light.turn_{{ trigger.id }}"
target:
area_id: trastero
data: {}
What could prevent the turn_off action from running after the sensor has been ‘off’ for 1 minute?
Are there common issues with for: delays, triggers, or templating in the service field that I should check?
Thanks for any insight!