Do I have this automation configured correctly to work as expected (according to the description)? I’ve never used trigger timeouts before. I did this in the Automations UI since YAML is a copy-and-paste kind of thing for me.
alias: Banister Lights on in Evening
description: >-
Turns on the banister lights at sunset and then turns them off 5h45m later or
at 10:30pm (whichever is sooner).
trigger:
- platform: sun
event: sunset
offset: '-00:00:00'
condition: []
action:
- type: turn_on
device_id: 994d492fdbae803341f36b0680164bba
entity_id: switch.banister_lights_socket
domain: switch
- wait_for_trigger:
- platform: time
at: '22:30:00'
timeout: '05:45:00'
- type: turn_off
device_id: 994d492fdbae803341f36b0680164bba
entity_id: switch.banister_lights_socket
domain: switch
mode: single
The syntax may be correct but this is very bad practice. You should never wait in an automation for longer than a few 10s of seconds at most. It is very likely that this automation could be interrupted while waiting, either because of a restart or reload of your automations.
The simplest method is to use two automations, one for on, one for off.
I see. Thank you. I appreciate the guidance on best practices. I will split this into two separate automations. I wish the UI had folders or tags for automations to help keep them all organized.
Should the Wait for time to pass action also be limited to <~60 seconds? I have a separate automation set up this way: