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
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Final
|
from typing import Any, Final
|
||||||
|
|
||||||
from aioairzone.common import OperationMode
|
from aioairzone.common import OperationMode
|
||||||
from aioairzone.const import (
|
from aioairzone.const import (
|
||||||
@ -123,10 +123,16 @@ class AirzoneClimate(AirzoneEntity, ClimateEntity):
|
|||||||
]
|
]
|
||||||
self._async_update_attrs()
|
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."""
|
"""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:
|
try:
|
||||||
await self.coordinator.airzone.put_hvac(params)
|
await self.coordinator.airzone.put_hvac(_params)
|
||||||
except AirzoneError as error:
|
except AirzoneError as error:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f"Failed to set zone {self.name}: {error}"
|
f"Failed to set zone {self.name}: {error}"
|
||||||
@ -137,29 +143,20 @@ class AirzoneClimate(AirzoneEntity, ClimateEntity):
|
|||||||
async def async_turn_on(self) -> None:
|
async def async_turn_on(self) -> None:
|
||||||
"""Turn the entity on."""
|
"""Turn the entity on."""
|
||||||
params = {
|
params = {
|
||||||
API_SYSTEM_ID: self.system_id,
|
|
||||||
API_ZONE_ID: self.zone_id,
|
|
||||||
API_ON: 1,
|
API_ON: 1,
|
||||||
}
|
}
|
||||||
_LOGGER.debug("Turn off params=%s", params)
|
|
||||||
await self._async_update_hvac_params(params)
|
await self._async_update_hvac_params(params)
|
||||||
|
|
||||||
async def async_turn_off(self) -> None:
|
async def async_turn_off(self) -> None:
|
||||||
"""Turn the entity off."""
|
"""Turn the entity off."""
|
||||||
params = {
|
params = {
|
||||||
API_SYSTEM_ID: self.system_id,
|
|
||||||
API_ZONE_ID: self.zone_id,
|
|
||||||
API_ON: 0,
|
API_ON: 0,
|
||||||
}
|
}
|
||||||
_LOGGER.debug("Turn off params=%s", params)
|
|
||||||
await self._async_update_hvac_params(params)
|
await self._async_update_hvac_params(params)
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
||||||
"""Set hvac mode."""
|
"""Set hvac mode."""
|
||||||
params = {
|
params = {}
|
||||||
API_SYSTEM_ID: self.system_id,
|
|
||||||
API_ZONE_ID: self.zone_id,
|
|
||||||
}
|
|
||||||
if hvac_mode == HVAC_MODE_OFF:
|
if hvac_mode == HVAC_MODE_OFF:
|
||||||
params[API_ON] = 0
|
params[API_ON] = 0
|
||||||
else:
|
else:
|
||||||
@ -172,18 +169,13 @@ class AirzoneClimate(AirzoneEntity, ClimateEntity):
|
|||||||
f"Mode can't be changed on slave zone {self.name}"
|
f"Mode can't be changed on slave zone {self.name}"
|
||||||
)
|
)
|
||||||
params[API_ON] = 1
|
params[API_ON] = 1
|
||||||
_LOGGER.debug("Set hvac_mode=%s params=%s", hvac_mode, params)
|
|
||||||
await self._async_update_hvac_params(params)
|
await self._async_update_hvac_params(params)
|
||||||
|
|
||||||
async def async_set_temperature(self, **kwargs) -> None:
|
async def async_set_temperature(self, **kwargs) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
temp = kwargs.get(ATTR_TEMPERATURE)
|
|
||||||
params = {
|
params = {
|
||||||
API_SYSTEM_ID: self.system_id,
|
API_SET_POINT: kwargs.get(ATTR_TEMPERATURE),
|
||||||
API_ZONE_ID: self.zone_id,
|
|
||||||
API_SET_POINT: temp,
|
|
||||||
}
|
}
|
||||||
_LOGGER.debug("Set temp=%s params=%s", temp, params)
|
|
||||||
await self._async_update_hvac_params(params)
|
await self._async_update_hvac_params(params)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
Loading…
x
Reference in New Issue
Block a user