Automation Trigger Time vs Sunset

Hi all,

I’m trying to write an automation which turns on a switch (light) at a set time (1830) of sunset, whichever is earlier.

I’ve set 2 triggers to be Sunset and the time of 1830, however I can’t get my head around what the conditions need to be call the action based on the time comparison.

Grateful for some help for a novice HAer please!

You don’t need any conditions. Whichever trigger occurs first will turn your switch on. The next time it triggers it will be turning on a switch that is already on, so nothing actually happens.

If you really want to prevent this second action from happening include a state condition that checks for the switch being off. It will be on when the second trigger occurs.

Thanks, lets say I wanted the action to fire at the later of 1830 or sunset, how would I achieve that?

Two triggers and two conditions.

trigger:
  - platform: time
    at: "18:30:00"
  - platform: sun
    event: sunset
condition:
  - condition: time
    after: "18:29:59"
  - condition: state 
    entity_id: sun.sun
    state: "below_horizon"
2 Likes