Correct flow rate conversion review after merge (#109501)

pull/106803/head
Joakim Plate 2024-02-04 15:01:06 +01:00 committed by GitHub
parent e109ed53eb
commit eefc6cd50a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 3 deletions

View File

@ -36,7 +36,13 @@ from homeassistant.loader import async_suggest_report_issue
from homeassistant.util import dt as dt_util
from homeassistant.util.enum import try_parse_enum
from .const import ATTR_LAST_RESET, ATTR_STATE_CLASS, DOMAIN, SensorStateClass
from .const import (
ATTR_LAST_RESET,
ATTR_STATE_CLASS,
DOMAIN,
SensorStateClass,
UnitOfVolumeFlowRate,
)
_LOGGER = logging.getLogger(__name__)
@ -52,6 +58,7 @@ EQUIVALENT_UNITS = {
"RPM": REVOLUTIONS_PER_MINUTE,
"ft3": UnitOfVolume.CUBIC_FEET,
"m3": UnitOfVolume.CUBIC_METERS,
"ft³/m": UnitOfVolumeFlowRate.CUBIC_FEET_PER_MINUTE,
}
# Keep track of entities for which a warning about decreasing value has been logged

View File

@ -688,7 +688,7 @@ async def test_restore_number_restore_state(
38.0,
),
(
SensorDeviceClass.VOLUME_FLOW_RATE,
NumberDeviceClass.VOLUME_FLOW_RATE,
UnitOfVolumeFlowRate.LITERS_PER_MINUTE,
UnitOfVolumeFlowRate.GALLONS_PER_MINUTE,
UnitOfVolumeFlowRate.GALLONS_PER_MINUTE,
@ -696,7 +696,7 @@ async def test_restore_number_restore_state(
"13.2",
),
(
SensorDeviceClass.VOLUME_FLOW_RATE,
NumberDeviceClass.VOLUME_FLOW_RATE,
UnitOfVolumeFlowRate.GALLONS_PER_MINUTE,
UnitOfVolumeFlowRate.LITERS_PER_MINUTE,
UnitOfVolumeFlowRate.LITERS_PER_MINUTE,

View File

@ -2422,6 +2422,7 @@ def test_list_statistic_ids_unsupported(
(None, "kW", "Wh", "power", 13.050847, -10, 30),
# Can't downgrade from ft³ to ft3 or from m³ to m3
(None, "ft³", "ft3", "volume", 13.050847, -10, 30),
(None, "ft³/min", "ft³/m", "volume_flow_rate", 13.050847, -10, 30),
(None, "", "m3", "volume", 13.050847, -10, 30),
],
)
@ -2887,6 +2888,17 @@ def test_compile_hourly_statistics_convert_units_1(
(None, "RPM", "rpm", None, None, 13.050847, 13.333333, -10, 30),
(None, "rpm", "RPM", None, None, 13.050847, 13.333333, -10, 30),
(None, "ft3", "ft³", None, "volume", 13.050847, 13.333333, -10, 30),
(
None,
"ft³/m",
"ft³/min",
None,
"volume_flow_rate",
13.050847,
13.333333,
-10,
30,
),
(None, "m3", "", None, "volume", 13.050847, 13.333333, -10, 30),
],
)
@ -3010,6 +3022,7 @@ def test_compile_hourly_statistics_equivalent_units_1(
(None, "RPM", "rpm", None, 13.333333, -10, 30),
(None, "rpm", "RPM", None, 13.333333, -10, 30),
(None, "ft3", "ft³", None, 13.333333, -10, 30),
(None, "ft³/m", "ft³/min", None, 13.333333, -10, 30),
(None, "m3", "", None, 13.333333, -10, 30),
],
)