Sunset not working as condition

I think it would have worked using your original conditions but only if you understand how the sunset/sunrise events are processed.

“after sunset” is any time between sunset and the following midnight. So if sunset is at 6 pm the “after: sunset” condition is true for any time between 6pm and midnight.

Likewise, “before sunrise” is any time between the previous midnight and sunrise.

By default all conditions are ‘and’. so in your original automation you are requiring that the time be both between sunset and midnight, and also between midnight and sunrise simultaneously. I think you should now see why it never worked.

to get it to work correctly you needed to make those two conditions as ‘or’. So then it would have worked if the time was either between sunset and midnight or between midnight and sunrise. Effectively making the condition being between sunset and the next sunrise which is what you ultimately wanted.

2 Likes