Add pressure mmhg unit conversion#35575
Conversation
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| VALID_UNITS = [PRESSURE_PA, PRESSURE_HPA, PRESSURE_MBAR, PRESSURE_INHG, PRESSURE_PSI] | ||
| VALID_UNITS = [PRESSURE_PA, PRESSURE_HPA, PRESSURE_MBAR, PRESSURE_INHG, PRESSURE_PSI, PRESSURE_MMHG] |
There was a problem hiding this comment.
Is anything using this code, ie the new unit?
There was a problem hiding this comment.
No, there is no code yet that uses this.
But in the forum I met a lot of requests to add these units. And I myself am more familiar with them. That's why I added them.
There was a problem hiding this comment.
mmHg is usual pressure unit for CIS sitizens
There was a problem hiding this comment.
So if nothing is using it, why should it be added? As it sounds like this will add "dead" code to our codebase.
There was a problem hiding this comment.
The reason is that this (and only this) unit of pressure measurement is familiar to the CIS population (and this is more than 280 million people). More precisely -- all former regions of the USSR.
Yes, this unit is not currently used in the Home Assistant code. But in the forum, people regularly ask to add it, for example, to the weather frontend.
- https://community.home-assistant.io/t/pressure-units-in-the-weather-component-can-be-more-diverse/60944
- https://community.home-assistant.io/t/value-template/34950/6
- https://community.home-assistant.io/t/esphome-pressure-hpa-to-mmhg/171527
- etc.
What is the point of making “crutches” in separate modules when you can centrally add this unit to the core and solve the problem?
There was a problem hiding this comment.
Just because you live in a country where other standards are generally accepted, gives no reason to ignore the standards generally accepted in countries on the other sixth of all the Earth’s land.
Yes, that integration developer could theoretically suggest this code. But for some reason he did not. Maybe because he didn’t even think that it was possible? Or maybe because the conversion of pressure units was added to the core code later than he did his component?
Adding this unit will allow this and other developers to make their work easier in the future. It will allow in the future users of Home Assistant from the CIS countries to use this system with great comfort.
I am sure that a little time will pass and this code will be claimed by developers and will cease to be dead.
There was a problem hiding this comment.
By the way, I also found an example when a person needs reverse conversion: https://community.home-assistant.io/t/change-the-unit-in-bloomsky-sensors/35837
There was a problem hiding this comment.
We won't accept this PR until there's an active use case in the code.
There was a problem hiding this comment.
Here is a use-case out-of-code. I, as many others, want to customize output of any weather sensor, which I'm not using ATM partially because there is no pressure unit, used in my country. I could use a template, but it would be a lot nicer to put one small setting in one sensor to make it work like all other system.
Please, put yourself in our shoes and image if your country's proffered pressure/temperature/whatever unit was not supported. Let's imagine for a second, that HA was originally developed not in the US, but somewhere in Europe with metric system. I really don't think that a US citizen coming with such a small proposal adding their unit of temperature measurement, would be rejected so harshly. There was a time, when there were no temperature units in HA, and it was corrected.
As for code usage - there are CIS weather services, such as Gismeteo and Yandex Weather, providing pressure in mmHg, not in hPa. And integrations for them could have used mmHg for their operation. Please see this integration's example code. This code could have used the proposed unit.
There was a problem hiding this comment.
This is about adding "dead" code to our codebase. As soon as there is a use case for it in our codebase, we are happy to accept and add it.
The integration you have linked it not the Home Assistant codebase. Feel free to open up a PR to add an integration to our codebase that add this and the new integration.
PS: Did you know most of us are not in the US? Like everybody who reviewed this PR? Thanks.
|
Since nothing is using the code in this PR at the moment I'll close now. Please open a new PR when there's code that uses this. Thanks for your contribution. |
Proposed change
In the CIS, the usual units of pressure are mmHg. This update just adds them.
Type of change
Additional information
Update is simple. There are no additional info, sorry :)
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: