1 """BleBox cover entity."""
3 from __future__
import annotations
21 from .
import BleBoxConfigEntry
22 from .entity
import BleBoxEntity
24 BLEBOX_TO_COVER_DEVICE_CLASSES = {
25 "gate": CoverDeviceClass.GATE,
26 "gatebox": CoverDeviceClass.DOOR,
27 "shutter": CoverDeviceClass.SHUTTER,
30 BLEBOX_TO_HASS_COVER_STATES = {
33 BleboxCoverState.MOVING_DOWN: CoverState.CLOSING,
34 BleboxCoverState.MOVING_UP: CoverState.OPENING,
35 BleboxCoverState.MANUALLY_STOPPED: CoverState.OPEN,
36 BleboxCoverState.LOWER_LIMIT_REACHED: CoverState.CLOSED,
37 BleboxCoverState.UPPER_LIMIT_REACHED: CoverState.OPEN,
39 BleboxCoverState.OVERLOAD: CoverState.OPEN,
40 BleboxCoverState.MOTOR_FAILURE: CoverState.OPEN,
41 BleboxCoverState.SAFETY_STOP: CoverState.OPEN,
47 config_entry: BleBoxConfigEntry,
48 async_add_entities: AddEntitiesCallback,
50 """Set up a BleBox entry."""
53 for feature
in config_entry.runtime_data.features.get(
"covers", [])
59 """Representation of a BleBox cover feature."""
61 def __init__(self, feature: blebox_uniapi.cover.Cover) ->
None:
62 """Initialize a BleBox cover feature."""
66 CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
76 CoverEntityFeature.SET_TILT_POSITION
77 | CoverEntityFeature.OPEN_TILT
78 | CoverEntityFeature.CLOSE_TILT
83 """Return the current cover position."""
84 position = self._feature.current
88 return None if position
is None else 100 - position
92 """Return the current tilt of shutter."""
93 position = self._feature.tilt_current
94 return None if position
is None else 100 - position
98 """Return whether cover is opening."""
99 return self.
_is_state_is_state(CoverState.OPENING)
103 """Return whether cover is closing."""
104 return self.
_is_state_is_state(CoverState.CLOSING)
108 """Return whether cover is closed."""
109 return self.
_is_state_is_state(CoverState.CLOSED)
112 """Fully open the cover position."""
113 await self._feature.async_open()
116 """Fully close the cover position."""
117 await self._feature.async_close()
120 """Fully open the cover tilt."""
121 await self._feature.async_set_tilt_position(0)
124 """Fully close the cover tilt."""
126 await self._feature.async_set_tilt_position(100)
129 """Set the cover position."""
130 position = kwargs[ATTR_POSITION]
131 await self._feature.async_set_position(100 - position)
134 """Stop the cover."""
138 """Set the tilt position."""
139 position = kwargs[ATTR_TILT_POSITION]
140 await self._feature.async_set_tilt_position(100 - position)
143 value = BLEBOX_TO_HASS_COVER_STATES[self._feature.state]
144 return None if value
is None else value == state_name
None async_open_cover_tilt(self, **Any kwargs)
None async_set_cover_position(self, **Any kwargs)
None async_close_cover_tilt(self, **Any kwargs)
bool|None is_closed(self)
bool|None is_closing(self)
None __init__(self, blebox_uniapi.cover.Cover feature)
bool|None _is_state(self, state_name)
None async_close_cover(self, **Any kwargs)
None async_set_cover_tilt_position(self, **Any kwargs)
None async_stop_cover(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
bool|None is_opening(self)
current_cover_tilt_position
None async_setup_entry(HomeAssistant hass, BleBoxConfigEntry config_entry, AddEntitiesCallback async_add_entities)
None async_stop(HomeAssistant hass)