1 """Representation of the Damper for AirTouch 5 Devices."""
6 from airtouch5py.airtouch5_simple_client
import Airtouch5SimpleClient
7 from airtouch5py.packets.zone_control
import (
12 from airtouch5py.packets.zone_name
import ZoneName
13 from airtouch5py.packets.zone_status
import ZoneStatusZone
25 from .
import Airtouch5ConfigEntry
26 from .const
import DOMAIN
27 from .entity
import Airtouch5Entity
29 _LOGGER = logging.getLogger(__name__)
34 config_entry: Airtouch5ConfigEntry,
35 async_add_entities: AddEntitiesCallback,
37 """Set up the Airtouch 5 Cover entities."""
38 client = config_entry.runtime_data
43 client, zone, client.latest_zone_status[zone.zone_number].has_sensor
45 for zone
in client.zones
50 """How open the damper is in each zone."""
52 _attr_device_class = CoverDeviceClass.DAMPER
53 _attr_translation_key =
"damper"
57 _attr_supported_features = (
58 CoverEntityFeature.SET_POSITION
59 | CoverEntityFeature.OPEN
60 | CoverEntityFeature.CLOSE
64 self, client: Airtouch5SimpleClient, zone_name: ZoneName, has_sensor: bool
66 """Initialise the Cover Entity."""
70 self.
_attr_unique_id_attr_unique_id = f
"zone_{zone_name.zone_number}_open_percentage"
72 identifiers={(DOMAIN, f
"zone_{zone_name.zone_number}")},
73 name=zone_name.zone_name,
74 manufacturer=
"Polyaire",
80 if self.
_zone_name_zone_name.zone_number
not in data:
82 status = data[self.
_zone_name_zone_name.zone_number]
85 if status.open_percentage == 0:
92 """Add data updated listener after this object has been initialized."""
98 """Remove data updated listener after this object has been initialized."""
103 """Open the damper."""
111 """Update the damper to a specific position."""
113 if (position := kwargs.get(ATTR_POSITION))
is None:
114 _LOGGER.debug(
"Argument `position` is missing in set_cover_position")
119 power: ZoneSettingPower
121 if position_percent == 0:
122 power = ZoneSettingPower.SET_TO_OFF
124 power = ZoneSettingPower.SET_TO_ON
126 zcz = ZoneControlZone(
128 ZoneSettingValue.SET_OPEN_PERCENTAGE,
130 position_percent / 100.0,
133 packet = self.
_client_client.data_packet_factory.zone_control([zcz])
134 await self.
_client_client.send_packet(packet)
None async_open_cover(self, **Any kwargs)
None async_added_to_hass(self)
None async_close_cover(self, **Any kwargs)
None async_will_remove_from_hass(self)
None _async_update_attrs(self, dict[int, ZoneStatusZone] data)
_attr_current_cover_position
None async_set_cover_position(self, **Any kwargs)
None _set_cover_position(self, float position_percent)
None __init__(self, Airtouch5SimpleClient client, ZoneName zone_name, bool has_sensor)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, Airtouch5ConfigEntry config_entry, AddEntitiesCallback async_add_entities)