Sunset setting not working

Hello, I’ve been trying to automate my Wiz lightstrip to turn 35 minutes before the sunset. Everything in the code is working except the trigger for sunset. I tried everything to get it working, searched many discussions but nothing seems to be working for me, the automation simply would not start. When the sunset setting is removed and I try to run the automation for example on specific time, everything is working fine. Do you have any ideas or a workaround that I could to get it working? Here’s my yaml code:

alias: Obývák - západ slunce
description: “”
trigger:

  • platform: sun
    event: sunset
    offset: “-00:35:00”
    condition:
  • condition: or
    conditions:
    • condition: state
      entity_id: person.sarka_vaculikova
      state: home
    • condition: state
      entity_id: person.supra_household
      state: home
      enabled: true
      action:
  • repeat:
    until:
    - condition: template
    value_template: >-
    {{ state_attr(‘light.wiz_obyvakova_stena’, ‘brightness’) | int / 255
    * 100 >= 100 }}
    sequence:
    - service: light.turn_on
    data:
    brightness_step_pct: 5
    color_temp: 344
    target:
    entity_id: light.wiz_obyvakova_stena
    - delay:
    hours: 0
    minutes: 1
    seconds: 45
    milliseconds: 0
    mode: single

Thank you very much for any idea.

Hard to tell without proper formatting. Add ``` to the beginning and end.

Maybe sounds like a silly question, but have you added/enabled the Sun-Integration /In /Settings/Devices & Services ?
BTW Did you use the UI-Editor or are you “trying your luck” in yaml ?

1 Like

You should format your code so we can see if you have errors outside of the basic text.

Yes, all sun related entities should be enabled. I used the UI editor and copied the code from “Edit in YAML” option.
I’m beginner, so I don’t know much about Home assitant, sorry about the unformatted code, you should see it in a proper way down
bellow:


alias: Obývák - západ slunce
description: ""
trigger:
  - platform: sun
    event: sunset
    offset: "-00:35:00"
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: person.sarka_vaculikova
        state: home
      - condition: state
        entity_id: person.supra_household
        state: home
    enabled: true
action:
  - repeat:
      until:
        - condition: template
          value_template: >-
            {{ state_attr('light.wiz_obyvakova_stena', 'brightness') | int / 255
            * 100 >= 100 }}
      sequence:
        - service: light.turn_on
          data:
            brightness_step_pct: 5
            color_temp: 344
          target:
            entity_id: light.wiz_obyvakova_stena
        - delay:
            hours: 0
            minutes: 1
            seconds: 45
            milliseconds: 0
mode: single

And by above you mean you waited until 35min before Sunset, and it didn’t trigger(35min before) ?
PS: As i don’t know “where on earth you are” i just wonder, because here 35min before sunset is like hours ago !, so it wont trigger again before tomorrow :wink:

Yes, and that’s what it should do. I want it to start the automation 35 minutes before sunset, the lights should be slowly increasing the brightness until 100% when the sun sets and there’s not much of a light in my living room by that time, I live in Czech Republic. I’m kinda experimenting with it and maybe there will be some further customization according to the real-life expirience :smiley:

go to your automation, click on trace , i assume you made this automation prior to 35min before sunset !, So you really “experienced” it didn’t “trigger”
In the “Trace” you’ll see the “last triggered time”

Czech Republic !, so i guess you´ll have to wait another +20 hours for your next Trigger-Event :slight_smile:

I created the automation few hours before the whole thing could even start to execute (it should start 35 minutes before 20:16 (sunset) on May 8th). I ran the automation manually to test it few times when it didn’t start on designated time, so the step details won’t give me any useful information now, I will need to wait until next sunset like you said. Everything else like my location a correct timezone should be configured correctly and I assume that the sunset entity should take that informations and run accordingly.

It will show if the automation was “executed” and if you click the Trace-TimeLine, you’ll se the rest
So yes it’s “Useful” Information, for you and for the person(s) who are willing to help you :wink:
But it’s ok if you don’t feel for “sharing” the information , better luck tommorow

I want to share the info and I believe it is very useful for diagnostics, but I played with it so that information may be disorted. Here is the screenshot:

Right, useless information, if one want to know whether the Sun Triggered the automation :grin: