1 """Support for the Airzone Cloud climate."""
3 from __future__
import annotations
5 from typing
import Any, Final
7 from aioairzone_cloud.common
import OperationAction, OperationMode, TemperatureUnit
8 from aioairzone_cloud.const
import (
35 AZD_TEMP_SET_COOL_AIR,
45 ATTR_TARGET_TEMP_HIGH,
61 from .
import AirzoneCloudConfigEntry
62 from .coordinator
import AirzoneUpdateCoordinator
67 AirzoneInstallationEntity,
71 FAN_SPEED_AUTO: dict[int, str] = {
75 FAN_SPEED_MAPS: Final[dict[int, dict[int, str]]] = {
87 HVAC_ACTION_LIB_TO_HASS: Final[dict[OperationAction, HVACAction]] = {
88 OperationAction.COOLING: HVACAction.COOLING,
89 OperationAction.DRYING: HVACAction.DRYING,
90 OperationAction.FAN: HVACAction.FAN,
91 OperationAction.HEATING: HVACAction.HEATING,
92 OperationAction.IDLE: HVACAction.IDLE,
93 OperationAction.OFF: HVACAction.OFF,
95 HVAC_MODE_LIB_TO_HASS: Final[dict[OperationMode, HVACMode]] = {
96 OperationMode.STOP: HVACMode.OFF,
97 OperationMode.COOLING: HVACMode.COOL,
98 OperationMode.COOLING_AIR: HVACMode.COOL,
99 OperationMode.COOLING_RADIANT: HVACMode.COOL,
100 OperationMode.COOLING_COMBINED: HVACMode.COOL,
101 OperationMode.HEATING: HVACMode.HEAT,
102 OperationMode.HEAT_AIR: HVACMode.HEAT,
103 OperationMode.HEAT_RADIANT: HVACMode.HEAT,
104 OperationMode.HEAT_COMBINED: HVACMode.HEAT,
105 OperationMode.EMERGENCY_HEAT: HVACMode.HEAT,
106 OperationMode.VENTILATION: HVACMode.FAN_ONLY,
107 OperationMode.DRY: HVACMode.DRY,
108 OperationMode.AUTO: HVACMode.HEAT_COOL,
110 HVAC_MODE_HASS_TO_LIB: Final[dict[HVACMode, OperationMode]] = {
111 HVACMode.OFF: OperationMode.STOP,
112 HVACMode.COOL: OperationMode.COOLING,
113 HVACMode.HEAT: OperationMode.HEATING,
114 HVACMode.FAN_ONLY: OperationMode.VENTILATION,
115 HVACMode.DRY: OperationMode.DRY,
116 HVACMode.HEAT_COOL: OperationMode.AUTO,
122 entry: AirzoneCloudConfigEntry,
123 async_add_entities: AddEntitiesCallback,
125 """Add Airzone climate from a config_entry."""
126 coordinator = entry.runtime_data
128 entities: list[AirzoneClimate] = []
131 for aidoo_id, aidoo_data
in coordinator.data.get(AZD_AIDOOS, {}).items():
141 for group_id, group_data
in coordinator.data.get(AZD_GROUPS, {}).items():
142 if group_data[AZD_NUM_DEVICES] > 1:
152 for inst_id, inst_data
in coordinator.data.get(AZD_INSTALLATIONS, {}).items():
153 if inst_data[AZD_NUM_GROUPS] > 1:
163 for zone_id, zone_data
in coordinator.data.get(AZD_ZONES, {}).items():
176 """Define an Airzone Cloud climate."""
179 _attr_temperature_unit = UnitOfTemperature.CELSIUS
180 _enable_turn_on_off_backwards_compatibility =
False
183 """Init common climate device attributes."""
187 HVAC_MODE_LIB_TO_HASS[mode]
for mode
in self.
get_airzone_valueget_airzone_value(AZD_MODES)
193 self._attr_supported_features |= (
194 ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
201 self._initialize_fan_speeds()
205 """Update attributes when the coordinator updates."""
211 """Update climate attributes."""
232 AZD_TEMP_SET_COOL_AIR
245 """Define an Airzone Cloud Device base class."""
247 _attr_supported_features = (
248 ClimateEntityFeature.TARGET_TEMPERATURE
249 | ClimateEntityFeature.TURN_OFF
250 | ClimateEntityFeature.TURN_ON
252 _speeds: dict[int, str]
253 _speeds_reverse: dict[str, int]
256 """Initialize fan speeds."""
258 max_speed =
max(azd_speeds)
260 fan_speeds: dict[int, str]
261 if speeds_map := FAN_SPEED_MAPS.get(max_speed):
262 fan_speeds = speeds_map
266 for speed
in azd_speeds:
268 fan_speeds[speed] = f
"{int(round((speed * 100) / max_speed, 0))}%"
271 fan_speeds = FAN_SPEED_AUTO | fan_speeds
274 for key, value
in fan_speeds.items():
275 _key = azd_speeds.get(key)
277 self.
_speeds_speeds[_key] = value
285 """Turn the entity on."""
294 """Turn the entity off."""
303 """Set new fan mode."""
304 params: dict[str, Any] = {
312 """Set new target temperature."""
313 hvac_mode = kwargs.get(ATTR_HVAC_MODE)
314 if hvac_mode
is not None:
317 params: dict[str, Any] = {}
318 if ATTR_TEMPERATURE
in kwargs:
319 params[API_SETPOINT] = {
320 API_VALUE: kwargs[ATTR_TEMPERATURE],
322 API_UNITS: TemperatureUnit.CELSIUS.value,
325 if ATTR_TARGET_TEMP_LOW
in kwargs
and ATTR_TARGET_TEMP_HIGH
in kwargs:
326 params[API_SP_AIR_COOL] = {
327 API_VALUE: kwargs[ATTR_TARGET_TEMP_HIGH],
329 API_UNITS: TemperatureUnit.CELSIUS.value,
332 params[API_SP_AIR_HEAT] = {
333 API_VALUE: kwargs[ATTR_TARGET_TEMP_LOW],
335 API_UNITS: TemperatureUnit.CELSIUS.value,
342 """Define an Airzone Cloud DeviceGroup base class."""
344 _attr_supported_features = (
345 ClimateEntityFeature.TARGET_TEMPERATURE
346 | ClimateEntityFeature.TURN_OFF
347 | ClimateEntityFeature.TURN_ON
351 """Turn the entity on."""
360 """Turn the entity off."""
369 """Set new target temperature."""
370 hvac_mode = kwargs.get(ATTR_HVAC_MODE)
371 if hvac_mode
is not None:
374 params: dict[str, Any] = {}
375 if ATTR_TEMPERATURE
in kwargs:
376 params[API_PARAMS] = {
377 API_SETPOINT: kwargs[ATTR_TEMPERATURE],
380 API_UNITS: TemperatureUnit.CELSIUS.value,
386 params: dict[str, Any] = {
389 if hvac_mode == HVACMode.OFF:
390 params[API_PARAMS][API_POWER] =
False
392 mode = HVAC_MODE_HASS_TO_LIB[hvac_mode]
393 params[API_PARAMS][API_MODE] = mode.value
394 params[API_PARAMS][API_POWER] =
True
399 """Define an Airzone Cloud Aidoo climate."""
403 coordinator: AirzoneUpdateCoordinator,
407 """Initialize Airzone Cloud Aidoo climate."""
408 super().
__init__(coordinator, aidoo_id, aidoo_data)
417 params: dict[str, Any] = {}
418 if hvac_mode == HVACMode.OFF:
419 params[API_POWER] = {
423 mode = HVAC_MODE_HASS_TO_LIB[hvac_mode]
425 API_VALUE: mode.value,
427 params[API_POWER] = {
434 """Define an Airzone Cloud Group climate."""
438 coordinator: AirzoneUpdateCoordinator,
442 """Initialize Airzone Cloud Group climate."""
443 super().
__init__(coordinator, group_id, group_data)
452 """Define an Airzone Cloud Installation climate."""
456 coordinator: AirzoneUpdateCoordinator,
460 """Initialize Airzone Cloud Installation climate."""
461 super().
__init__(coordinator, inst_id, inst_data)
470 """Define an Airzone Cloud Zone climate."""
474 coordinator: AirzoneUpdateCoordinator,
478 """Initialize Airzone Cloud Zone climate."""
479 super().
__init__(coordinator, system_zone_id, zone_data)
490 params: dict[str, Any] = {}
491 if hvac_mode == HVACMode.OFF:
492 params[API_POWER] = {
496 mode = HVAC_MODE_HASS_TO_LIB[hvac_mode]
498 if hvac_mode != HVAC_MODE_LIB_TO_HASS[cur_mode]:
501 API_VALUE: mode.value,
505 params[API_POWER] = {
513 f
"Mode can't be changed on slave zone {self.entity_id}"
None async_set_hvac_mode(self, HVACMode hvac_mode)
None __init__(self, AirzoneUpdateCoordinator coordinator, str aidoo_id, dict aidoo_data)
_attr_target_temperature_low
_attr_current_temperature
_attr_target_temperature_high
_attr_target_temperature_step
None _handle_coordinator_update(self)
None _init_attributes(self)
None _async_update_attrs(self)
None _initialize_fan_speeds(self)
None async_turn_off(self)
None async_set_temperature(self, **Any kwargs)
tuple _attr_supported_features
None async_set_fan_mode(self, str fan_mode)
None async_turn_off(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
None async_set_temperature(self, **Any kwargs)
None __init__(self, AirzoneUpdateCoordinator coordinator, str group_id, dict group_data)
None __init__(self, AirzoneUpdateCoordinator coordinator, str inst_id, dict inst_data)
None __init__(self, AirzoneUpdateCoordinator coordinator, str system_zone_id, dict zone_data)
None async_set_hvac_mode(self, HVACMode hvac_mode)
None _async_update_params(self, dict[str, Any] params)
None _async_update_params(self, dict[str, Any] params)
Any get_airzone_value(self, str key)
None _async_update_params(self, dict[str, Any] params)
Any get_airzone_value(self, str key)
ClimateEntityFeature supported_features(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
int|None supported_features(self)
None async_setup_entry(HomeAssistant hass, AirzoneCloudConfigEntry entry, AddEntitiesCallback async_add_entities)
web.Response get(self, web.Request request, str config_key)