Hello, I am trying to make the lights in my bedroom dim, and then check if the occupancy is clear for a few seconds before turning off. This gives me a chance to activate the sensor again if necessary. I previously tried to just add a delay between dimming and turning off the light, but if I tried to activate the sensor during that delay, it raise the brightness, finish the delay, then turn off. However when I try to do this with an if condition it appears that it doesn’t run even after having the occupancy be clear for more than 10 seconds. I am doing this via the UI, and pasted the YAML below. Any help is appreciated, thank you.
alias: Turn Bedroom Lights Off When Unoccupied
description: When no occupancy is detected in the bedroom, the bedroom lights turn off.
triggers:
- trigger: state
entity_id:
- binary_sensor.aqara_presence_sensor_fp1e_occupancy
from: null
to: "off"
conditions:
- condition: state
entity_id: light.bedroom_lights
state: "on"
actions:
- sequence:
- action: light.turn_on
metadata: {}
data:
brightness_step_pct: -25
target:
entity_id: light.bedroom_lights
- if:
- condition: state
entity_id: binary_sensor.aqara_presence_sensor_fp1e_occupancy
state: "off"
for:
hours: 0
minutes: 0
seconds: 10
then:
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.bedroom_lights
mode: single