1 """Cover platform for Advantage Air integration."""
14 from .
import AdvantageAirDataConfigEntry
15 from .const
import ADVANTAGE_AIR_STATE_CLOSE, ADVANTAGE_AIR_STATE_OPEN
16 from .entity
import AdvantageAirThingEntity, AdvantageAirZoneEntity
17 from .models
import AdvantageAirData
24 config_entry: AdvantageAirDataConfigEntry,
25 async_add_entities: AddEntitiesCallback,
27 """Set up AdvantageAir cover platform."""
29 instance = config_entry.runtime_data
31 entities: list[CoverEntity] = []
32 if aircons := instance.coordinator.data.get(
"aircons"):
33 for ac_key, ac_device
in aircons.items():
34 for zone_key, zone
in ac_device[
"zones"].items():
38 if things := instance.coordinator.data.get(
"myThings"):
39 for thing
in things[
"things"].values():
40 if thing[
"channelDipState"]
in [1, 2]:
44 elif thing[
"channelDipState"] == 3:
52 """Advantage Air Zone Vent."""
54 _attr_device_class = CoverDeviceClass.DAMPER
55 _attr_supported_features = (
56 CoverEntityFeature.OPEN
57 | CoverEntityFeature.CLOSE
58 | CoverEntityFeature.SET_POSITION
61 def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) ->
None:
62 """Initialize an Advantage Air Zone Vent."""
63 super().
__init__(instance, ac_key, zone_key)
68 """Return if vent is fully closed."""
69 return self.
_zone_zone[
"state"] == ADVANTAGE_AIR_STATE_CLOSE
73 """Return vents current position as a percentage."""
74 if self.
_zone_zone[
"state"] == ADVANTAGE_AIR_STATE_OPEN:
75 return self.
_zone_zone[
"value"]
79 """Fully open zone vent."""
81 {
"state": ADVANTAGE_AIR_STATE_OPEN,
"value": 100},
85 """Fully close zone vent."""
86 await self.
async_update_zoneasync_update_zone({
"state": ADVANTAGE_AIR_STATE_CLOSE})
89 """Change vent position."""
90 position = round(kwargs[ATTR_POSITION] / 5) * 5
92 await self.
async_update_zoneasync_update_zone({
"state": ADVANTAGE_AIR_STATE_CLOSE})
96 "state": ADVANTAGE_AIR_STATE_OPEN,
103 """Representation of Advantage Air Cover controlled by MyPlace."""
105 _attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
109 instance: AdvantageAirData,
110 thing: dict[str, Any],
111 device_class: CoverDeviceClass,
113 """Initialize an Advantage Air Things Cover."""
119 """Return if cover is fully closed."""
120 return self.
_data_data[
"value"] == 0
123 """Fully open zone vent."""
127 """Fully close zone vent."""
None async_close_cover(self, **Any kwargs)
None __init__(self, AdvantageAirData instance, dict[str, Any] thing, CoverDeviceClass device_class)
None async_open_cover(self, **Any kwargs)
None __init__(self, AdvantageAirData instance, str ac_key, str zone_key)
None async_close_cover(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
None async_set_cover_position(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None async_turn_off(self, **Any kwargs)
dict[str, Any] _zone(self)
None async_setup_entry(HomeAssistant hass, AdvantageAirDataConfigEntry config_entry, AddEntitiesCallback async_add_entities)