Fix Abode unit of measurement (#94168)
Change unit of measurement to HA const
This commit is contained in:
parent
f24b514c9a
commit
74c0552a12
2 changed files with 3 additions and 2 deletions
|
@ -12,6 +12,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.const import LIGHT_LUX
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ class AbodeSensor(AbodeDevice, SensorEntity):
|
||||||
elif description.key == CONST.HUMI_STATUS_KEY:
|
elif description.key == CONST.HUMI_STATUS_KEY:
|
||||||
self._attr_native_unit_of_measurement = device.humidity_unit
|
self._attr_native_unit_of_measurement = device.humidity_unit
|
||||||
elif description.key == CONST.LUX_STATUS_KEY:
|
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
|
@property
|
||||||
def native_value(self) -> float | None:
|
def native_value(self) -> float | None:
|
||||||
|
|
|
@ -39,7 +39,7 @@ async def test_attributes(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
state = hass.states.get("sensor.environment_sensor_lux")
|
state = hass.states.get("sensor.environment_sensor_lux")
|
||||||
assert state.state == "1.0"
|
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")
|
state = hass.states.get("sensor.environment_sensor_temperature")
|
||||||
# Abodepy device JSON reports 19.5, but Home Assistant shows 19.4
|
# Abodepy device JSON reports 19.5, but Home Assistant shows 19.4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue