Can you name a time of day that is both after sunset and before sunrise?
Likewise is there a time of day both after 18:00 and before 6:00?
I find that using the sun’s elevation is easier to get right. Elevation is negative = sun is below the horizon = after sunset one day and before sunrise the next day.
- alias: 'timing-Back door light on at night'
trigger:
platform: numeric_state
entity_id: sun.sun
attribute: elevation
below: 0
action:
service: switch.turn_on
entity_id: switch.back_door_motion_light
There are no “or” conditions in the Automations editor, only via YAML.There is no way to do this with the Sun condition in the UI editor. That’s probably what threw me off. I’ll do it in YAML. Thanks.
The UI as seen in my screenshot is wrong then. It leads me to think when I set “after: sunset” and “before: sunrise”, it should work.or at least tell me there’s an issue. It’s just bad UX.
As for the time condition, I have no idea as well.
Sorry but that’s even worse than I thought. Having parameters like Sun, Status and such mixed in the same menu as condition types such as AND, OR is a really, really bad UI - it’s just diffrent categories of things. I’d expect it to be between the different conditions, or on top, as an any other automation software.
AND it doesn’t solve the fact that the UI in my mobile screenshot above just doesn’t indicate what I’m trying can’t be done. Why is that UI that lets me designate BOTH Before and After even there, then? Either let me do what I want (which isn’t something unexpected, it’s just “do X in nighttime”) OR split the condition into separate After and Before.
I’m not doing anything weird here. I’m using the built-in functionality as presented. Sorry but that’s bad UX, no matter how you slice it.
then the UI is, again, bad as that means night time can’t be defined by a single condition, so there’s no point in having both before/after and sunset/sunrise.
It’s incredibly difficult to devise good UI for complex systems with all sorts of conditions like HA, I don’t blame anyone. I’m just pointing out it’s confusing and unintuitive and maybe something devs could look into.
Creating an automation with the Automation Editor or a text editor have something in common: they provide you with the freedom to compose utter nonsense.
The Automation Editor guards against common syntax errors (a text editor won’t, unless you use something like VS Code with a few plugins). However, neither have a “Home Assistant logic checker”; they allow you to create unsound logic (like an invalid Sunset/Sunrise Condition).
Anyway, the original question was answered many posts ago and the rest of the thread has become a
“I read the owner’s manual but the car let me drive into the ditch!”
Well, I don’t understand a point of having a special Sun condition in the editor that doesn’t allow for “sun is down”, I.e. one of the two possible states of Sun. It’s misleading and leads to futile threads like this. That’s all.