I’m new to Home Assistant and have been getting things figured out well. I have successfully built some automations but this one has me stumped. I’m trying to have some lights turn on in my Family Room when the sun sets. I have the correct Time Zone. If I select the Sun Device as a trigger and Sunset in that trigger as an event nothing happens. If I Run actions the light comes on every time.
So I thought about using the event (sun_next_dusk or sun_next_setting) as a trigger but they don’t allow an offset so by the time the light would come on this north facing room will be impossibly dark. I know there has to be a way to do this but the logic is escaping me. For today the sun_next_dusk is 8:32PM and the sun_next_setting is 7:54PM.
I’ve been trying very hard to figure these things out myself and not be one of those guys but I could really use some help with this one.
If you start a new automation in the GUI, and start by creating a new TRIGGER, there should be a few types of trigger choices displayed. If TIME & LOCATION is selected, you should see a SUN option that can be selected in order to get to the following dialog:
If you don’t get to there. . . I don’t recall if this requires the SUN integration to be installed. It’s been a minute since I went to SETTINGS / INTEGRATIONS and added the SUN integration, but I suppose this is why I did it. [:thunk:]
Post the automation you created that uses a Sun Trigger (in YAML format; not a screenshot of the UI).
BTW, if the automation fails to trigger at sunset, it will produce no traces. I suggest you check the automation’s traces and see if any were produced.
Because, as its name indicates, it simply runs the actions of your automation. It doesn’t test the automation’s triggers and conditions so it’s not a comprehensive test.
Check the automation’s traces to see when was the last time it triggered (if ever). For more details about traces, refer to the link in my previous post.
It is useful to make sure that your actions are written correctly. It’s especially helpful with complex actions.
You don’t need both, but since your actions are working let’s not mess with it for now. But come back to this later and we can show you how to make your automation more readable.
If you know what time sunset is, set the offset to trigger in the next hour then come back to look at the trace. Post a screenshot of the trace
Suddenly last night it started working. Even before I had a chance to make the changes you suggested. My wife and I were sitting in the Family Room and the lights came on. I did do the software update to 2025.4.2 earlier in the day. Maybe that helped?