Add Fritz!DECT 440 humidity sensor (#54597)
Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>
This commit is contained in:
parent
4ae887ad34
commit
26042bdad7
4 changed files with 21 additions and 0 deletions
|
@ -17,6 +17,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
|
@ -58,6 +59,15 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
|
|||
),
|
||||
native_value=lambda device: device.temperature, # type: ignore[no-any-return]
|
||||
),
|
||||
FritzSensorEntityDescription(
|
||||
key="humidity",
|
||||
name="Humidity",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
device_class=DEVICE_CLASS_HUMIDITY,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
suitable=lambda device: device.rel_humidity is not None,
|
||||
native_value=lambda device: device.rel_humidity, # type: ignore[no-any-return]
|
||||
),
|
||||
FritzSensorEntityDescription(
|
||||
key="battery",
|
||||
name="Battery",
|
||||
|
|
|
@ -100,6 +100,7 @@ class FritzDeviceSensorMock(FritzDeviceBaseMock):
|
|||
lock = "fake_locked"
|
||||
present = True
|
||||
temperature = 1.23
|
||||
rel_humidity = 42
|
||||
|
||||
|
||||
class FritzDeviceSwitchMock(FritzDeviceBaseMock):
|
||||
|
|
|
@ -49,6 +49,13 @@ async def test_setup(hass: HomeAssistant, fritz: Mock):
|
|||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS
|
||||
assert state.attributes[ATTR_STATE_CLASS] == STATE_CLASS_MEASUREMENT
|
||||
|
||||
state = hass.states.get(f"{ENTITY_ID}_humidity")
|
||||
assert state
|
||||
assert state.state == "42"
|
||||
assert state.attributes[ATTR_FRIENDLY_NAME] == f"{CONF_FAKE_NAME} Humidity"
|
||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == PERCENTAGE
|
||||
assert state.attributes[ATTR_STATE_CLASS] == STATE_CLASS_MEASUREMENT
|
||||
|
||||
state = hass.states.get(f"{ENTITY_ID}_battery")
|
||||
assert state
|
||||
assert state.state == "23"
|
||||
|
|
|
@ -64,6 +64,9 @@ async def test_setup(hass: HomeAssistant, fritz: Mock):
|
|||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS
|
||||
assert state.attributes[ATTR_STATE_CLASS] == STATE_CLASS_MEASUREMENT
|
||||
|
||||
state = hass.states.get(f"{ENTITY_ID}_humidity")
|
||||
assert state is None
|
||||
|
||||
state = hass.states.get(f"{SENSOR_DOMAIN}.{CONF_FAKE_NAME}_power_consumption")
|
||||
assert state
|
||||
assert state.state == "5.678"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue