-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Met.no migrate from classic to complete endpoint #39493
Met.no migrate from classic to complete endpoint #39493
Conversation
- Update code to handle new endpoint json format - Use hourly forecast for current weather, not daily - Update precipitation calculation - Ensure compared datetime objects are compared in the same time zone - Use data from full 24 hours to calculate daily forecast min/max/sum values - Add `precipitation_probability` to forecast parameters
Hey there @Danielhiversen, mind taking a look at this pull request as its been labeled with an integration ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thank you for your contribution thus far! 🎖 Since this is a significant contribution (counting the upstream changes as well), we would appreciate you'd added yourself to the list of code owners for this integration. ❤️ Please, add your GitHub username to the For more information about "code owners", see: Architecture Decision Record 0008: Code owners. |
Hi @frenck, Code owners have been updated. I see there are a few failing checks on the CI. I'm having a bit of an issue getting my local dev environment to run tests and it's getting late where I am. Might have to come back to this tomorrow. |
dc6ae00
to
5499714
Compare
With the addition of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The weather forecast data returned in the weather forecast
property must be defined within home assistant as it's part of the home assistant API. Changing the library must not change the returned data implicitly. Changes should be explicitly done inside home assistant.
https://developers.home-assistant.io/docs/core/entity/weather#forecast
So the change would be to have pyMetno return keys native to it, then map those keys to HA constants in the HA met.no component? |
Yes, exactly. 👍 |
Cool, happy to make that change. @Danielhiversen, I see two ways forward:
The latter has the benefit of pyMetno returning more accurate forecasts for direct users of pyMetno, with the drawback that it'll be a breaking change for those very users. The former is less work and less hassle for users upgrading, but leaves an unstated connection between pyMetno and the HA component from the pyMetno side. |
The component is now using constants. I also noticed met.no serves wind direction in degrees, whereas Home Assistant expects a 1-3 letter string according to the docs. It's all in need of a proper test. I've so far been lazy and testing on my production instance, though I'm unable to do that currently after a recent change to the |
b6657eb
to
28bcb10
Compare
The frontend should be able to convert azimuth angle degrees to cardinal direction letters, so we should keep the current state to not break user automations. We allow both ways at the moment. I have a PR open to update the docs. |
* Roll back conversion of wind direction to cardinal direction letters * Remove ATTR_WEATHER_CONDITION constant from weather component * Filter out None value keys from forecast
Looks good! Seems there's a test failure for the met integration. |
Working on that now. Getting set up with a proper dev environment so I can run tests locally. |
This test fails for me on the dev branch without this update as well. Might be related to b258e75. I'll poke around some more. |
…ata()` This causes a test to fail in home-assistant/core#39493
…ata()` This causes a test to fail in home-assistant/core#39493
Okay, the test is failing due to an issue I introduced in pyMetno 0.8.0. I've created a PR for that: Danielhiversen/pyMetno#25 |
On a side note, pyMetno 0.8.0 and later serves time stamps in UTC rather than local time zones with an offset as described in #38193. Let me know if you'd prefer not rocking the boat and reverting that change. |
…ata()` (#25) This causes a test to fail in home-assistant/core#39493
UTC is the correct time format for state attributes. That's our standard. 👍 Please mention it in the breaking changes. |
Ping me when the description is updated:
Then we can merge. |
@MartinHjelmare I've made those updates. Black failed now, but it's on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Black will be fixed here: |
Breaking change
In updating pyMetno to use the newer endpoint, some of the calculations and forecast aggregations were tweaked a bit:
None of these changes are expected to break someone's setup, though the data presented might look a little different due to the above.
In addition, all time stamps are now given in UTC. Automations that depend on the
datetime
key under the state attributeforecast
needs to be checked and updated.Proposed change
Bump met component requirement to myMetno-0.8.1: https://github.com/Danielhiversen/pyMetno/releases/tag/0.8.1
The new release has the following changes.
precipitation_probability
to forecast parametersType of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: