Allow turning Airzone slave zones on with any HVAC mode (#94721)

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 <noltari@gmail.com>
This commit is contained in:
Álvaro Fernández Rojas 2023-06-27 21:25:41 +02:00 committed by GitHub
parent ed2daf1f65
commit 78380c0cd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -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 = {}

View File

@ -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: