From 6b1f503a79d134439ba82910b97b5211e4a0a059 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 25 Oct 2022 09:53:28 +0200 Subject: [PATCH] Allow gas units to be overriden (#80884) --- homeassistant/components/sensor/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/__init__.py b/homeassistant/components/sensor/__init__.py index e353f089951..fbe12652f35 100644 --- a/homeassistant/components/sensor/__init__.py +++ b/homeassistant/components/sensor/__init__.py @@ -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,