Fix unknown data in homematicip_cloud (#85618)

This commit is contained in:
epenet 2023-01-10 18:26:49 +01:00 committed by GitHub
parent 7621c450c7
commit a7647fee28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -177,10 +177,10 @@ class HomematicipHeatingThermostat(HomematicipGenericEntity, SensorEntity):
return "mdi:radiator"
@property
def native_value(self) -> int:
def native_value(self) -> int | None:
"""Return the state of the radiator valve."""
if self._device.valveState != ValveState.ADAPTION_DONE:
return self._device.valveState
return None
return round(self._device.valvePosition * 100)

View File

@ -29,6 +29,7 @@ from homeassistant.const import (
PERCENTAGE,
POWER_WATT,
SPEED_KILOMETERS_PER_HOUR,
STATE_UNKNOWN,
TEMP_CELSIUS,
)
from homeassistant.setup import async_setup_component
@ -82,7 +83,7 @@ async def test_hmip_heating_thermostat(hass, default_mock_hap_factory):
await async_manipulate_test_data(hass, hmip_device, "valveState", "nn")
ha_state = hass.states.get(entity_id)
assert ha_state.state == "nn"
assert ha_state.state == STATE_UNKNOWN
await async_manipulate_test_data(
hass, hmip_device, "valveState", ValveState.ADAPTION_DONE