1 """Support for SUPLA covers - curtains, rollershutters, entry gate etc."""
3 from __future__
import annotations
6 from pprint
import pformat
14 from .
import DOMAIN, SUPLA_COORDINATORS, SUPLA_SERVERS
15 from .entity
import SuplaEntity
17 _LOGGER = logging.getLogger(__name__)
19 SUPLA_SHUTTER =
"CONTROLLINGTHEROLLERSHUTTER"
20 SUPLA_GATE =
"CONTROLLINGTHEGATE"
21 SUPLA_GARAGE_DOOR =
"CONTROLLINGTHEGARAGEDOOR"
27 async_add_entities: AddEntitiesCallback,
28 discovery_info: DiscoveryInfoType |
None =
None,
30 """Set up the SUPLA covers."""
31 if discovery_info
is None:
34 _LOGGER.debug(
"Discovery: %s", pformat(discovery_info))
36 entities: list[CoverEntity] = []
37 for device
in discovery_info.values():
38 device_name = device[
"function_name"]
39 server_name = device[
"server_name"]
41 if device_name == SUPLA_SHUTTER:
45 hass.data[DOMAIN][SUPLA_SERVERS][server_name],
46 hass.data[DOMAIN][SUPLA_COORDINATORS][server_name],
50 elif device_name
in {SUPLA_GATE, SUPLA_GARAGE_DOOR}:
54 hass.data[DOMAIN][SUPLA_SERVERS][server_name],
55 hass.data[DOMAIN][SUPLA_COORDINATORS][server_name],
63 """Representation of a SUPLA Cover."""
67 """Return current position of cover. 0 is closed, 100 is open."""
69 return 100 - state[
"shut"]
73 """Move the cover to a specific position."""
75 "REVEAL_PARTIALLY", percentage=kwargs.get(ATTR_POSITION)
80 """Return if the cover is closed."""
90 """Close the cover."""
99 """Representation of a SUPLA door."""
101 _attr_device_class = CoverDeviceClass.GARAGE
105 """Return if the door is closed or not."""
107 if state
and "hi" in state:
108 return state.get(
"hi")
117 """Close the door."""
126 """Toggle the door."""
bool|None is_closed(self)
int|None current_cover_position(self)
None async_open_cover(self, **Any kwargs)
int|None current_cover_position(self)
bool|None is_closed(self)
None async_close_cover(self, **Any kwargs)
None async_set_cover_position(self, **Any kwargs)
None async_stop_cover(self, **Any kwargs)
None async_close_cover(self, **Any kwargs)
None async_stop_cover(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
bool|None is_closed(self)
None async_toggle(self, **Any kwargs)
def async_action(self, action, **add_pars)
web.Response get(self, web.Request request, str config_key)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)