mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
airzone: climate: move id params to _async_update_hvac_params (#70099)
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
parent
e04fef3c2d
commit
4a950f06e2
@ -2,7 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Final
|
||||
from typing import Any, Final
|
||||
|
||||
from aioairzone.common import OperationMode
|
||||
from aioairzone.const import (
|
||||
@ -123,10 +123,16 @@ class AirzoneClimate(AirzoneEntity, ClimateEntity):
|
||||
]
|
||||
self._async_update_attrs()
|
||||
|
||||
async def _async_update_hvac_params(self, params) -> None:
|
||||
async def _async_update_hvac_params(self, params: dict[str, Any]) -> None:
|
||||
"""Send HVAC parameters to API."""
|
||||
_params = {
|
||||
API_SYSTEM_ID: self.system_id,
|
||||
API_ZONE_ID: self.zone_id,
|
||||
**params,
|
||||
}
|
||||
_LOGGER.debug("update_hvac_params=%s", _params)
|
||||
try:
|
||||
await self.coordinator.airzone.put_hvac(params)
|
||||
await self.coordinator.airzone.put_hvac(_params)
|
||||
except AirzoneError as error:
|
||||
raise HomeAssistantError(
|
||||
f"Failed to set zone {self.name}: {error}"
|
||||
@ -137,29 +143,20 @@ class AirzoneClimate(AirzoneEntity, ClimateEntity):
|
||||
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 = {
|
||||
API_SYSTEM_ID: self.system_id,
|
||||
API_ZONE_ID: self.zone_id,
|
||||
}
|
||||
params = {}
|
||||
if hvac_mode == HVAC_MODE_OFF:
|
||||
params[API_ON] = 0
|
||||
else:
|
||||
@ -172,18 +169,13 @@ class AirzoneClimate(AirzoneEntity, ClimateEntity):
|
||||
f"Mode can't be changed on slave zone {self.name}"
|
||||
)
|
||||
params[API_ON] = 1
|
||||
_LOGGER.debug("Set hvac_mode=%s params=%s", hvac_mode, params)
|
||||
await self._async_update_hvac_params(params)
|
||||
|
||||
async def async_set_temperature(self, **kwargs) -> None:
|
||||
"""Set new target temperature."""
|
||||
temp = kwargs.get(ATTR_TEMPERATURE)
|
||||
params = {
|
||||
API_SYSTEM_ID: self.system_id,
|
||||
API_ZONE_ID: self.zone_id,
|
||||
API_SET_POINT: temp,
|
||||
API_SET_POINT: kwargs.get(ATTR_TEMPERATURE),
|
||||
}
|
||||
_LOGGER.debug("Set temp=%s params=%s", temp, params)
|
||||
await self._async_update_hvac_params(params)
|
||||
|
||||
@callback
|
||||
|
Loading…
x
Reference in New Issue
Block a user