1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

airzone: implement turn on/off (#70095)

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
Álvaro Fernández Rojas
2022-04-15 15:13:59 +02:00
committed by GitHub
parent 8ab9cd1695
commit abea7d3245
2 changed files with 83 additions and 3 deletions

View File

@@ -26,7 +26,6 @@ from aioairzone.const import (
AZD_ZONES,
)
from aioairzone.exceptions import AirzoneError
from aiohttp.client_exceptions import ClientConnectorError
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import (
@@ -128,13 +127,33 @@ class AirzoneClimate(AirzoneEntity, ClimateEntity):
"""Send HVAC parameters to API."""
try:
await self.coordinator.airzone.put_hvac(params)
except (AirzoneError, ClientConnectorError) as error:
except AirzoneError as error:
raise HomeAssistantError(
f"Failed to set zone {self.name}: {error}"
) from error
else:
self.coordinator.async_set_updated_data(self.coordinator.airzone.data())
async def async_turn_on(self) -> None:
"""Turn the entity on."""
params = {
API_SYSTEM_ID: self.system_id,
API_ZONE_ID: self.zone_id,
API_ON: 1,
}
_LOGGER.debug("Turn off params=%s", params)
await self._async_update_hvac_params(params)
async def async_turn_off(self) -> None:
"""Turn the entity off."""
params = {
API_SYSTEM_ID: self.system_id,
API_ZONE_ID: self.zone_id,
API_ON: 0,
}
_LOGGER.debug("Turn off params=%s", params)
await self._async_update_hvac_params(params)
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
"""Set hvac mode."""
params = {