WTH Sunrise - Sunset condition

The thing that made me go WTH:

I (and others) got frustrated with sunset/sunrise conditions. Using the GUI (or YAML) it seems like if you put before sunrise and after sunset in the same statement you should be able to get just that but you don’t because it is an AND, so never true. It can’t be before sunrise and after sunset on the same calendar day.

You have to put two statements:
Before Sunrise
- OR -
After Sunset.

Having something in the GUI that makes it clear this is an AND, would help even if it was just help text.

Or check the state of sun.sun, which can be below_horizon or above_horizon, which is probably the thing you are looking for?

2 Likes

I figured out how this works so I my automations are good. Using sun.sun is above/below_horizon works if you don’t want an offset.

My point is not that is is broken, but that it makes people go “what the heck”.
The scenario being someone new goes in to make an automation and sees the Sun condition so they go to use it. They want something at night so their intuition says before sunrise with before offset 30 minutes and after sunset after offset 30 minutes, and nothing happens. If they want something during the day they put after unrise+30minutes and before sunset-30 minutes and it works.

I just looked at the documentation on conditions and it is much better than last year when this confused me in that it has a note (and example) telling about using an OR to get after sunset to before sunrise. This is great but too many people try first, then RTFM later.

Since someone had this very issue a couple months ago I keep trying to think of better ways to communicate the way it works. Maybe if in the GUI it had the after condition first people would realize the sun has to be between the after condition and the before condition.

1 Like