-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Provide an example of how to make a 'when dark' condition by ORing su… #4652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…nrise and sunset conditions. See issue#12308 at home-assistant/core#12308
Resolves issue #12308 |
@mf-social Would you like to handle the review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 🥇
The truth table is still misleading, or just downright wrong. |
@ryanwinter Create a separate PR for the truth table please..thanks! |
I'm wondering if the current code makes sense. It uses midnight as an additional state change point, but this isn't obvious, or something anyone would need. I actually think the current table reflects what it should do. Let me think of a code change to propose instead. |
^ I think that's intentional, otherwise it will always be true. If you make it go past midnight, at any given daylight time it is after sunrise today and before sunrise tomorrow, at any given darkness time it is after sunset today and before sunset tomorrow. But it is also after both conditions yesterday and before both conditions for tomorrow. There has to be a cutoff and midnight makes perfect sense IMO. |
I think that the cutoff should be the next sun event which will trigger the end state change, rather than an arbitrary time which was likely picked as midnight to simplify code. I mean why not 3am, midday, 8:57pm? I am proposing that the current sun truth table be reflected in code. |
Because it is after sunrise / sunset on the day in question, a day runs from midnight to midnight, not 3 - 3 or any other time. 🤔 |
Yes, but a night runs from sunset to sunrise, and we are talking about sun related conditions. |
Yes, and sun related conditions do not exclusively cater for when it is dark. They currently cater for whether the sun is up or down on that particular day. Day as in Monday, Wednesday etc, not 'the time it was (or will be) light' Like I say, it works well for me in that format, but if you think it's better another way then that's cool. I was just thinking it will be a massive breaking change for people's long-standing automations so you might want to garner some more opinions before spending time rewriting the logic. |
Well I agree this could be a breaking change, people (including myself) have either written logic to work around this weird effect, or moved to sun elevation instead to bypass the confusing logic which contradicts the documentation. Let me take a quick look at a coding solution first and see if this makes sense. |
…nrise and sunset conditions.
See issue#12308 at home-assistant/core#12308
Description:
Pull request in home-assistant (if applicable): home-assistant/home-assistant#
Checklist:
current
. New documentation for platforms/components and features should go tonext
.