What is wrong with this automation?
Once it starts, even after I close the door sensor it just runs indefinitely. Why something this simple seems to have some weird drawback hidden at some detail that is against intuition?
alias: "Entrada - contact puerta luz "
description: "Enciende la luz de la entrada con la puerta "
triggers:
- entity_id:
- binary_sensor.opening_3_contact
from: "off"
to: "on"
trigger: state
conditions:
- condition: sun
before: sunrise
after: sunset
after_offset: "-30"
before_offset: "30"
actions:
- data: {}
target:
entity_id: light.entrada
action: light.turn_on
- wait_for_trigger:
- entity_id:
- binary_sensor.opening_3_contact
to: "off"
for:
hours: 0
minutes: 0
seconds: 30
trigger: state
- delay:
hours: 0
minutes: 0
seconds: 45
milliseconds: 0
- data: {}
target:
entity_id: light.entrada
action: light.turn_off
mode: restart
Like restarting the automation will put your example into trouble?
I have to admit it is a very smart approach, but as many smart things, maybe it will have unexpected outcomes as you mention
The code I posted is not prone to the same kind of issues your code will.
Delaying code is always an issue.
Setting a for time in trigger is a lot safer.