Automation with state trigger sun.sun to below_horizon never triggers

Hi,
does anybody know why the below automation never triggers?
According to everything I found in the forums this should work.

  - id: 2b791d46-fab0-4a0a-8241-9b7ca9a59fa4
    description: Retract the awning when the sun goes down
    alias: Fahre Markise ein wenn die Sonne untergeht
    trigger:
      - platform: state
        entity_id: sun.sun
        to: below_horizon
    condition:
      - condition: state
        entity_id: cover.markise
        state: "on"
    action:
      - service: cover.close_cover
        entity_id: cover.markise
      - service: notify.group_notifications
        data:
          message: "Ich habe Markise eingefahren."

Thank you!

Is it turned on?

Did you run the usual tests?

  1. Use Developer tools → States to find the automation, click the info icon and then push Execute
  2. Use Developer tools → Services and call automation.trigger on the automation with skip_condition: false
  3. Use Developer tools → States to find the trigger entity, click the name of that entity, then change the state (at the top) to something that’ll trigger the automation before pushing Set State
1 Like

Thanks for your input.
Yes its turned on and I can trigger it manually by clicking execute and via service call.

I haven’t thought of setting the state directly but that didn’t help either.

did you try the event sunset trigger: https://www.home-assistant.io/docs/automation/trigger/#sunset--sunrise-trigger

I recall having issues with the below_horizon as trigger, and the event trigger solved that.

1 Like

Had the same problem with my TV and ambilight automation.

As Mariusthvdb mentioned, problem is the below_horizon trigger. Solved it via not using as trigger or condition below_horizon but sun

trigger:
    - platform: sun
      event: sunset
      offset: '-00:30:00'

....

    #   - condition: state
    #     entity_id: sun.sun
    #     state: 'below_horizon'
      - condition: sun
        after: sunset
        after_offset: "-00:30:00"
1 Like

Thanks you two. Do you know how I can test that event trigger?
In the Developer Tools on the Event Page I set EventType to “sun” and Event Data to “sun” or “data: sun” but it didn’t trigger the automation.

I think maybe you didn’t do step 2:

I don’t use covers, but I suspect this is your problem:

    condition:
      - condition: state
        entity_id: cover.markise
        state: "on"

I believe the state of covers are open, closed, etc., not on or off.

1 Like

Thank you. Totally true!