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

Migrate OpenWeaterMap to new library (support API 3.0) #116870

Merged
merged 24 commits into from
May 24, 2024

Conversation

freekode
Copy link
Contributor

@freekode freekode commented May 5, 2024

Breaking change

Migration to new library with support of OneCall API (3.0).

OWM API v2.5 will be closed in June 2024. All OpenWeatherMap integrations must be migrated to mode (API) v3.0 to avoid service interruption.

Before the migration, you must have an active subscription (be aware that subscription activation takes up to 2h). After the subscription is activated, users can migrate integrations to mode v3.0 via repair notification or manually via the integration configuration menu.

The subscription has a free tier with 1000 calls/day. Consider setting the limit on the OpenWeatherMap website to stay under the threshold where API usage incurs a cost.

OpenWeatherMap official statement

Proposed change

Migrate new library pyopenweathermap I created specifically for Home Assistant. Currently, used pyowm library didn't have an update for a long time and seems dead.
Remove forecast modes, one call allows to retrieve daily and hourly forecasts. Remove migration from V1 to V2 of config_flow, forecast mode isn't used anymore, there is no need for migration.

New lib https://github.com/freekode/pyopenweathermap

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

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 May 5, 2024

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

Code owner commands

Code owners of openweathermap 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 openweathermap 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.

freekode and others added 2 commits May 6, 2024 09:01
Co-authored-by: J. Nick Koston <nick@koston.org>
@freekode freekode marked this pull request as ready for review May 7, 2024 17:46
@freekode freekode requested a review from fabaff as a code owner May 7, 2024 17:46
@bdraco
Copy link
Member

bdraco commented May 8, 2024

I was hoping to be able to do another review pass on this before I'm flying all day tomorrow but it looks like the day got away from me. I'll be traveling for a week so I'll minimal time to look at this one. I'd like to try to get it merged before the 2024.6.x beta though given API 2.5 is going to go away.

freekode and others added 2 commits May 12, 2024 09:56
Co-authored-by: J. Nick Koston <nick@koston.org>
@freekode
Copy link
Contributor Author

I'm still traveling until Thursday, but I wanted to give you feedback on the issue so we can be sure to get it in before beta.

Thanks, have a nice trip :)

@frenck frenck marked this pull request as draft May 18, 2024 15:27
@frenck
Copy link
Member

frenck commented May 18, 2024

I've marked this PR, as changes are requested that need to be processed.
Please un-draft it once it is ready for review again by clicking the "Ready for review" button.

Thanks! 👍

../Frenck

Learn more about our pull request process.

@freekode freekode marked this pull request as ready for review May 21, 2024 16:13
@bdraco
Copy link
Member

bdraco commented May 22, 2024

Screenshot 2024-05-22 at 10 40 01 AM Screenshot 2024-05-22 at 10 40 07 AM Screenshot 2024-05-22 at 10 40 14 AM

Almost there, but It looks like its always rejecting the API key now.

I also tried setting it up fresh with the same api key that is working with v2.5 and its rejecting it with the same error

@freekode
Copy link
Contributor Author

yep, fixed

Copy link
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

Thanks @freekode

@bdraco
Copy link
Member

bdraco commented May 23, 2024

Tested, everything working. Migration to 3.0 successful

@bdraco bdraco added the smash Indicator this PR is close to finish for merging or closing label May 23, 2024
@bdraco
Copy link
Member

bdraco commented May 23, 2024

Please update the breaking change section to tell users what they need to do. The target audience for breaking changes is the user consuming the change. This will get published nearly verbatim in the release notes.

@freekode
Copy link
Contributor Author

Added more info in PR description

@bdraco
Copy link
Member

bdraco commented May 23, 2024

During subscription activation OpenWeatherMap asks for your credit card, but won't charge anything.

That implies that's a guarantee they won't be charged which we cannot make since OWM might change their policies.

Suggested reword:

OWM API v2.5 will be closed in June 2024. All OpenWeatherMap integrations must be migrated to mode (API) v3.0 to avoid service interruption.

Before the migration, you must have an active subscription (be aware that subscription activation takes up to 2h). After the subscription is activated, users can migrate integrations to mode v3.0 via repair notification or manually via the integration configuration menu.

The subscription has a free tier with 1000 calls/day. Consider setting the limit on the OpenWeatherMap website to stay under the threshold where API usage incurs a cost.

@bdraco bdraco merged commit 24d3192 into home-assistant:dev May 24, 2024
38 checks passed
@freekode freekode deleted the upd-owm branch May 24, 2024 08:25
@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2024
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.

APi 2.5 to be closed in June 2024 New API keys for OpenWeatherMap OneCall do not work with API 2.5
4 participants