Trigger on sunset/sunrise

I use an automation for my luxaflex duettes that should be triggered on sunrise/sunset. When I set a state trigger on the sun.sun device, it works, but it seems to trigger multiple times. So I defined the sunset and sunrise events as a trigger. Seems to be fairly simple, but it doesn’t get triggered. Anyone an idea of what I am doing wrong?

alias: Luxaflex Duettes auto dag-nacht
description: ''
trigger:
  - platform: sun
    event: sunrise
    offset: '0:30'
  - platform: sun
    event: sunset
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: sun.sun
            state: below_horizon
        sequence:
          - service: input_select.select_option
            data:
              option: Dicht
            target:
              entity_id: input_select.luxaflex_dining
          - delay:
              milliseconds: 500
          - service: input_select.select_option
            data:
              option: Dicht
            target:
              entity_id: input_select.luxaflex_living
    default:
      - service: input_select.select_option
        data:
          option: Dagstand
        target:
          entity_id: input_seect.luxaflex_living
      - delay:
          milliseconds: 500
      - service: input_select.select_option
        data:
          option: Dagstand
        target:
          entity_id: input_select.luxaflex_dining
mode: restart

not given straight answer, but some experience here.
below trigger, triggered this morning at 7:34 (and sunrise was 7:04). Meaning possible things to think about:

  • format for offset
  • offset means ‘after sunrise’, so sun is above horizon.
  • i’m not familair with 2 triggers for same event yet, so would suggest to do 1 trigger to test with first.
trigger:
  - platform: sun
    event: sunrise
    offset: '00:30:00'

Does it not trigger or is the action part not working? Did you “trigger” it from the automation’s UI to check the later?

The action part seems to work. When I use this as a trigger, it works (but triggered many times). When I Manually changed the Duettes and it get’s triggered again during the day, it sets the duettes in the dayscene again…

trigger:
  - platform: state
    entity_id: sun.sun

I am not sure when a sunset event is fired, if the state is below_horizon at that time, since I test on that (to avoid having seperate automations for up and down).

I did, and that works ok.

The formatting suggestion would be interesting, since I used the UI to configure it. However I tried using no delay (and thus no formatting issue). That seems to have no effect.

btw… if it worked on ‘state’, why not just move to

mode: single

then it would just run one time.
Still wondering why it would trigger multiple times

That would be something I can try. It should still be possible to trigger on sunset/sunrise. Maybe indeed due to the 2 triggers for same event…

That answer is kind of vague but taking it at face value I’m not sure it works as you might think.

“single” mode only prevents the automation from running more than one simultaneous instances of the automation. It can still trigger hundreds of times a day if the trigger is satisfied.

if the automation is currently running (meaning the automation actions haven’t completed and “current:” attribute value is not 0) if the trigger occurs again then the trigger is ignored. This is usually only affected for actions that have a delay of some kind either thru a programmed “delay:” entry or if a service call is waiting for a response from a device to move to the next action step. But it can happen for any automation if the trigger is detected in succession quickly enough.

but if the trigger happens again when the automation is no longer active (“current:” value is 0) then the automation will run immediately as soon as the trigger and conditions are met.

Using restart in this case won’t really affect anything since that mode tells the automation to cancel it’s actions and start over again if the trigger occurs as the automation action are in progress. since the triggers are single events many hours apart there should be no way for the trigger to re-occur and cause the automation to cancel/restart its actions.

So all of that said I really doubt that the mode has anything to do with the automation not running.

The problem with using a state trigger is that the automation will trigger on every state or attribute change of the entity.

using sunrise/sunset only allows it to trigger on those events and will ignore all the other attribute changes.

I don’t see anything obvious why the automation in your first post shouldn’t run.

to troubleshoot you could try to split them into two separate automations (instead of one using “choose:”) and see if they work like that.

Two seperate automations does work. I think it has to do with the fact that I use the same entity for multiple triggers…