Skip to content

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

Merged
merged 1 commit into from
Feb 13, 2018

Conversation

Human
Copy link
Contributor

@Human Human commented Feb 12, 2018

…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:

  • Branch: Fixes, changes and adjustments should be created against current. New documentation for platforms/components and features should go to next.
  • The documentation follow the standards.

@Human
Copy link
Contributor Author

Human commented Feb 12, 2018

Resolves issue #12308

@Human
Copy link
Contributor Author

Human commented Feb 13, 2018

@mf-social Would you like to handle the review?

Copy link
Contributor

@point-4ward point-4ward left a 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 👍

Copy link
Contributor

@arsaboo arsaboo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🥇

@arsaboo arsaboo merged commit f97d518 into home-assistant:current Feb 13, 2018
@Human Human deleted the patch-2 branch February 13, 2018 16:45
@ryanwinter
Copy link

The truth table is still misleading, or just downright wrong.

@arsaboo
Copy link
Contributor

arsaboo commented Feb 13, 2018

@ryanwinter Create a separate PR for the truth table please..thanks!

@ryanwinter
Copy link

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.

@point-4ward
Copy link
Contributor

point-4ward commented Feb 13, 2018

^ 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.

@ryanwinter
Copy link

ryanwinter commented Feb 13, 2018

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.

@point-4ward
Copy link
Contributor

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. 🤔

@ryanwinter
Copy link

Yes, but a night runs from sunset to sunrise, and we are talking about sun related conditions.

@point-4ward
Copy link
Contributor

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.

@ryanwinter
Copy link

ryanwinter commented Feb 13, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants