Add new units L/h , L/s and m³/s to volume flow rate sensor device class (#143625)

add new units L/h , L/s and m³/s
This commit is contained in:
Michael 2025-04-25 00:17:47 +02:00 committed by GitHub
parent d83c617566
commit 3405b2549b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 0 deletions

View File

@ -766,8 +766,11 @@ class UnitOfVolumeFlowRate(StrEnum):
"""Volume flow rate units."""
CUBIC_METERS_PER_HOUR = "m³/h"
CUBIC_METERS_PER_SECOND = "m³/s"
CUBIC_FEET_PER_MINUTE = "ft³/min"
LITERS_PER_HOUR = "L/h"
LITERS_PER_MINUTE = "L/min"
LITERS_PER_SECOND = "L/s"
GALLONS_PER_MINUTE = "gal/min"
MILLILITERS_PER_SECOND = "mL/s"

View File

@ -705,10 +705,13 @@ class VolumeFlowRateConverter(BaseUnitConverter):
# Units in terms of m³/h
_UNIT_CONVERSION: dict[str | None, float] = {
UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR: 1,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_SECOND: 1 / _HRS_TO_SECS,
UnitOfVolumeFlowRate.CUBIC_FEET_PER_MINUTE: 1
/ (_HRS_TO_MINUTES * _CUBIC_FOOT_TO_CUBIC_METER),
UnitOfVolumeFlowRate.LITERS_PER_HOUR: 1 / _L_TO_CUBIC_METER,
UnitOfVolumeFlowRate.LITERS_PER_MINUTE: 1
/ (_HRS_TO_MINUTES * _L_TO_CUBIC_METER),
UnitOfVolumeFlowRate.LITERS_PER_SECOND: 1 / (_HRS_TO_SECS * _L_TO_CUBIC_METER),
UnitOfVolumeFlowRate.GALLONS_PER_MINUTE: 1
/ (_HRS_TO_MINUTES * _GALLON_TO_CUBIC_METER),
UnitOfVolumeFlowRate.MILLILITERS_PER_SECOND: 1
@ -717,7 +720,10 @@ class VolumeFlowRateConverter(BaseUnitConverter):
VALID_UNITS = {
UnitOfVolumeFlowRate.CUBIC_FEET_PER_MINUTE,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_SECOND,
UnitOfVolumeFlowRate.LITERS_PER_HOUR,
UnitOfVolumeFlowRate.LITERS_PER_MINUTE,
UnitOfVolumeFlowRate.LITERS_PER_SECOND,
UnitOfVolumeFlowRate.GALLONS_PER_MINUTE,
UnitOfVolumeFlowRate.MILLILITERS_PER_SECOND,
}

View File

@ -806,12 +806,30 @@ _CONVERTED_VALUE: dict[
2500,
UnitOfVolumeFlowRate.MILLILITERS_PER_SECOND,
),
(
1,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_SECOND,
3600,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
),
(
1,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_SECOND,
3600000,
UnitOfVolumeFlowRate.LITERS_PER_HOUR,
),
(
3,
UnitOfVolumeFlowRate.LITERS_PER_MINUTE,
50,
UnitOfVolumeFlowRate.MILLILITERS_PER_SECOND,
),
(
3.6,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
1,
UnitOfVolumeFlowRate.LITERS_PER_SECOND,
),
],
}