I would like to have a task to either trigger at sunset, or if sunset is after 7pm then trigger at 7pm.
Is that a possible logic to enact in an automation?
Trigger from both sunset and 7pm. Check one of these is false to catch the first event, rather than the usual pattern of catching the second:
triggers:
- trigger: time
at: "19:00"
- trigger: state
entity_id: sun.sun
to: 'below_horizon'
conditions:
- or:
- condition: time
before: "19:00"
- condition: state
entity_id: sun.sun
state: 'above_horizon'
actions:
[etc]
With early sunset:
- triggers at sunset
- before 19:00 so run action
- triggers at 19:00
- neither condition true so stop
With late sunset:
- triggers at 19:00
- sun still up so run action
- triggers at sunset
- neither condition true so stop
1 Like