1 """Support for Slide slides."""
3 from __future__
import annotations
14 from .const
import API, DEFAULT_OFFSET, DOMAIN, SLIDES
16 _LOGGER = logging.getLogger(__name__)
26 async_add_entities: AddEntitiesCallback,
27 discovery_info: DiscoveryInfoType |
None =
None,
29 """Set up cover(s) for Slide platform."""
31 if discovery_info
is None:
36 for slide
in hass.data[DOMAIN][SLIDES].values():
37 _LOGGER.debug(
"Setting up Slide entity: %s", slide)
38 entities.append(
SlideCover(hass.data[DOMAIN][API], slide))
44 """Representation of a Slide cover."""
46 _attr_assumed_state =
True
47 _attr_device_class = CoverDeviceClass.CURTAIN
50 """Initialize the cover."""
53 self.
_id_id = slide[
"id"]
61 """Return if the cover is opening or not."""
62 return self.
_slide_slide[
"state"] == OPENING
66 """Return if the cover is closing or not."""
67 return self.
_slide_slide[
"state"] == CLOSING
71 """Return None if status is unknown, True if closed, else False."""
72 if self.
_slide_slide[
"state"]
is None:
74 return self.
_slide_slide[
"state"] == CLOSED
78 """Return False if state is not available."""
79 return self.
_slide_slide[
"online"]
83 """Return the current position of cover shutter."""
84 if (pos := self.
_slide_slide[
"pos"])
is not None:
85 if (1 - pos) <= DEFAULT_OFFSET
or pos <= DEFAULT_OFFSET:
94 self.
_slide_slide[
"state"] = OPENING
95 await self.
_api_api.slide_open(self.
_id_id)
98 """Close the cover."""
99 self.
_slide_slide[
"state"] = CLOSING
100 await self.
_api_api.slide_close(self.
_id_id)
103 """Stop the cover."""
104 await self.
_api_api.slide_stop(self.
_id_id)
107 """Move the cover to a specific position."""
108 position = kwargs[ATTR_POSITION] / 100
110 position = 1 - position
112 if self.
_slide_slide[
"pos"]
is not None:
113 if position > self.
_slide_slide[
"pos"]:
114 self.
_slide_slide[
"state"] = CLOSING
116 self.
_slide_slide[
"state"] = OPENING
118 await self.
_api_api.slide_set_position(self.
_id_id, position)
bool|None is_closed(self)
None async_stop_cover(self, **Any kwargs)
def __init__(self, api, slide)
_attr_extra_state_attributes
None async_close_cover(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
None async_set_cover_position(self, **Any kwargs)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)