Skip to content
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

Fix TOD incorrectly determining the state between sunrise and sunset #65884

Merged
merged 2 commits into from
Feb 8, 2022

Conversation

nvx
Copy link

@nvx nvx commented Feb 6, 2022

Proposed change

The changes made in PR #30199 which contains fixes for #24577 and #21974 were accidentally reverted in #48573 which has caused the time of day component to show an incorrect state after home assistant restarts in some situations, for example as per #50315

This PR is just a cherry-pick of the commit from #30199 to re-apply the same fix.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

…nd sunset (home-assistant#30199)

* TOD fix

* Comment added

* Review

* Review

* Review
@nvx
Copy link
Author

nvx commented Feb 6, 2022

Looks like I'll need to update the previous patch a little. Was hoping it'd be a simple cherry-pick only.

@homeassistant
Copy link
Contributor

Hi @nvx,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@nvx
Copy link
Author

nvx commented Feb 7, 2022

Seems to run fine now with the trivial edit on the original cherry-picked commit and confirmed locally the issue is resolved.

Is it fine to be merged as-is, otherwise I can squash the two commits into one if that's preferred.

@nvx
Copy link
Author

nvx commented Feb 7, 2022

Strangely running black locally didn't complain, but the CI workflow didn't like it. Guessing I'm not running black with the right config locally? https://developers.home-assistant.io/blog/2019/07/31/black/ didn't indicate much

@nvx
Copy link
Author

nvx commented Feb 8, 2022

Finally sorted out my environment, turns out I was on the wrong branch running black and unit tests hence thinking it was working.

I've also added a unit test now that fails without this fix, but succeeds with the fix enabled.

I squashed all of my commits into a single commit, but I left the original cherry-picked commit to retain author information.

current version.
Only apply fix when using times and not when using sun events.
Add unit test for behaviour.
@MartinHjelmare MartinHjelmare changed the title Fix TOD component incorrectly determining the state between sunrise and sunset (#50315 - re-applies #30199) Fix TOD incorrectly determining the state between sunrise and sunset Feb 8, 2022
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Thanks!

@MartinHjelmare MartinHjelmare added this to the 2022.2.4 milestone Feb 8, 2022
@MartinHjelmare MartinHjelmare merged commit 2df5060 into home-assistant:dev Feb 8, 2022
balloob pushed a commit that referenced this pull request Feb 8, 2022
…65884)

* Fix TOD component incorrectly determining the state between sunrise and sunset (#30199)

* TOD fix

* Comment added

* Review

* Review

* Review

* Update time after day fix workaround for compatibility with
current version.
Only apply fix when using times and not when using sun events.
Add unit test for behaviour.

Co-authored-by: Nikolay Vasilchuk <Anonym.tsk@gmail.com>
@balloob balloob mentioned this pull request Feb 8, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Feb 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Times of the Day broken
5 participants