Add number + sensor device class volume storage (#88312)

* Add number + sensor device class volume storage

* Fix typo

* Format code

* Update device automations
This commit is contained in:
Erik Montnemery 2023-03-01 11:22:57 +01:00 committed by GitHub
parent 29b049fc57
commit fca5cc6ea3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 0 deletions

View file

@ -362,6 +362,18 @@ class SensorDeviceClass(StrEnum):
USCS/imperial units are currently assumed to be US volumes)
"""
VOLUME_STORAGE = "volume_storage"
"""Generic stored volume.
Use this device class for sensors measuring stored volume, for example the amount
of fuel in a fuel tank.
Unit of measurement: `VOLUME_*` units
- SI / metric: `mL`, `L`, ``
- USCS / imperial: `ft³`, `CCF`, `fl. oz.`, `gal` (warning: volumes expressed in
USCS/imperial units are currently assumed to be US volumes)
"""
WATER = "water"
"""Water.
@ -451,6 +463,7 @@ UNIT_CONVERTERS: dict[SensorDeviceClass | str | None, type[BaseUnitConverter]] =
SensorDeviceClass.TEMPERATURE: TemperatureConverter,
SensorDeviceClass.VOLTAGE: ElectricPotentialConverter,
SensorDeviceClass.VOLUME: VolumeConverter,
SensorDeviceClass.VOLUME_STORAGE: VolumeConverter,
SensorDeviceClass.WATER: VolumeConverter,
SensorDeviceClass.WEIGHT: MassConverter,
SensorDeviceClass.WIND_SPEED: SpeedConverter,
@ -573,6 +586,7 @@ DEVICE_CLASS_STATE_CLASSES: dict[SensorDeviceClass, set[SensorStateClass]] = {
SensorStateClass.TOTAL,
SensorStateClass.TOTAL_INCREASING,
},
SensorDeviceClass.VOLUME_STORAGE: {SensorStateClass.MEASUREMENT},
SensorDeviceClass.WATER: {
SensorStateClass.TOTAL,
SensorStateClass.TOTAL_INCREASING,