Hi. I’ve got the time zone set correctly in HA and sun.sun is reporting a correct sunrise time:
But now, i have added a following condition to an automation:
condition: sun
after: sunset
before: sunrise
And it doesnt seem to work an hour before sunrise:
What may be causing this oddity?
Seems that sunrise condition in automations takes GMT timezone, but everywhere else the timezone is set correctly to BST.
Ha! That makes absolute sense.
Forgot about that while redoing my automation in GUI.
But to be honest, if GUI automation editor allows me to select both before and after, i would assume that it should format the YAML correctly
It’s not a question of YAML formatting. You created a single Sun Condition with two options. That’s exactly what the Automation Editor produced. Francisp showed that the correct way to do it is to create two Sun Conditions that are logically ORed. That’s not a mere formatting difference it’s a completely different conditional expression.
In your case, you may wish to consider using a State Condition.
condition:
- condition: state
entity_id: sun.sun
state: 'below_horizon'