Use correct value for current temperature for AVM Fritz!Smarthome thermostat devices (#60510)
parent
83acfda757
commit
8626de24fc
|
@ -88,6 +88,8 @@ class FritzboxThermostat(FritzBoxEntity, ClimateEntity):
|
|||
@property
|
||||
def current_temperature(self) -> float:
|
||||
"""Return the current temperature."""
|
||||
if self.device.has_temperature_sensor and self.device.temperature is not None:
|
||||
return self.device.temperature # type: ignore [no-any-return]
|
||||
return self.device.actual_temperature # type: ignore [no-any-return]
|
||||
|
||||
@property
|
||||
|
|
|
@ -68,6 +68,7 @@ class FritzDeviceClimateMock(FritzDeviceBaseMock):
|
|||
"""Mock of a AVM Fritz!Box climate device."""
|
||||
|
||||
actual_temperature = 18.0
|
||||
temperature = 18.0
|
||||
alert_state = "fake_state"
|
||||
battery_level = 23
|
||||
battery_low = True
|
||||
|
@ -79,7 +80,7 @@ class FritzDeviceClimateMock(FritzDeviceBaseMock):
|
|||
has_powermeter = False
|
||||
has_lightbulb = False
|
||||
has_switch = False
|
||||
has_temperature_sensor = False
|
||||
has_temperature_sensor = True
|
||||
has_thermostat = True
|
||||
holiday_active = "fake_holiday"
|
||||
lock = "fake_locked"
|
||||
|
|
|
@ -186,7 +186,7 @@ async def test_update(hass: HomeAssistant, fritz: Mock):
|
|||
assert state.attributes[ATTR_MIN_TEMP] == 8
|
||||
assert state.attributes[ATTR_TEMPERATURE] == 19.5
|
||||
|
||||
device.actual_temperature = 19
|
||||
device.temperature = 19
|
||||
device.target_temperature = 20
|
||||
|
||||
next_update = dt_util.utcnow() + timedelta(seconds=200)
|
||||
|
@ -200,6 +200,24 @@ async def test_update(hass: HomeAssistant, fritz: Mock):
|
|||
assert state.attributes[ATTR_TEMPERATURE] == 20
|
||||
|
||||
|
||||
async def test_automatic_offset(hass: HomeAssistant, fritz: Mock):
|
||||
"""Test when automtaic offset is configured on fritz!box device."""
|
||||
device = FritzDeviceClimateMock()
|
||||
device.temperature = 18
|
||||
device.actual_temperature = 19
|
||||
device.target_temperature = 20
|
||||
assert await setup_config_entry(
|
||||
hass, MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], ENTITY_ID, device, fritz
|
||||
)
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state
|
||||
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 18
|
||||
assert state.attributes[ATTR_MAX_TEMP] == 28
|
||||
assert state.attributes[ATTR_MIN_TEMP] == 8
|
||||
assert state.attributes[ATTR_TEMPERATURE] == 20
|
||||
|
||||
|
||||
async def test_update_error(hass: HomeAssistant, fritz: Mock):
|
||||
"""Test update with error."""
|
||||
device = FritzDeviceClimateMock()
|
||||
|
|
Loading…
Reference in New Issue