1 """Cover Platform for Chacon Dio REV-SHUTTER devices."""
6 from dio_chacon_wifi_api.const
import DeviceTypeEnum, ShutterMoveEnum
17 from .
import ChaconDioConfigEntry
18 from .entity
import ChaconDioEntity
20 _LOGGER = logging.getLogger(__name__)
25 config_entry: ChaconDioConfigEntry,
26 async_add_entities: AddEntitiesCallback,
28 """Set up Chacon Dio cover devices."""
29 data = config_entry.runtime_data
34 for device
in data.list_devices
35 if device[
"type"] == DeviceTypeEnum.SHUTTER.value
40 """Object for controlling a Chacon Dio cover."""
42 _attr_device_class = CoverDeviceClass.SHUTTER
45 _attr_supported_features = (
46 CoverEntityFeature.OPEN
47 | CoverEntityFeature.CLOSE
48 | CoverEntityFeature.STOP
49 | CoverEntityFeature.SET_POSITION
53 """Recomputes the attributes values either at init or when the device state changes."""
63 Closed status is effective after the server callback that triggers callback_device_state.
67 "Close cover %s , %s, %s",
78 await self.
clientclient.move_shutter_direction(
79 self.target_id, ShutterMoveEnum.DOWN
85 Opened status is effective after the server callback that triggers callback_device_state.
89 "Open cover %s , %s, %s",
100 await self.
clientclient.move_shutter_direction(self.target_id, ShutterMoveEnum.UP)
103 """Stop the cover."""
105 _LOGGER.debug(
"Stop cover %s , %s", self.target_id, self.
_attr_name_attr_name)
111 await self.
clientclient.move_shutter_direction(self.target_id, ShutterMoveEnum.STOP)
114 """Set the cover open position in percentage.
116 Closing or opening status is effective after the server callback that triggers callback_device_state.
118 position: int = kwargs[ATTR_POSITION]
121 "Set cover position %i, %s , %s", position, self.target_id, self.
_attr_name_attr_name
124 await self.
clientclient.move_shutter_percentage(self.target_id, position)
None async_set_cover_position(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
None _update_attr(self, dict[str, Any] data)
None async_stop_cover(self, **Any kwargs)
_attr_current_cover_position
None async_close_cover(self, **Any kwargs)
bool|None is_closed(self)
int|None current_cover_position(self)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ChaconDioConfigEntry config_entry, AddEntitiesCallback async_add_entities)