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

Remove hourly weather entity from NWS #112503

Merged
merged 3 commits into from
Mar 22, 2024
Merged

Remove hourly weather entity from NWS #112503

merged 3 commits into from
Mar 22, 2024

Conversation

gjohansson-ST
Copy link
Member

Breaking change

The nws integration previously created two entities for each configured location, one entity which provided daily weather forecasts and one entity which provided hourly forecasts. The nws integration now only creates a single entity which provides both daily and hourly weather forecasts.

Proposed change

Remove the hourly weather entity from nws and instead provide hourly + daily forecasts in one entity

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)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format 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.

To help with the load of incoming pull requests:

@home-assistant
Copy link

home-assistant bot commented Mar 6, 2024

Hey there @MatthewFlamm, @kamiyo, mind taking a look at this pull request as it has been labeled with an integration (nws) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of nws can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign nws Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

# Add hourly entity to legacy config entries
if entity_registry.async_get_entity_id(
# Remove hourly entity from legacy config entries
if entity_id := entity_registry.async_get_entity_id(
Copy link
Contributor

Choose a reason for hiding this comment

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

At some point we can assume that users will no longer have this entity. Should we aim to remove this code at some point, and add a comment to this effect? Or are we committing to keeping this around?

Copy link
Member Author

Choose a reason for hiding this comment

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

6 releases is the general deprecation time so I guess that's relevant here too for cleaning this up eventually.

@MatthewFlamm
Copy link
Contributor

The available code also no longer works if the user is expecting that this will also represent the availability of the hourly forecast data. To be consistent we should probably remove the forecast coordinator or expand to using both forecast coordinators.

Unfortunately if we expand to check all coordinators last success to check for availability, this combined hourly and twice daily forecast structure will make it even more likely for this entity to show unavailable.

@kamiyo
Copy link
Contributor

kamiyo commented Mar 11, 2024

I don't know how many days the forecasts are usually, but can we cache the results and only return false from available if neither last update did not succeed nor is there any current data in the forecast (last forecast date < now)?

@MatthewFlamm
Copy link
Contributor

MatthewFlamm commented Mar 11, 2024

I don't know how many days the forecasts are usually, but can we cache the results and only return false from available if neither last update did not succeed nor is there any current data in the forecast (last forecast date < now)?

The way it works currently is similar but slightly different. If the last success time was within some time period from now then it is considered available, otherwise unavailable. This PR keeps this, but we now only have one entity with two forecast coordinators. Only one forecast coordinator is used to determine availability. I worry that including both will cause extra 'unavailable' times for users who just want one forecast. The NWS servers are flaky enough that this is a problem. But not including them all will result in potentially more stale forecasts to be shown.

@gjohansson-ST
Copy link
Member Author

Changing the behavior of the available property and/or adjusting the coordinators are not in scope of this PR so feel free to do so in a separate PR in a follow-up 👍

Copy link
Contributor

@MatthewFlamm MatthewFlamm left a comment

Choose a reason for hiding this comment

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

This generally LGTM. However, I think it would be good to have feedback on how much time must elapse before we can assume users no longer have the hourly entity to clean up the code.

@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Mar 13, 2024
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @gjohansson-ST 👍

../Frenck

@frenck frenck merged commit 7df0d3b into dev Mar 22, 2024
21 checks passed
@frenck frenck deleted the nws-remove-hourly branch March 22, 2024 15:32
@github-actions github-actions bot locked and limited conversation to collaborators Mar 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking-change cla-signed code-owner-approved has-tests integration: nws Quality Scale: platinum small-pr PRs with less than 30 lines. smash Indicator this PR is close to finish for merging or closing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants