core icon indicating copy to clipboard operation
core copied to clipboard

Update metoffice to use DataHub API

Open avee87 opened this issue 1 year ago • 13 comments

Breaking change

MetOffice is deprecating Datapoint API currently used by this integration and it's going to stop working in March 2025. To keep integration working, it's now migrated to DataHub API.

To keep integration working, you will need to provide it a new API key which can be obtained by signing up for DataHub and subscribing to Global spot dataset. Free subscription provides 360 calls per day which is enough for this integration to work.

Some sensors have changed due to new data source:

  • hourly forecast provided by weather entity now has actual hourly entries as opposed to 3-hourly in the old version
  • instead of visibility and visibility_distance sensors showing a range and qualitative description (such as "1-4 km" and "Poor"), integration now exposes a single visibility sensor with precise visibility distance in meters
  • integration no longer exposes "daily" and "3-hourly" sensors, there is a single set of them now
  • sensors no longer expose Site ID, Site name and Sensor ID attributes as these don't provide any additional value

Proposed change

  • Integration was rewritten to support the new API based on datapoint-python 0.12.1.
  • Updated forecast types to twice_daily and hourly to reflect the data returned by the API.
  • Added some new weather attributes provided by new API

I had to bump aio-geojson-generic-client dependency from 0.4 to 0.5 to avoid conflicts. Changelog explicitly references Home Assistant dependency conflicts as a primary reason for update so I don't expect this to cause issues.

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)
  • [x] 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 #125210 #141502
  • This PR is related to issue:
  • Link to documentation pull request: https://github.com/home-assistant/home-assistant.io/pull/35954

Checklist

  • [x] The code change is tested and works locally.
  • [x] Local tests pass. Your PR cannot be merged unless tests pass
  • [x] There is no commented out code in this PR.
  • [x] I have followed the development checklist
  • [x] I have followed the perfect PR recommendations
  • [x] The code has been formatted using Ruff (ruff format homeassistant tests)
  • [x] 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:

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

To help with the load of incoming pull requests:

avee87 avatar Nov 23 '24 23:11 avee87

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

Code owner commands

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

home-assistant[bot] avatar Nov 23 '24 23:11 home-assistant[bot]

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

Code owner commands

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

home-assistant[bot] avatar Nov 23 '24 23:11 home-assistant[bot]

I had to bump aio-geojson-generic-client dependency from 0.4 to 0.5 to avoid conflicts. Changelog explicitly references Home Assistant dependency conflicts as a primary reason for update so I don't expect this to cause issues.

I'm happy to include this version bump here. Alternatively I could create a separate version bump PR, I simply haven't had a chance to do that yet.

exxamalte avatar Nov 24 '24 02:11 exxamalte

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:

Learn more about our pull request process.

home-assistant[bot] avatar Dec 18 '24 12:12 home-assistant[bot]

I get that you want to get as much in as possible, but to get the review in a decent way, please strip out new features from this PR and let's take them in follow-up PR's instead.

gjohansson-ST avatar Dec 28 '24 15:12 gjohansson-ST

Since I merged dependency bump in a separate PR, would it be possible to remove integration: geo_json_events tag to avoid potentially polluting release notes?

avee87 avatar Dec 30 '24 23:12 avee87

This PR has been waiting for review for a very long time now and there are multiple reports of old service degrading as it gets closer to shutdown date.

Is there anything I could do to speed things up?

avee87 avatar Apr 11 '25 23:04 avee87

The metoffice HA integration has been very handy for me over the last few years. The datapoint api is very hit and miss last couple of months though and the integration is regularly "unavailable". I would hate to lose it outright and hope this PR makes it into a release soon.

I really appreciate the efforts of @avee87 and the other contributors trying to keep this alive. Kudos!

morini3andahalf avatar Apr 19 '25 19:04 morini3andahalf

What is the hold up? Doesn't this just need merged? Why has it sat so long?

cgarz avatar May 02 '25 05:05 cgarz

Removing beta milestone from this PR as it is a breaking change and from https://www.metoffice.gov.uk/services/data/datapoint/datapoint-retirement-faqs the API will be shutdown later in 2025 and not on March 2025. Therefore no need to include it in the beta

edenhaus avatar May 05 '25 09:05 edenhaus

the API will be shutdown later in 2025 and not on March 2025. Therefore no need to include it in the beta

the API shutdown was pushed back from March to September 2025, but the API has been closed for new signups, so at the moment the MetOffice integration only works for existing API users

gcoan avatar May 05 '25 10:05 gcoan

Met Office have said that they are no longer allowing new datapoint api key users. Unless this has changed, this effectively means that the met office integration is broken for all new homeassistant users.

GreatAlbatross avatar May 05 '25 10:05 GreatAlbatross

What? It's getting pushed back again? 😩

Why??? I can't sign up for the old api. Doesn't this just need merged?

cgarz avatar May 05 '25 10:05 cgarz

Let's just get this done?

MrHarcombe avatar May 21 '25 19:05 MrHarcombe

Fantastic! It works! Thanks a bunch! :hearts:

I was impatient and I run via docker so I just mapped the update over /usr/src/homeassistant/homeassistant/components/metoffice and now I have a nice and much more reliable (hopefully) weather API :partying_face:

cgarz avatar May 22 '25 00:05 cgarz