mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 09:23:17 -04:00
Add kPa as a valid unit of measurement for pressure in weather entity (#165519)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
parent
5f1a7f4735
commit
876ab37064
@@ -81,6 +81,7 @@ INTENT_GET_WEATHER = "HassGetWeather"
|
||||
|
||||
VALID_UNITS_PRESSURE: set[str] = {
|
||||
UnitOfPressure.HPA,
|
||||
UnitOfPressure.KPA,
|
||||
UnitOfPressure.MBAR,
|
||||
UnitOfPressure.INHG,
|
||||
UnitOfPressure.MMHG,
|
||||
|
||||
@@ -145,6 +145,8 @@ def async_check_significant_change(
|
||||
UnitOfPressure.MMHG, # 1hPa = 0.75mmHg
|
||||
):
|
||||
absolute_change = 1.0
|
||||
elif unit == UnitOfPressure.KPA: # 1hPa = 0.1 kPa
|
||||
absolute_change = 0.1
|
||||
elif unit == UnitOfPressure.INHG: # 1hPa = 0.03inHg
|
||||
absolute_change = 0.05
|
||||
|
||||
|
||||
@@ -168,6 +168,14 @@ async def test_significant_state_change() -> None:
|
||||
},
|
||||
False,
|
||||
),
|
||||
(
|
||||
{ATTR_WEATHER_PRESSURE: 100},
|
||||
{
|
||||
ATTR_WEATHER_PRESSURE: 100.09,
|
||||
ATTR_WEATHER_PRESSURE_UNIT: UnitOfPressure.KPA,
|
||||
},
|
||||
False,
|
||||
),
|
||||
(
|
||||
{ATTR_WEATHER_PRESSURE: 29.5},
|
||||
{
|
||||
@@ -280,6 +288,14 @@ async def test_significant_state_change() -> None:
|
||||
},
|
||||
True,
|
||||
),
|
||||
(
|
||||
{ATTR_WEATHER_PRESSURE: 100},
|
||||
{
|
||||
ATTR_WEATHER_PRESSURE: 100.11,
|
||||
ATTR_WEATHER_PRESSURE_UNIT: UnitOfPressure.KPA,
|
||||
},
|
||||
True,
|
||||
),
|
||||
(
|
||||
{ATTR_WEATHER_PRESSURE: 29.5},
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ async def test_device_class_units(
|
||||
assert msg["result"] == {
|
||||
"units": {
|
||||
"precipitation_unit": ["in", "mm"],
|
||||
"pressure_unit": ["hPa", "inHg", "mbar", "mmHg"],
|
||||
"pressure_unit": ["hPa", "inHg", "kPa", "mbar", "mmHg"],
|
||||
"temperature_unit": ["°C", "°F"],
|
||||
"visibility_unit": ["km", "mi"],
|
||||
"wind_speed_unit": ["Beaufort", "ft/s", "km/h", "kn", "m/s", "mph"],
|
||||
|
||||
Reference in New Issue
Block a user