Add m³/min as volume flow rate unit (#151051)

pull/151033/head^2
Christian Fetzer 2025-08-24 21:30:25 +02:00 committed by GitHub
parent b018465a4d
commit 0dc2a5a02c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 2 deletions

View File

@ -418,7 +418,7 @@ class NumberDeviceClass(StrEnum):
"""Generic flow rate
Unit of measurement: UnitOfVolumeFlowRate
- SI / metric: `/h`, `L/min`, `mL/s`
- SI / metric: `/h`, `/min`, `/s`, `L/h`, `L/min`, `L/s`, `mL/s`
- USCS / imperial: `ft³/min`, `gal/min`
"""

View File

@ -452,7 +452,7 @@ class SensorDeviceClass(StrEnum):
"""Generic flow rate
Unit of measurement: UnitOfVolumeFlowRate
- SI / metric: `/h`, `L/min`, `mL/s`
- SI / metric: `/h`, `/min`, `/s`, `L/h`, `L/min`, `L/s`, `mL/s`
- USCS / imperial: `ft³/min`, `gal/min`
"""

View File

@ -783,6 +783,7 @@ class UnitOfVolumeFlowRate(StrEnum):
"""Volume flow rate units."""
CUBIC_METERS_PER_HOUR = "m³/h"
CUBIC_METERS_PER_MINUTE = "m³/min"
CUBIC_METERS_PER_SECOND = "m³/s"
CUBIC_FEET_PER_MINUTE = "ft³/min"
LITERS_PER_HOUR = "L/h"

View File

@ -769,6 +769,7 @@ 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_MINUTE: 1 / _HRS_TO_MINUTES,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_SECOND: 1 / _HRS_TO_SECS,
UnitOfVolumeFlowRate.CUBIC_FEET_PER_MINUTE: 1
/ (_HRS_TO_MINUTES * _CUBIC_FOOT_TO_CUBIC_METER),
@ -784,6 +785,7 @@ class VolumeFlowRateConverter(BaseUnitConverter):
VALID_UNITS = {
UnitOfVolumeFlowRate.CUBIC_FEET_PER_MINUTE,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_MINUTE,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_SECOND,
UnitOfVolumeFlowRate.LITERS_PER_HOUR,
UnitOfVolumeFlowRate.LITERS_PER_MINUTE,

View File

@ -947,6 +947,12 @@ _CONVERTED_VALUE: dict[
1,
UnitOfVolumeFlowRate.LITERS_PER_SECOND,
),
(
0.6,
UnitOfVolumeFlowRate.CUBIC_METERS_PER_MINUTE,
10,
UnitOfVolumeFlowRate.LITERS_PER_SECOND,
),
],
}