1 """Switch platform for Advantage Air integration."""
9 from .
import AdvantageAirDataConfigEntry
11 ADVANTAGE_AIR_AUTOFAN_ENABLED,
12 ADVANTAGE_AIR_STATE_OFF,
13 ADVANTAGE_AIR_STATE_ON,
15 from .entity
import AdvantageAirAcEntity, AdvantageAirThingEntity
16 from .models
import AdvantageAirData
21 config_entry: AdvantageAirDataConfigEntry,
22 async_add_entities: AddEntitiesCallback,
24 """Set up AdvantageAir switch platform."""
26 instance = config_entry.runtime_data
28 entities: list[SwitchEntity] = []
29 if aircons := instance.coordinator.data.get(
"aircons"):
30 for ac_key, ac_device
in aircons.items():
31 if ac_device[
"info"][
"freshAirStatus"] !=
"none":
33 if ADVANTAGE_AIR_AUTOFAN_ENABLED
in ac_device[
"info"]:
35 if things := instance.coordinator.data.get(
"myThings"):
38 for thing
in things[
"things"].values()
39 if thing[
"channelDipState"] == 8
45 """Representation of Advantage Air fresh air control."""
47 _attr_icon =
"mdi:air-filter"
48 _attr_name =
"Fresh air"
49 _attr_device_class = SwitchDeviceClass.SWITCH
51 def __init__(self, instance: AdvantageAirData, ac_key: str) ->
None:
52 """Initialize an Advantage Air fresh air control."""
54 self._attr_unique_id +=
"-freshair"
58 """Return the fresh air status."""
59 return self.
_ac_ac[
"freshAirStatus"] == ADVANTAGE_AIR_STATE_ON
62 """Turn fresh air on."""
63 await self.
async_update_acasync_update_ac({
"freshAirStatus": ADVANTAGE_AIR_STATE_ON})
66 """Turn fresh air off."""
67 await self.
async_update_acasync_update_ac({
"freshAirStatus": ADVANTAGE_AIR_STATE_OFF})
71 """Representation of Advantage Air MyFan control."""
73 _attr_icon =
"mdi:fan-auto"
75 _attr_device_class = SwitchDeviceClass.SWITCH
77 def __init__(self, instance: AdvantageAirData, ac_key: str) ->
None:
78 """Initialize an Advantage Air MyFan control."""
80 self._attr_unique_id +=
"-myfan"
84 """Return the MyFan status."""
85 return self.
_ac_ac[ADVANTAGE_AIR_AUTOFAN_ENABLED]
89 await self.
async_update_acasync_update_ac({ADVANTAGE_AIR_AUTOFAN_ENABLED:
True})
93 await self.
async_update_acasync_update_ac({ADVANTAGE_AIR_AUTOFAN_ENABLED:
False})
97 """Representation of Advantage Air Thing."""
99 _attr_device_class = SwitchDeviceClass.SWITCH
None __init__(self, AdvantageAirData instance, str ac_key)
None async_turn_on(self, **Any kwargs)
None async_turn_off(self, **Any kwargs)
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None __init__(self, AdvantageAirData instance, str ac_key)
None async_setup_entry(HomeAssistant hass, AdvantageAirDataConfigEntry config_entry, AddEntitiesCallback async_add_entities)