1 """Support for RFXtrx covers."""
3 from __future__
import annotations
8 import RFXtrx
as rfxtrxmod
16 from .
import DeviceTuple, async_setup_platform_entry
20 CONF_VENETIAN_BLIND_MODE,
21 CONST_VENETIAN_BLIND_MODE_EU,
22 CONST_VENETIAN_BLIND_MODE_US,
24 from .entity
import RfxtrxCommandEntity
26 _LOGGER = logging.getLogger(__name__)
29 def supported(event: rfxtrxmod.RFXtrxEvent) -> bool:
30 """Return whether an event supports cover."""
31 return bool(event.device.known_to_be_rollershutter)
36 config_entry: ConfigEntry,
37 async_add_entities: AddEntitiesCallback,
39 """Set up config entry."""
42 event: rfxtrxmod.RFXtrxEvent,
43 auto: rfxtrxmod.RFXtrxEvent |
None,
44 device_id: DeviceTuple,
45 entity_info: dict[str, Any],
51 venetian_blind_mode=entity_info.get(CONF_VENETIAN_BLIND_MODE),
52 event=event
if auto
else None,
57 hass, config_entry, async_add_entities, supported, _constructor
62 """Representation of a RFXtrx cover."""
64 _device: rfxtrxmod.RollerTrolDevice | rfxtrxmod.RfyDevice | rfxtrxmod.LightingDevice
68 device: rfxtrxmod.RFXtrxDevice,
69 device_id: DeviceTuple,
70 event: rfxtrxmod.RFXtrxEvent =
None,
71 venetian_blind_mode: str |
None =
None,
73 """Initialize the RFXtrx cover device."""
74 super().
__init__(device, device_id, event)
79 CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
82 if venetian_blind_mode
in (
83 CONST_VENETIAN_BLIND_MODE_US,
84 CONST_VENETIAN_BLIND_MODE_EU,
87 CoverEntityFeature.OPEN_TILT
88 | CoverEntityFeature.CLOSE_TILT
89 | CoverEntityFeature.STOP_TILT
93 """Restore device state."""
96 if self.
_event_event
is None:
98 if old_state
is not None:
102 """Move the cover up."""
104 await self._async_send(self.
_device_device.send_up05sec)
106 await self._async_send(self.
_device_device.send_up2sec)
108 await self._async_send(self.
_device_device.send_open)
113 """Move the cover down."""
115 await self._async_send(self.
_device_device.send_down05sec)
117 await self._async_send(self.
_device_device.send_down2sec)
119 await self._async_send(self.
_device_device.send_close)
124 """Stop the cover."""
125 await self._async_send(self.
_device_device.send_stop)
130 """Tilt the cover up."""
132 await self._async_send(self.
_device_device.send_up2sec)
134 await self._async_send(self.
_device_device.send_up05sec)
137 """Tilt the cover down."""
139 await self._async_send(self.
_device_device.send_down2sec)
141 await self._async_send(self.
_device_device.send_down05sec)
144 """Stop the cover tilt."""
145 await self._async_send(self.
_device_device.send_stop)
150 """Apply command from rfxtrx."""
151 assert isinstance(event, rfxtrxmod.ControlEvent)
153 if event.values[
"Command"]
in COMMAND_ON_LIST:
155 elif event.values[
"Command"]
in COMMAND_OFF_LIST:
160 self, event: rfxtrxmod.RFXtrxEvent, device_id: DeviceTuple
162 """Check if event applies to me and update."""
None async_open_cover(self, **Any kwargs)
None _apply_event(self, rfxtrxmod.RFXtrxEvent event)
None __init__(self, rfxtrxmod.RFXtrxDevice device, DeviceTuple device_id, rfxtrxmod.RFXtrxEvent event=None, str|None venetian_blind_mode=None)
None async_stop_cover_tilt(self, **Any kwargs)
None async_stop_cover(self, **Any kwargs)
None async_close_cover(self, **Any kwargs)
None async_added_to_hass(self)
None async_open_cover_tilt(self, **Any kwargs)
None async_close_cover_tilt(self, **Any kwargs)
None _handle_event(self, rfxtrxmod.RFXtrxEvent event, DeviceTuple device_id)
None _apply_event(self, rfxtrxmod.RFXtrxEvent event)
None async_write_ha_state(self)
State|None async_get_last_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
bool supported(rfxtrxmod.RFXtrxEvent event)
None async_setup_platform_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities, Callable[[rfxtrxmod.RFXtrxEvent], bool] supported, Callable[[rfxtrxmod.RFXtrxEvent, rfxtrxmod.RFXtrxEvent|None, DeviceTuple, dict[str, Any],], list[Entity],] constructor)