From badd06ede0dff2ae995acb8b095edfc3dd6b7956 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Sun, 4 Jun 2023 10:39:28 +0200 Subject: [PATCH] Adjust liter unit and add gallons per minute --- homeassistant/const.py | 3 ++- homeassistant/util/unit_conversion.py | 3 +++ tests/util/test_unit_conversion.py | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 71fad5c82f8..e71457f3c1e 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1041,7 +1041,8 @@ class UnitOfVolumeFlowRate(StrEnum): CUBIC_METERS_PER_HOUR = "m³/h" CUBIC_FEET_PER_MINUTE = "ft³/m" - LITERS_PER_MINUTE = "l/m" + LITERS_PER_MINUTE = "L/min" + GALLONS_PER_MINUTE = "gal/min" _DEPRECATED_VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR: Final = DeprecatedConstantEnum( diff --git a/homeassistant/util/unit_conversion.py b/homeassistant/util/unit_conversion.py index 8fb87d04822..15912fa2f6e 100644 --- a/homeassistant/util/unit_conversion.py +++ b/homeassistant/util/unit_conversion.py @@ -532,9 +532,12 @@ class VolumeFlowRateConverter(BaseUnitConverter): / (_HRS_TO_MINUTES * _CUBIC_FOOT_TO_CUBIC_METER), UnitOfVolumeFlowRate.LITERS_PER_MINUTE: 1 / (_HRS_TO_MINUTES * _L_TO_CUBIC_METER), + UnitOfVolumeFlowRate.GALLONS_PER_MINUTE: 1 + / (_HRS_TO_MINUTES * _GALLON_TO_CUBIC_METER), } VALID_UNITS = { UnitOfVolumeFlowRate.CUBIC_FEET_PER_MINUTE, UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR, UnitOfVolumeFlowRate.LITERS_PER_MINUTE, + UnitOfVolumeFlowRate.GALLONS_PER_MINUTE, } diff --git a/tests/util/test_unit_conversion.py b/tests/util/test_unit_conversion.py index 8b662c398d9..08d362072d4 100644 --- a/tests/util/test_unit_conversion.py +++ b/tests/util/test_unit_conversion.py @@ -434,6 +434,12 @@ _CONVERTED_VALUE: dict[ 0.58857777, UnitOfVolumeFlowRate.CUBIC_FEET_PER_MINUTE, ), + ( + 1, + UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR, + 4.40286754, + UnitOfVolumeFlowRate.GALLONS_PER_MINUTE, + ), ( 1, UnitOfVolumeFlowRate.LITERS_PER_MINUTE, @@ -446,6 +452,12 @@ _CONVERTED_VALUE: dict[ 0.03531466, UnitOfVolumeFlowRate.CUBIC_FEET_PER_MINUTE, ), + ( + 1, + UnitOfVolumeFlowRate.LITERS_PER_MINUTE, + 0.264172052, + UnitOfVolumeFlowRate.GALLONS_PER_MINUTE, + ), ( 1, UnitOfVolumeFlowRate.CUBIC_FEET_PER_MINUTE, @@ -458,6 +470,12 @@ _CONVERTED_VALUE: dict[ 28.3168465, UnitOfVolumeFlowRate.LITERS_PER_MINUTE, ), + ( + 1, + UnitOfVolumeFlowRate.CUBIC_FEET_PER_MINUTE, + 7.48051948, + UnitOfVolumeFlowRate.GALLONS_PER_MINUTE, + ), ], }