From 77baea8cb799ccbdecf632e71a87c51d20342e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Mon, 6 Nov 2023 01:32:03 +0100 Subject: [PATCH] Allow setting HVAC mode through set_temperature service in Airzone integration (#103185) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * airzone: climate: set_temperature: support ATTR_HVAC_MODE Signed-off-by: Álvaro Fernández Rojas * tests: airzone: set_temp: check HVAC mode Signed-off-by: Álvaro Fernández Rojas --------- Signed-off-by: Álvaro Fernández Rojas --- homeassistant/components/airzone/climate.py | 4 ++++ tests/components/airzone/test_climate.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/homeassistant/components/airzone/climate.py b/homeassistant/components/airzone/climate.py index adbc6e1ff6e..22172255b9b 100644 --- a/homeassistant/components/airzone/climate.py +++ b/homeassistant/components/airzone/climate.py @@ -31,6 +31,7 @@ from aioairzone.const import ( ) from homeassistant.components.climate import ( + ATTR_HVAC_MODE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, FAN_AUTO, @@ -222,6 +223,9 @@ class AirzoneClimate(AirzoneZoneEntity, ClimateEntity): params[API_HEAT_SET_POINT] = kwargs[ATTR_TARGET_TEMP_LOW] await self._async_update_hvac_params(params) + if ATTR_HVAC_MODE in kwargs: + await self.async_set_hvac_mode(kwargs[ATTR_HVAC_MODE]) + @callback def _handle_coordinator_update(self) -> None: """Update attributes when the coordinator updates.""" diff --git a/tests/components/airzone/test_climate.py b/tests/components/airzone/test_climate.py index 94bea0a5e07..34844e34370 100644 --- a/tests/components/airzone/test_climate.py +++ b/tests/components/airzone/test_climate.py @@ -536,6 +536,7 @@ async def test_airzone_climate_set_temp(hass: HomeAssistant) -> None: API_SYSTEM_ID: 1, API_ZONE_ID: 5, API_SET_POINT: 20.5, + API_ON: 1, } ] } @@ -551,12 +552,14 @@ async def test_airzone_climate_set_temp(hass: HomeAssistant) -> None: SERVICE_SET_TEMPERATURE, { ATTR_ENTITY_ID: "climate.dorm_2", + ATTR_HVAC_MODE: HVACMode.HEAT, ATTR_TEMPERATURE: 20.5, }, blocking=True, ) state = hass.states.get("climate.dorm_2") + assert state.state == HVACMode.HEAT assert state.attributes.get(ATTR_TEMPERATURE) == 20.5