Don't overwrite target temperature by setting hvac mode in AVM Fritz!SmartHome (#112119)
parent
ef7836be73
commit
850dac0655
|
@ -29,6 +29,7 @@ from .const import (
|
||||||
ATTR_STATE_HOLIDAY_MODE,
|
ATTR_STATE_HOLIDAY_MODE,
|
||||||
ATTR_STATE_SUMMER_MODE,
|
ATTR_STATE_SUMMER_MODE,
|
||||||
ATTR_STATE_WINDOW_OPEN,
|
ATTR_STATE_WINDOW_OPEN,
|
||||||
|
LOGGER,
|
||||||
)
|
)
|
||||||
from .model import ClimateExtraAttributes
|
from .model import ClimateExtraAttributes
|
||||||
|
|
||||||
|
@ -129,6 +130,11 @@ class FritzboxThermostat(FritzBoxDeviceEntity, ClimateEntity):
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
"""Set new operation mode."""
|
"""Set new operation mode."""
|
||||||
|
if self.hvac_mode == hvac_mode:
|
||||||
|
LOGGER.debug(
|
||||||
|
"%s is already in requested hvac mode %s", self.name, hvac_mode
|
||||||
|
)
|
||||||
|
return
|
||||||
if hvac_mode == HVACMode.OFF:
|
if hvac_mode == HVACMode.OFF:
|
||||||
await self.async_set_temperature(temperature=OFF_REPORT_SET_TEMPERATURE)
|
await self.async_set_temperature(temperature=OFF_REPORT_SET_TEMPERATURE)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -288,6 +288,7 @@ async def test_set_temperature_mode_off(hass: HomeAssistant, fritz: Mock) -> Non
|
||||||
async def test_set_temperature_mode_heat(hass: HomeAssistant, fritz: Mock) -> None:
|
async def test_set_temperature_mode_heat(hass: HomeAssistant, fritz: Mock) -> None:
|
||||||
"""Test setting temperature by mode."""
|
"""Test setting temperature by mode."""
|
||||||
device = FritzDeviceClimateMock()
|
device = FritzDeviceClimateMock()
|
||||||
|
device.target_temperature = 0.0
|
||||||
assert await setup_config_entry(
|
assert await setup_config_entry(
|
||||||
hass, MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], ENTITY_ID, device, fritz
|
hass, MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], ENTITY_ID, device, fritz
|
||||||
)
|
)
|
||||||
|
@ -321,9 +322,26 @@ async def test_set_hvac_mode_off(hass: HomeAssistant, fritz: Mock) -> None:
|
||||||
assert device.set_target_temperature.call_args_list == [call(0)]
|
assert device.set_target_temperature.call_args_list == [call(0)]
|
||||||
|
|
||||||
|
|
||||||
|
async def test_no_reset_hvac_mode_heat(hass: HomeAssistant, fritz: Mock) -> None:
|
||||||
|
"""Test setting hvac mode."""
|
||||||
|
device = FritzDeviceClimateMock()
|
||||||
|
assert await setup_config_entry(
|
||||||
|
hass, MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], ENTITY_ID, device, fritz
|
||||||
|
)
|
||||||
|
|
||||||
|
await hass.services.async_call(
|
||||||
|
DOMAIN,
|
||||||
|
SERVICE_SET_HVAC_MODE,
|
||||||
|
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: HVACMode.HEAT},
|
||||||
|
True,
|
||||||
|
)
|
||||||
|
assert device.set_target_temperature.call_count == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_set_hvac_mode_heat(hass: HomeAssistant, fritz: Mock) -> None:
|
async def test_set_hvac_mode_heat(hass: HomeAssistant, fritz: Mock) -> None:
|
||||||
"""Test setting hvac mode."""
|
"""Test setting hvac mode."""
|
||||||
device = FritzDeviceClimateMock()
|
device = FritzDeviceClimateMock()
|
||||||
|
device.target_temperature = 0.0
|
||||||
assert await setup_config_entry(
|
assert await setup_config_entry(
|
||||||
hass, MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], ENTITY_ID, device, fritz
|
hass, MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], ENTITY_ID, device, fritz
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue