Conditional Triggers

Hi all,
I am relatively new to Home assistant, but really enjoying the experience so far. I have a scenario I have not yet managaed to get my head round and wondered if someone can help.
Scenario:
I would like to put some blinds down 30 minutes after Sunset or at 21;15, whichever comes first. I currently have one automation where I have two triggers 1) sunset + 30 minutes. 2) 21:15. Obviously this works but it trigeers the blinds down script twice. Is there a way to set this up so that I only trigger once? If sunset +30 is before 21:15 then trigger and if not just trigger at 21:15.

Since you want the earlier of the two, one way to do it would be to set both triggers, then add a condition that checks if the automation has already run for the day.

triggers:
  - trigger: time
    at: "21:15"
  - trigger: sun
    event: sunset
    offset: "00:30:00"
conditions:
  - condition: template
    value_template: |
      {{ (this.attributes.last_triggered | default(as_datetime(0),1)).date() != now().date() }}

Create a toggle helper and use that as a flag: have your automation turn it on, and include a condition so that if it is already on the automation stops.

You’ll have to have something else turn the flag off again in the morning - maybe the blinds up automation.

1 Like

Thank you both. I had thought about the option to create a value and check if the other had run. The other option I thought of although maybe not so clean was to create a repeating daily calender event from 16:00- 21:14 and have a condition check it then an else if.
Your ideas are better though, I will give it a go.