Skip to content

Commit 3e20c50

Browse files
autinerdCFenner
andauthored
Add gallons per hour as volume flow rate unit (home-assistant#154246)
Co-authored-by: Christopher Fenner <[email protected]>
1 parent 2abc197 commit 3e20c50

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

homeassistant/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ class UnitOfVolumeFlowRate(StrEnum):
665665
LITERS_PER_HOUR = "L/h"
666666
LITERS_PER_MINUTE = "L/min"
667667
LITERS_PER_SECOND = "L/s"
668+
GALLONS_PER_HOUR = "gal/h"
668669
GALLONS_PER_MINUTE = "gal/min"
669670
MILLILITERS_PER_SECOND = "mL/s"
670671

homeassistant/util/unit_conversion.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ class VolumeFlowRateConverter(BaseUnitConverter):
826826
UnitOfVolumeFlowRate.LITERS_PER_MINUTE: 1
827827
/ (_HRS_TO_MINUTES * _L_TO_CUBIC_METER),
828828
UnitOfVolumeFlowRate.LITERS_PER_SECOND: 1 / (_HRS_TO_SECS * _L_TO_CUBIC_METER),
829+
UnitOfVolumeFlowRate.GALLONS_PER_HOUR: 1 / _GALLON_TO_CUBIC_METER,
829830
UnitOfVolumeFlowRate.GALLONS_PER_MINUTE: 1
830831
/ (_HRS_TO_MINUTES * _GALLON_TO_CUBIC_METER),
831832
UnitOfVolumeFlowRate.MILLILITERS_PER_SECOND: 1
@@ -839,6 +840,7 @@ class VolumeFlowRateConverter(BaseUnitConverter):
839840
UnitOfVolumeFlowRate.LITERS_PER_HOUR,
840841
UnitOfVolumeFlowRate.LITERS_PER_MINUTE,
841842
UnitOfVolumeFlowRate.LITERS_PER_SECOND,
843+
UnitOfVolumeFlowRate.GALLONS_PER_HOUR,
842844
UnitOfVolumeFlowRate.GALLONS_PER_MINUTE,
843845
UnitOfVolumeFlowRate.MILLILITERS_PER_SECOND,
844846
}

tests/util/test_unit_conversion.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,12 @@
977977
7.48051948,
978978
UnitOfVolumeFlowRate.GALLONS_PER_MINUTE,
979979
),
980+
(
981+
1,
982+
UnitOfVolumeFlowRate.LITERS_PER_HOUR,
983+
0.264172052,
984+
UnitOfVolumeFlowRate.GALLONS_PER_HOUR,
985+
),
980986
(
981987
9,
982988
UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,

0 commit comments

Comments
 (0)