1 """Climate platform for Advantage Air integration."""
3 from __future__
import annotations
24 from .
import AdvantageAirDataConfigEntry
26 ADVANTAGE_AIR_AUTOFAN_ENABLED,
27 ADVANTAGE_AIR_STATE_CLOSE,
28 ADVANTAGE_AIR_STATE_OFF,
29 ADVANTAGE_AIR_STATE_ON,
30 ADVANTAGE_AIR_STATE_OPEN,
32 from .entity
import AdvantageAirAcEntity, AdvantageAirZoneEntity
33 from .models
import AdvantageAirData
35 ADVANTAGE_AIR_HVAC_MODES = {
36 "heat": HVACMode.HEAT,
37 "cool": HVACMode.COOL,
38 "vent": HVACMode.FAN_ONLY,
40 "myauto": HVACMode.HEAT_COOL,
42 HASS_HVAC_MODES = {v: k
for k, v
in ADVANTAGE_AIR_HVAC_MODES.items()}
44 ADVANTAGE_AIR_MYZONE =
"MyZone"
45 ADVANTAGE_AIR_MYAUTO =
"MyAuto"
46 ADVANTAGE_AIR_MYAUTO_ENABLED =
"myAutoModeEnabled"
47 ADVANTAGE_AIR_MYTEMP =
"MyTemp"
48 ADVANTAGE_AIR_MYTEMP_ENABLED =
"climateControlModeEnabled"
49 ADVANTAGE_AIR_HEAT_TARGET =
"myAutoHeatTargetTemp"
50 ADVANTAGE_AIR_COOL_TARGET =
"myAutoCoolTargetTemp"
51 ADVANTAGE_AIR_MYFAN =
"autoAA"
60 HVAC_MODES_MYAUTO = [*HVAC_MODES, HVACMode.HEAT_COOL]
61 SUPPORTED_FEATURES = (
62 ClimateEntityFeature.FAN_MODE
63 | ClimateEntityFeature.TURN_OFF
64 | ClimateEntityFeature.TURN_ON
66 SUPPORTED_FEATURES_MYZONE = SUPPORTED_FEATURES | ClimateEntityFeature.TARGET_TEMPERATURE
67 SUPPORTED_FEATURES_MYAUTO = (
68 SUPPORTED_FEATURES | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
73 _LOGGER = logging.getLogger(__name__)
78 config_entry: AdvantageAirDataConfigEntry,
79 async_add_entities: AddEntitiesCallback,
81 """Set up AdvantageAir climate platform."""
83 instance = config_entry.runtime_data
85 entities: list[ClimateEntity] = []
86 if aircons := instance.coordinator.data.get(
"aircons"):
87 for ac_key, ac_device
in aircons.items():
89 for zone_key, zone
in ac_device[
"zones"].items():
97 """AdvantageAir AC unit."""
99 _attr_fan_modes = [FAN_LOW, FAN_MEDIUM, FAN_HIGH, FAN_AUTO]
100 _attr_temperature_unit = UnitOfTemperature.CELSIUS
101 _attr_target_temperature_step = PRECISION_WHOLE
105 _enable_turn_on_off_backwards_compatibility =
False
108 def __init__(self, instance: AdvantageAirData, ac_key: str) ->
None:
109 """Initialize an AdvantageAir AC unit."""
115 if ADVANTAGE_AIR_MYTEMP_ENABLED
in self.
_ac_ac:
120 if ADVANTAGE_AIR_MYAUTO_ENABLED
in self.
_ac_ac:
128 """Configure attributes based on preset."""
131 if self.
_ac_ac.
get(ADVANTAGE_AIR_MYAUTO_ENABLED):
138 elif self.
_ac_ac.
get(ADVANTAGE_AIR_MYTEMP_ENABLED):
153 """Handle updated data from the coordinator."""
159 """Return the selected zones current temperature."""
161 return self.
_myzone_myzone[
"measuredTemp"]
166 """Return the current target temperature."""
169 return self.
_myzone_myzone[
"setTemp"]
170 return self.
_ac_ac[
"setTemp"]
174 """Return the current HVAC modes."""
175 if self.
_ac_ac[
"state"] == ADVANTAGE_AIR_STATE_ON:
176 return ADVANTAGE_AIR_HVAC_MODES.get(self.
_ac_ac[
"mode"])
181 """Return the current fan modes."""
182 return FAN_AUTO
if self.
_ac_ac[
"fan"] == ADVANTAGE_AIR_MYFAN
else self.
_ac_ac[
"fan"]
186 """Return the temperature cool mode is enabled."""
187 return self.
_ac_ac.
get(ADVANTAGE_AIR_COOL_TARGET)
191 """Return the temperature heat mode is enabled."""
192 return self.
_ac_ac.
get(ADVANTAGE_AIR_HEAT_TARGET)
195 """Set the HVAC State to on."""
196 await self.
async_update_acasync_update_ac({
"state": ADVANTAGE_AIR_STATE_ON})
199 """Set the HVAC State to off."""
202 "state": ADVANTAGE_AIR_STATE_OFF,
207 """Set the HVAC Mode and State."""
208 if hvac_mode == HVACMode.OFF:
215 "state": ADVANTAGE_AIR_STATE_ON,
216 "mode": HASS_HVAC_MODES.get(hvac_mode),
221 """Set the Fan Mode."""
222 if fan_mode == FAN_AUTO
and self.
_ac_ac.
get(ADVANTAGE_AIR_AUTOFAN_ENABLED):
223 mode = ADVANTAGE_AIR_MYFAN
229 """Set the Temperature."""
230 if ATTR_TEMPERATURE
in kwargs:
231 await self.
async_update_acasync_update_ac({
"setTemp": kwargs[ATTR_TEMPERATURE]})
232 if ATTR_TARGET_TEMP_LOW
in kwargs
and ATTR_TARGET_TEMP_HIGH
in kwargs:
235 ADVANTAGE_AIR_COOL_TARGET: kwargs[ATTR_TARGET_TEMP_HIGH],
236 ADVANTAGE_AIR_HEAT_TARGET: kwargs[ATTR_TARGET_TEMP_LOW],
241 """Set the preset mode."""
243 if ADVANTAGE_AIR_MYTEMP_ENABLED
in self.
_ac_ac:
244 change[ADVANTAGE_AIR_MYTEMP_ENABLED] = preset_mode == ADVANTAGE_AIR_MYTEMP
245 if ADVANTAGE_AIR_MYAUTO_ENABLED
in self.
_ac_ac:
246 change[ADVANTAGE_AIR_MYAUTO_ENABLED] = preset_mode == ADVANTAGE_AIR_MYAUTO
252 """AdvantageAir MyTemp Zone control."""
254 _attr_hvac_modes = [HVACMode.OFF, HVACMode.HEAT_COOL]
255 _attr_supported_features = (
256 ClimateEntityFeature.TARGET_TEMPERATURE
257 | ClimateEntityFeature.TURN_OFF
258 | ClimateEntityFeature.TURN_ON
260 _attr_temperature_unit = UnitOfTemperature.CELSIUS
261 _attr_target_temperature_step = PRECISION_WHOLE
264 _enable_turn_on_off_backwards_compatibility =
False
266 def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) ->
None:
267 """Initialize an AdvantageAir Zone control."""
268 super().
__init__(instance, ac_key, zone_key)
273 """Return the current state as HVAC mode."""
274 if self.
_zone_zone[
"state"] == ADVANTAGE_AIR_STATE_OPEN:
275 return HVACMode.HEAT_COOL
280 """Return the current temperature."""
281 return self.
_zone_zone[
"measuredTemp"]
285 """Return the target temperature."""
286 return self.
_zone_zone[
"setTemp"]
289 """Set the HVAC State to on."""
290 await self.
async_update_zoneasync_update_zone({
"state": ADVANTAGE_AIR_STATE_OPEN})
293 """Set the HVAC State to off."""
294 await self.
async_update_zoneasync_update_zone({
"state": ADVANTAGE_AIR_STATE_CLOSE})
297 """Set the HVAC Mode and State."""
298 if hvac_mode == HVACMode.OFF:
304 """Set the Temperature."""
305 temp = kwargs.get(ATTR_TEMPERATURE)
None async_set_hvac_mode(self, HVACMode hvac_mode)
float|None current_temperature(self)
None async_set_preset_mode(self, str preset_mode)
None async_set_fan_mode(self, str fan_mode)
None _async_configure_preset(self)
float|None target_temperature_low(self)
None _handle_coordinator_update(self)
None __init__(self, AdvantageAirData instance, str ac_key)
None async_set_temperature(self, **Any kwargs)
None async_turn_off(self)
float|None target_temperature(self)
float|None target_temperature_high(self)
None async_turn_off(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
float target_temperature(self)
None async_set_temperature(self, **Any kwargs)
float|None current_temperature(self)
None __init__(self, AdvantageAirData instance, str ac_key, str zone_key)
dict[str, Any]|None _myzone(self)
dict[str, Any] _zone(self)
None async_turn_off(self)
str|None preset_mode(self)
None async_setup_entry(HomeAssistant hass, AdvantageAirDataConfigEntry config_entry, AddEntitiesCallback async_add_entities)
web.Response get(self, web.Request request, str config_key)