1 """AirTouch 4 component to control of AirTouch 4 Climate Devices."""
3 from __future__
import annotations
25 from .
import AirTouch4ConfigEntry
26 from .const
import DOMAIN
29 "Heat": HVACMode.HEAT,
30 "Cool": HVACMode.COOL,
31 "AutoHeat": HVACMode.AUTO,
32 "AutoCool": HVACMode.AUTO,
33 "Auto": HVACMode.AUTO,
35 "Fan": HVACMode.FAN_ONLY,
39 HVACMode.HEAT:
"Heat",
40 HVACMode.COOL:
"Cool",
41 HVACMode.AUTO:
"Auto",
43 HVACMode.FAN_ONLY:
"Fan",
47 AT_TO_HA_FAN_SPEED = {
52 "Powerful": FAN_FOCUS,
57 AT_GROUP_MODES = [HVACMode.OFF, HVACMode.FAN_ONLY]
59 HA_FAN_SPEED_TO_AT = {value: key
for key, value
in AT_TO_HA_FAN_SPEED.items()}
61 _LOGGER = logging.getLogger(__name__)
66 config_entry: AirTouch4ConfigEntry,
67 async_add_entities: AddEntitiesCallback,
69 """Set up the Airtouch 4."""
70 coordinator = config_entry.runtime_data
71 info = coordinator.data
72 entities: list[ClimateEntity] = [
74 for group
in info[
"groups"]
77 AirtouchAC(coordinator, ac[
"ac_number"], info)
for ac
in info[
"acs"]
80 _LOGGER.debug(
" Found entities %s", entities)
86 """Representation of an AirTouch 4 ac."""
88 _attr_has_entity_name =
True
91 _attr_supported_features = (
92 ClimateEntityFeature.TARGET_TEMPERATURE
93 | ClimateEntityFeature.FAN_MODE
94 | ClimateEntityFeature.TURN_OFF
95 | ClimateEntityFeature.TURN_ON
97 _attr_temperature_unit = UnitOfTemperature.CELSIUS
98 _enable_turn_on_off_backwards_compatibility =
False
101 """Initialize the climate device."""
109 identifiers={(DOMAIN, f
"ac_{ac_number}")},
110 name=f
"AC {ac_number}",
111 manufacturer=
"Airtouch",
122 """Return the current temperature."""
123 return self.
_unit_unit.Temperature
127 """Return fan mode of the AC this group belongs to."""
128 return AT_TO_HA_FAN_SPEED[self.
_airtouch_airtouch.acs[self.
_ac_number_ac_number].AcFanSpeed]
132 """Return the list of available fan modes."""
133 airtouch_fan_speeds = self.
_airtouch_airtouch.GetSupportedFanSpeedsForAc(self.
_ac_number_ac_number)
134 return [AT_TO_HA_FAN_SPEED[speed]
for speed
in airtouch_fan_speeds]
138 """Return hvac target hvac state."""
139 is_off = self.
_unit_unit.PowerState ==
"Off"
147 """Return the list of available operation modes."""
148 airtouch_modes = self.
_airtouch_airtouch.GetSupportedCoolingModesForAc(self.
_ac_number_ac_number)
149 modes = [AT_TO_HA_STATE[mode]
for mode
in airtouch_modes]
150 modes.append(HVACMode.OFF)
154 """Set new operation mode."""
155 if hvac_mode
not in HA_STATE_TO_AT:
156 raise ValueError(f
"Unsupported HVAC mode: {hvac_mode}")
158 if hvac_mode == HVACMode.OFF:
161 await self.
_airtouch_airtouch.SetCoolingModeForAc(
162 self.
_ac_number_ac_number, HA_STATE_TO_AT[hvac_mode]
167 _LOGGER.debug(
"Setting operation mode of %s to %s", self.
_ac_number_ac_number, hvac_mode)
171 """Set new fan mode."""
173 raise ValueError(f
"Unsupported fan mode: {fan_mode}")
175 _LOGGER.debug(
"Setting fan mode of %s to %s", self.
_ac_number_ac_number, fan_mode)
176 await self.
_airtouch_airtouch.SetFanSpeedForAc(
177 self.
_ac_number_ac_number, HA_FAN_SPEED_TO_AT[fan_mode]
184 _LOGGER.debug(
"Turning %s on", self.
unique_idunique_id)
191 _LOGGER.debug(
"Turning %s off", self.
unique_idunique_id)
197 """Representation of an AirTouch 4 group."""
199 _attr_has_entity_name =
True
201 _attr_supported_features = (
202 ClimateEntityFeature.TARGET_TEMPERATURE
203 | ClimateEntityFeature.TURN_OFF
204 | ClimateEntityFeature.TURN_ON
206 _attr_temperature_unit = UnitOfTemperature.CELSIUS
207 _attr_hvac_modes = AT_GROUP_MODES
208 _enable_turn_on_off_backwards_compatibility =
False
210 def __init__(self, coordinator, group_number, info):
211 """Initialize the climate device."""
219 identifiers={(DOMAIN, group_number)},
220 manufacturer=
"Airtouch",
222 name=self.
_unit_unit.GroupName,
232 """Return Minimum Temperature for AC of this group."""
233 return self.
_airtouch_airtouch.acs[self.
_unit_unit.BelongsToAc].MinSetpoint
237 """Return Max Temperature for AC of this group."""
238 return self.
_airtouch_airtouch.acs[self.
_unit_unit.BelongsToAc].MaxSetpoint
242 """Return the current temperature."""
243 return self.
_unit_unit.Temperature
247 """Return the temperature we are trying to reach."""
248 return self.
_unit_unit.TargetSetpoint
252 """Return hvac target hvac state."""
254 is_off = self.
_unit_unit.PowerState ==
"Off"
258 return HVACMode.FAN_ONLY
261 """Set new operation mode."""
262 if hvac_mode
not in HA_STATE_TO_AT:
263 raise ValueError(f
"Unsupported HVAC mode: {hvac_mode}")
265 if hvac_mode == HVACMode.OFF:
272 "Setting operation mode of %s to %s", self.
_group_number_group_number, hvac_mode
278 """Return fan mode of the AC this group belongs to."""
279 return AT_TO_HA_FAN_SPEED[self.
_airtouch_airtouch.acs[self.
_unit_unit.BelongsToAc].AcFanSpeed]
283 """Return the list of available fan modes."""
284 airtouch_fan_speeds = self.
_airtouch_airtouch.GetSupportedFanSpeedsByGroup(
287 return [AT_TO_HA_FAN_SPEED[speed]
for speed
in airtouch_fan_speeds]
290 """Set new target temperatures."""
291 if (temp := kwargs.get(ATTR_TEMPERATURE))
is None:
292 _LOGGER.debug(
"Argument `temperature` is missing in set_temperature")
295 _LOGGER.debug(
"Setting temp of %s to %s", self.
_group_number_group_number,
str(temp))
296 self.
_unit_unit = await self.
_airtouch_airtouch.SetGroupToTemperature(
302 """Set new fan mode."""
304 raise ValueError(f
"Unsupported fan mode: {fan_mode}")
306 _LOGGER.debug(
"Setting fan mode of %s to %s", self.
_group_number_group_number, fan_mode)
307 self.
_unit_unit = await self.
_airtouch_airtouch.SetFanSpeedByGroup(
308 self.
_group_number_group_number, HA_FAN_SPEED_TO_AT[fan_mode]
314 _LOGGER.debug(
"Turning %s on", self.
unique_idunique_id)
324 await self.coordinator.async_request_refresh()
329 _LOGGER.debug(
"Turning %s off", self.
unique_idunique_id)
334 await self.coordinator.async_request_refresh()
def current_temperature(self)
def _handle_coordinator_update(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
None async_turn_off(self)
def __init__(self, coordinator, ac_number, info)
None async_set_fan_mode(self, str fan_mode)
None async_set_fan_mode(self, str fan_mode)
def __init__(self, coordinator, group_number, info)
None async_set_temperature(self, **Any kwargs)
None async_turn_off(self)
def _handle_coordinator_update(self)
def current_temperature(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
def target_temperature(self)
list[str]|None fan_modes(self)
HVACMode|None hvac_mode(self)
None async_turn_off(self)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, AirTouch4ConfigEntry config_entry, AddEntitiesCallback async_add_entities)