Flow rate unit conversions and device class (#106077)
* Add volume flow rate conversions
* Add missing translations
* Adjust liter unit and add gallons per minute
* Adjust to min instead of m for minutes
* Add matching class for number
* Add some tests for number and sensor platform
* Add deprecated constants
* Add explicit list of flow rate for check
This reverts commit 105171af31
.
This commit is contained in:
parent
a8e3df7e50
commit
cece117c93
14 changed files with 180 additions and 3 deletions
|
@ -34,6 +34,7 @@ from homeassistant.const import (
|
|||
UnitOfTemperature,
|
||||
UnitOfTime,
|
||||
UnitOfVolume,
|
||||
UnitOfVolumeFlowRate,
|
||||
UnitOfVolumetricFlux,
|
||||
)
|
||||
from homeassistant.helpers.deprecation import (
|
||||
|
@ -57,6 +58,7 @@ from homeassistant.util.unit_conversion import (
|
|||
TemperatureConverter,
|
||||
UnitlessRatioConverter,
|
||||
VolumeConverter,
|
||||
VolumeFlowRateConverter,
|
||||
)
|
||||
|
||||
DOMAIN: Final = "sensor"
|
||||
|
@ -394,6 +396,14 @@ class SensorDeviceClass(StrEnum):
|
|||
USCS/imperial units are currently assumed to be US volumes)
|
||||
"""
|
||||
|
||||
VOLUME_FLOW_RATE = "volume_flow_rate"
|
||||
"""Generic flow rate
|
||||
|
||||
Unit of measurement: UnitOfVolumeFlowRate
|
||||
- SI / metric: `m³/h`, `L/min`
|
||||
- USCS / imperial: `ft³/min`, `gal/min`
|
||||
"""
|
||||
|
||||
WATER = "water"
|
||||
"""Water.
|
||||
|
||||
|
@ -489,6 +499,7 @@ UNIT_CONVERTERS: dict[SensorDeviceClass | str | None, type[BaseUnitConverter]] =
|
|||
SensorDeviceClass.VOLTAGE: ElectricPotentialConverter,
|
||||
SensorDeviceClass.VOLUME: VolumeConverter,
|
||||
SensorDeviceClass.VOLUME_STORAGE: VolumeConverter,
|
||||
SensorDeviceClass.VOLUME_FLOW_RATE: VolumeFlowRateConverter,
|
||||
SensorDeviceClass.WATER: VolumeConverter,
|
||||
SensorDeviceClass.WEIGHT: MassConverter,
|
||||
SensorDeviceClass.WIND_SPEED: SpeedConverter,
|
||||
|
@ -555,6 +566,7 @@ DEVICE_CLASS_UNITS: dict[SensorDeviceClass, set[type[StrEnum] | str | None]] = {
|
|||
},
|
||||
SensorDeviceClass.VOLTAGE: set(UnitOfElectricPotential),
|
||||
SensorDeviceClass.VOLUME: set(UnitOfVolume),
|
||||
SensorDeviceClass.VOLUME_FLOW_RATE: set(UnitOfVolumeFlowRate),
|
||||
SensorDeviceClass.VOLUME_STORAGE: set(UnitOfVolume),
|
||||
SensorDeviceClass.WATER: {
|
||||
UnitOfVolume.CENTUM_CUBIC_FEET,
|
||||
|
@ -621,6 +633,7 @@ DEVICE_CLASS_STATE_CLASSES: dict[SensorDeviceClass, set[SensorStateClass]] = {
|
|||
SensorStateClass.TOTAL_INCREASING,
|
||||
},
|
||||
SensorDeviceClass.VOLUME_STORAGE: {SensorStateClass.MEASUREMENT},
|
||||
SensorDeviceClass.VOLUME_FLOW_RATE: {SensorStateClass.MEASUREMENT},
|
||||
SensorDeviceClass.WATER: {
|
||||
SensorStateClass.TOTAL,
|
||||
SensorStateClass.TOTAL_INCREASING,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue