Weather units: nws to zamg (4/4)#60831
Conversation
|
Hey there @fabaff, @freekode, @nzapponi, mind taking a look at this pull request as it has been labeled with an integration ( |
|
Hey there @MatthewFlamm, mind taking a look at this pull request as it has been labeled with an integration ( |
|
As the tests indicate the data from NWS comes in different units for observations and forecasts currently. I believe there is a new option in the API to change the forecast units, but this isn't available in the upstream library yet. Until then, I don't think you can include NWS in this. |
Apologies if I'm misunderstanding, but it looks like the data from _attr_temperature_unit = TEMP_CELSIUS
_attr_pressure_unit = PRESSURE_PA
_attr_wind_speed_unit = SPEED_KILOMETERS_PER_HOUR
_attr_visibility_unit = LENGTH_METERS#59533 added unit conversion inside the base weather entity class, so these units will be converted back into the user's user system. It is a bit of extra work to have (for example - this applies to pressure/wind speed too) pynws convert Fahrenheit to Celsius then make the weather entitity base class convert Celsius to Fahrenheit; a cleaner solution would be to make |
This is incorrect. The current observations are in one unit system. The forecasts are in a different set of units. Check the wind speed and temperature conversions in the existing nws weather module. Temperature is covered to Fahrenheit here so that it matches the forecast unit. core/homeassistant/components/nws/weather.py Line 163 in 5907f66 The temp is unchanged in the forecast. core/homeassistant/components/nws/weather.py Line 259 in 5907f66 #59533 assumes that these units are the same. |
|
Right forecast is currently in us units and observations in si units. Forecast can be configured to be in si units too (observations are not configurable), but there are some features like the textual detailed forecast which wouldn't be converted back to us units here. It would be best for NWS API to support us and si units for both forecasts and observations. Second best would be for pynws to allow observations to be converted to us units. I'm not sure if it will get done, or should get done for this PR though. |
MatthewFlamm
left a comment
There was a problem hiding this comment.
LGTM for NWS with some minor comments.
Based on the needed changes in the tests, it looks like the precision of the data is changing. This could be a breaking change if any users have an equality in their automations, although unlikely.
|
I think breaking the automations is very unlikely. Using less than or greater than comparisons I can see, but not equality. Many of these PRs updating weather units are standardizing the precisions, so I think this would clutter release notes too much. |
dab62cd to
4b8f1c0
Compare
|
This is a massive breaking change. Also:
|
|
If this doesn't get merged or something similar than the entity model for weather continues to be broken. Should we additionally revert the earlier changes that convert units to non -supported values? |
In all cases, it is broken. Adding these PRs is also massively breaking. See also the revert PRs you have been tagged on: #63843 Unfortunately, we had no response. |
|
I have no strong feeling on how this is fixed. But #59533 introduced the first breaking change that changed the entity model (no breaking change was noted or architecture decision was made). At least these PRs bring back the units to match the entity model, but I understand there are other changes that are unwanted. If so should we revert #59533? |
You misunderstood, it is wanted. We just need to mitigate a breaking change for the end-user. While there is already a partly breaking change shipped, merging the change of all these units is a massive breaking change for all weather entities across the board. |
|
Can we modify #59533 to convert to the accepted units as part of the stated entity model? I'm trying to figure out how to address the broken units issue currently. The situation seems unclear to me. |
|
@frenck Sorry about the delays replying to this. I've had a lot going on personally and there's been a lot to keep up with. As I understand, we had previously merged changes to the base weather entity that had made some more quantities like wind speed, pressure, etc determined by the global unit system. Is the path forwards to revert everything including the changes to the base weather entity, so we are back to where Home Assistant stood before these PRs? Or are you imagining a different way? |

Proposed change
Uses the new weather conversion in the weather entity ( #59533) to convert weather values to the configured units.
Type of change
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: