mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 13:45:12 +02:00
Add matching class for number
This commit is contained in:
@@ -34,6 +34,7 @@ from homeassistant.const import (
|
||||
UnitOfTemperature,
|
||||
UnitOfTime,
|
||||
UnitOfVolume,
|
||||
UnitOfVolumeFlowRate,
|
||||
UnitOfVolumetricFlux,
|
||||
)
|
||||
from homeassistant.helpers.deprecation import (
|
||||
@@ -42,7 +43,11 @@ from homeassistant.helpers.deprecation import (
|
||||
check_if_deprecated_constant,
|
||||
dir_with_deprecated_constants,
|
||||
)
|
||||
from homeassistant.util.unit_conversion import BaseUnitConverter, TemperatureConverter
|
||||
from homeassistant.util.unit_conversion import (
|
||||
BaseUnitConverter,
|
||||
TemperatureConverter,
|
||||
VolumeFlowRateConverter,
|
||||
)
|
||||
|
||||
ATTR_VALUE = "value"
|
||||
ATTR_MIN = "min"
|
||||
@@ -372,6 +377,14 @@ class NumberDeviceClass(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.
|
||||
|
||||
@@ -464,6 +477,7 @@ DEVICE_CLASS_UNITS: dict[NumberDeviceClass, set[type[StrEnum] | str | None]] = {
|
||||
NumberDeviceClass.VOLTAGE: set(UnitOfElectricPotential),
|
||||
NumberDeviceClass.VOLUME: set(UnitOfVolume),
|
||||
NumberDeviceClass.VOLUME_STORAGE: set(UnitOfVolume),
|
||||
NumberDeviceClass.VOLUME_FLOW_RATE: set(UnitOfVolumeFlowRate),
|
||||
NumberDeviceClass.WATER: {
|
||||
UnitOfVolume.CENTUM_CUBIC_FEET,
|
||||
UnitOfVolume.CUBIC_FEET,
|
||||
@@ -477,6 +491,7 @@ DEVICE_CLASS_UNITS: dict[NumberDeviceClass, set[type[StrEnum] | str | None]] = {
|
||||
|
||||
UNIT_CONVERTERS: dict[str, type[BaseUnitConverter]] = {
|
||||
NumberDeviceClass.TEMPERATURE: TemperatureConverter,
|
||||
NumberDeviceClass.VOLUME_FLOW_RATE: VolumeFlowRateConverter,
|
||||
}
|
||||
|
||||
# These can be removed if no deprecated constant are in this module anymore
|
||||
|
@@ -148,6 +148,9 @@
|
||||
"volume_storage": {
|
||||
"name": "[%key:component::sensor::entity_component::volume_storage::name%]"
|
||||
},
|
||||
"volume_flow_rate": {
|
||||
"name": "[%key:component::sensor::entity_component::volume_flow_rate::name%]"
|
||||
},
|
||||
"water": {
|
||||
"name": "[%key:component::sensor::entity_component::water::name%]"
|
||||
},
|
||||
|
Reference in New Issue
Block a user