From 78380c0cd482287fd870a10cd3679d2a7bb6aca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 27 Jun 2023 21:25:41 +0200 Subject: [PATCH] Allow turning Airzone slave zones on with any HVAC mode (#94721) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit airzone: climate: allow turning slave zone on with any hvac mode If the user selects a different mode on a slave zone from the one selected on the master zone, it will raise an exception and it won't change the operation mode or turn it on. Change this behaviour so that the exception will still be raised but the slave zone will be turned on and the hvac mode won't be changed. This allows commanding airzone slave zones from limited APIs like homekit. Signed-off-by: Álvaro Fernández Rojas --- homeassistant/components/airzone/climate.py | 9 ++++++--- tests/components/airzone/test_climate.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/airzone/climate.py b/homeassistant/components/airzone/climate.py index 3c47c333b92..74a564fa2de 100644 --- a/homeassistant/components/airzone/climate.py +++ b/homeassistant/components/airzone/climate.py @@ -193,6 +193,8 @@ class AirzoneClimate(AirzoneZoneEntity, ClimateEntity): async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set hvac mode.""" + slave_raise = False + params = {} if hvac_mode == HVACMode.OFF: params[API_ON] = 0 @@ -202,12 +204,13 @@ class AirzoneClimate(AirzoneZoneEntity, ClimateEntity): if self.get_airzone_value(AZD_MASTER): params[API_MODE] = mode else: - raise HomeAssistantError( - f"Mode can't be changed on slave zone {self.name}" - ) + slave_raise = True params[API_ON] = 1 await self._async_update_hvac_params(params) + if slave_raise: + raise HomeAssistantError(f"Mode can't be changed on slave zone {self.name}") + async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" params = {} diff --git a/tests/components/airzone/test_climate.py b/tests/components/airzone/test_climate.py index 2c66adcb974..f7cc7806bcb 100644 --- a/tests/components/airzone/test_climate.py +++ b/tests/components/airzone/test_climate.py @@ -438,7 +438,7 @@ async def test_airzone_climate_set_hvac_slave_error(hass: HomeAssistant) -> None ) state = hass.states.get("climate.dorm_2") - assert state.state == HVACMode.OFF + assert state.state == HVACMode.HEAT async def test_airzone_climate_set_fan_mode(hass: HomeAssistant) -> None: