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
Change pressure unit of measurement from mbar to hPa in Netatmo integration #86210
Conversation
Hi ljungqvist It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
Hey there @cgtobi, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
@@ -113,7 +113,7 @@ class NetatmoSensorEntityDescription(SensorEntityDescription, NetatmoRequiredKey | |||
name="Pressure", | |||
netatmo_name="pressure", | |||
entity_registry_enabled_default=True, | |||
native_unit_of_measurement=UnitOfPressure.MBAR, | |||
native_unit_of_measurement=UnitOfPressure.HPA, |
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.
This is a breaking change.
Is that needed? As in, if you like prefer hPa, you can change the unit for your entity to your liking.
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.
I think the device_class
should be adjusted instead to use SensorDeviceClass.ATMOSPHERIC_PRESSURE
See
core/homeassistant/util/unit_system.py
Lines 261 to 266 in 74096b8
# Force atmospheric pressures to hPa | |
**{ | |
("atmospheric_pressure", unit): UnitOfPressure.HPA | |
for unit in UnitOfPressure | |
if unit != UnitOfPressure.HPA | |
}, |
and
core/homeassistant/util/unit_system.py
Lines 302 to 307 in 74096b8
# Force atmospheric pressures to inHg | |
**{ | |
("atmospheric_pressure", unit): UnitOfPressure.INHG | |
for unit in UnitOfPressure | |
if unit != UnitOfPressure.INHG | |
}, |
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.
This is a breaking change.
Because there is a device_class and the unit is compatible, it shouldn't be a breaking change.
However, I think adjusting the device_class is better if it always refers to atmospheric pressure.
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.
This is a breaking change.
Is that needed? As in, if you like prefer hPa, you can change the unit for your entity to your liking.
The default should be hPa, as it is the correct unit for atmospheric pressure.
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.
? That is what the description already said. IMHO not enough to justify a breaking change. See also comment from epenwt above.
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.
Changing the device_class
is NOT a breaking change (existing sensors will keep using the old unit, new sensors will get the new unit).
Regarding the native_unit_of_measurement
, the netatmo documentation specifies mbar
in https://dev.netatmo.com/apidocumentation/weather so I think it's better to keep it as it is and avoid any chance of a breaking change.
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.
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.
Cool! Still, see the last comment by @epenet, it is communicated as mbar
by the API itself as well. We should match upstream. We should set a suggested unit if we think it should differ.
But that said, if it is a standard we want to have, we should take care of that system-wide (like preferred units as planned originally) and not a one-off.
That said, it is still a breaking change for external systems (like InfluxDB or any other recording system). -> No longer true indeed 👍
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.
Note: whatever the integration says, it will be converted to hPa for "atmospheric_pressure"
…RE` in Netatmo integration
I reverted the change of unit, which is not needed, and also updated the PR description accordingly. Thanks for the PR @ljungqvist 👍 |
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.
Thanks, @ljungqvist 👍
../Frenck
Proposed change
The
device_class
of the pressure in the Netatmo integration changed fromPRESSURE
toATMOSPHERIC_PRESSURE
.This means the unit of measurement will be automatically converted from mbar, which is used by the Netatmo API to hPa which is recommended by the World Meteorological Organization for reporting atmospheric pressure, if the user's unit system is metric, and to inHg if it's US customary.
Type of change
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
.To help with the load of incoming pull requests: