Allow gas units to be overriden (#80884)

This commit is contained in:
epenet 2022-10-25 09:53:28 +02:00 committed by GitHub
parent 3d3349240f
commit 6b1f503a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -376,9 +376,11 @@ STATE_CLASS_TOTAL: Final = "total"
STATE_CLASS_TOTAL_INCREASING: Final = "total_increasing"
STATE_CLASSES: Final[list[str]] = [cls.value for cls in SensorStateClass]
UNIT_CONVERTERS: dict[str, type[BaseUnitConverter]] = {
# Note: this needs to be aligned with frontend: OVERRIDE_SENSOR_UNITS in
# `entity-registry-settings.ts`
UNIT_CONVERTERS: dict[SensorDeviceClass | str | None, type[BaseUnitConverter]] = {
SensorDeviceClass.DISTANCE: DistanceConverter,
SensorDeviceClass.PRECIPITATION_INTENSITY: SpeedConverter,
SensorDeviceClass.GAS: VolumeConverter,
SensorDeviceClass.PRESSURE: PressureConverter,
SensorDeviceClass.SPEED: SpeedConverter,
SensorDeviceClass.TEMPERATURE: TemperatureConverter,