From 67bce169ee7a17920b41bd2209437a37adcbd1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Mart=C3=ADnez?= <103188721+hectorzin@users.noreply.github.com> Date: Mon, 23 Dec 2024 19:16:51 +0100 Subject: [PATCH] bug: unit of measurament This is the warning showed in the registry log: () is using native unit of measurement 'kWh' which is not a valid unit for the device class ('power') it is using; expected one of ['W', 'kW', 'TW', 'GW', 'MW']; --- custom_components/hon/sensor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/hon/sensor.py b/custom_components/hon/sensor.py index 4039282..35f7733 100644 --- a/custom_components/hon/sensor.py +++ b/custom_components/hon/sensor.py @@ -18,6 +18,7 @@ from homeassistant.const import ( UnitOfEnergy, UnitOfVolume, UnitOfMass, + UnitOfPower, UnitOfTime, UnitOfTemperature, ) @@ -83,7 +84,7 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { name="Current Electricity Used", state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.POWER, - native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + native_unit_of_measurement=UnitOfPower.WATT, icon="mdi:lightning-bolt", translation_key="energy_current", ),