From 7d8e4123142798950fda06c08ebdba5063d7e620 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 7 Jun 2023 19:53:45 +0200 Subject: [PATCH] Fix Abode unit of measurement (#94168) Change unit of measurement to HA const --- homeassistant/components/abode/sensor.py | 3 ++- tests/components/abode/test_sensor.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/abode/sensor.py b/homeassistant/components/abode/sensor.py index 87a9f8e9a27..546d57ab3e7 100644 --- a/homeassistant/components/abode/sensor.py +++ b/homeassistant/components/abode/sensor.py @@ -12,6 +12,7 @@ from homeassistant.components.sensor import ( SensorEntityDescription, ) from homeassistant.config_entries import ConfigEntry +from homeassistant.const import LIGHT_LUX from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -71,7 +72,7 @@ class AbodeSensor(AbodeDevice, SensorEntity): elif description.key == CONST.HUMI_STATUS_KEY: self._attr_native_unit_of_measurement = device.humidity_unit elif description.key == CONST.LUX_STATUS_KEY: - self._attr_native_unit_of_measurement = device.lux_unit + self._attr_native_unit_of_measurement = LIGHT_LUX @property def native_value(self) -> float | None: diff --git a/tests/components/abode/test_sensor.py b/tests/components/abode/test_sensor.py index 5d074de214f..67892dfafb4 100644 --- a/tests/components/abode/test_sensor.py +++ b/tests/components/abode/test_sensor.py @@ -39,7 +39,7 @@ async def test_attributes(hass: HomeAssistant) -> None: state = hass.states.get("sensor.environment_sensor_lux") assert state.state == "1.0" - assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "lux" + assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "lx" state = hass.states.get("sensor.environment_sensor_temperature") # Abodepy device JSON reports 19.5, but Home Assistant shows 19.4