diff --git a/homeassistant/components/homekit_controller/sensor.py b/homeassistant/components/homekit_controller/sensor.py index 6bf8a7fc084..91b62b0d572 100644 --- a/homeassistant/components/homekit_controller/sensor.py +++ b/homeassistant/components/homekit_controller/sensor.py @@ -12,6 +12,7 @@ from homeassistant.const import ( DEVICE_CLASS_TEMPERATURE, LIGHT_LUX, PERCENTAGE, + POWER_WATT, TEMP_CELSIUS, ) from homeassistant.core import callback @@ -29,19 +30,19 @@ SIMPLE_SENSOR = { "name": "Real Time Energy", "device_class": DEVICE_CLASS_POWER, "state_class": STATE_CLASS_MEASUREMENT, - "unit": "watts", + "unit": POWER_WATT, }, CharacteristicsTypes.Vendor.KOOGEEK_REALTIME_ENERGY: { "name": "Real Time Energy", "device_class": DEVICE_CLASS_POWER, "state_class": STATE_CLASS_MEASUREMENT, - "unit": "watts", + "unit": POWER_WATT, }, CharacteristicsTypes.Vendor.KOOGEEK_REALTIME_ENERGY_2: { "name": "Real Time Energy", "device_class": DEVICE_CLASS_POWER, "state_class": STATE_CLASS_MEASUREMENT, - "unit": "watts", + "unit": POWER_WATT, }, CharacteristicsTypes.get_uuid(CharacteristicsTypes.TEMPERATURE_CURRENT): { "name": "Current Temperature", diff --git a/tests/components/homekit_controller/specific_devices/test_koogeek_p1eu.py b/tests/components/homekit_controller/specific_devices/test_koogeek_p1eu.py index 6302013223d..1761edb3c8c 100644 --- a/tests/components/homekit_controller/specific_devices/test_koogeek_p1eu.py +++ b/tests/components/homekit_controller/specific_devices/test_koogeek_p1eu.py @@ -1,5 +1,6 @@ """Make sure that existing Koogeek P1EU support isn't broken.""" +from homeassistant.const import POWER_WATT from homeassistant.helpers import device_registry as dr, entity_registry as er from tests.components.homekit_controller.common import ( @@ -48,6 +49,7 @@ async def test_koogeek_p1eu_setup(hass): ) state = await helper.poll_and_get_state() assert state.attributes["friendly_name"] == "Koogeek-P1-A00AA0 - Real Time Energy" + assert state.attributes["unit_of_measurement"] == POWER_WATT # The sensor and switch should be part of the same device assert entry.device_id == device.id diff --git a/tests/components/homekit_controller/specific_devices/test_koogeek_sw2.py b/tests/components/homekit_controller/specific_devices/test_koogeek_sw2.py index 1d46b633153..768959e0331 100644 --- a/tests/components/homekit_controller/specific_devices/test_koogeek_sw2.py +++ b/tests/components/homekit_controller/specific_devices/test_koogeek_sw2.py @@ -6,6 +6,7 @@ This Koogeek device has a custom power sensor that extra handling. It should have 2 entities - the actual switch and a sensor for power usage. """ +from homeassistant.const import POWER_WATT from homeassistant.helpers import device_registry as dr, entity_registry as er from tests.components.homekit_controller.common import ( @@ -58,6 +59,7 @@ async def test_koogeek_ls1_setup(hass): # Assert that the friendly name is detected correctly assert state.attributes["friendly_name"] == "Koogeek-SW2-187A91 - Real Time Energy" + assert state.attributes["unit_of_measurement"] == POWER_WATT device_registry = dr.async_get(hass)