The automation below turns on a light when motion has been detected and it is supposed to shut it off again when no motion has been detected for 120 seconds. Very simple, however, the turning of works intermittently. Most of the times it does work. I have many automations that look exactly like this, some triggered by the same motion sensors and one of them can work while the another fail and both automations are listening to the exact same events. The failure is in the "wait for trigger" step where it gets stuck when it fails, which also means that this automation is stuck in that state. Any ideas?
alias: Movement Balcony - Turn on Lights Balcony
description: ""
triggers:
- entity_id: binary_sensor.nexa_motion_sensor_outside_balcony_motion_detection
from: "off"
to: "on"
trigger: state
conditions:
- condition: sun
before: sunrise
after: sunset
after_offset: "-00:15:00"
actions:
- if:
- condition: state
entity_id: light.light_outside_balcony
state: "off"
then:
- action: light.turn_on
target:
entity_id:
- light.light_outside_balcony
data: {}
- wait_for_trigger:
entity_id: binary_sensor.nexa_motion_sensor_outside_balcony_motion_detection
from: "on"
to: "off"
for: 120
trigger: state
- action: light.turn_off
target:
entity_id:
- light.light_outside_balcony
data: {}
mode: single