1 """Support for KNX/IP covers."""
3 from __future__
import annotations
5 from collections.abc
import Callable
8 from xknx.devices
import Cover
as XknxCover
10 from homeassistant
import config_entries
28 from .
import KNXModule
29 from .const
import KNX_MODULE_KEY
30 from .entity
import KnxYamlEntity
31 from .schema
import CoverSchema
37 async_add_entities: AddEntitiesCallback,
39 """Set up cover(s) for KNX platform."""
40 knx_module = hass.data[KNX_MODULE_KEY]
41 config: list[ConfigType] = knx_module.config_yaml[Platform.COVER]
47 """Representation of a KNX cover."""
51 def __init__(self, knx_module: KNXModule, config: ConfigType) ->
None:
52 """Initialize the cover."""
54 knx_module=knx_module,
57 name=config[CONF_NAME],
58 group_address_long=config.get(CoverSchema.CONF_MOVE_LONG_ADDRESS),
59 group_address_short=config.get(CoverSchema.CONF_MOVE_SHORT_ADDRESS),
60 group_address_stop=config.get(CoverSchema.CONF_STOP_ADDRESS),
61 group_address_position_state=config.get(
62 CoverSchema.CONF_POSITION_STATE_ADDRESS
64 group_address_angle=config.get(CoverSchema.CONF_ANGLE_ADDRESS),
65 group_address_angle_state=config.get(
66 CoverSchema.CONF_ANGLE_STATE_ADDRESS
68 group_address_position=config.get(CoverSchema.CONF_POSITION_ADDRESS),
69 travel_time_down=config[CoverSchema.CONF_TRAVELLING_TIME_DOWN],
70 travel_time_up=config[CoverSchema.CONF_TRAVELLING_TIME_UP],
71 invert_updown=config[CoverSchema.CONF_INVERT_UPDOWN],
72 invert_position=config[CoverSchema.CONF_INVERT_POSITION],
73 invert_angle=config[CoverSchema.CONF_INVERT_ANGLE],
76 self._unsubscribe_auto_updater: Callable[[],
None] |
None =
None
79 _supports_tilt =
False
81 CoverEntityFeature.CLOSE
82 | CoverEntityFeature.OPEN
83 | CoverEntityFeature.SET_POSITION
85 if self.
_device_device.step.writable:
88 CoverEntityFeature.CLOSE_TILT
89 | CoverEntityFeature.OPEN_TILT
90 | CoverEntityFeature.STOP_TILT
92 if self.
_device_device.supports_angle:
95 if self.
_device_device.supports_stop:
101 CoverDeviceClass.BLIND
if _supports_tilt
else None
104 f
"{self._device.updown.group_address}_"
105 f
"{self._device.position_target.group_address}"
110 """Return the current position of the cover.
112 None is unknown, 0 is closed, 100 is fully open.
115 if (pos := self.
_device_device.current_position())
is not None:
121 """Return if the cover is closed."""
123 if self.
_device_device.current_position()
is None:
129 """Return if the cover is opening or not."""
134 """Return if the cover is closing or not."""
138 """Close the cover."""
139 await self.
_device_device.set_down()
142 """Open the cover."""
143 await self.
_device_device.set_up()
146 """Move the cover to a specific position."""
147 knx_position = 100 - kwargs[ATTR_POSITION]
148 await self.
_device_device.set_position(knx_position)
151 """Stop the cover."""
152 await self.
_device_device.stop()
156 """Return current tilt position of cover."""
157 if (angle := self.
_device_device.current_angle())
is not None:
162 """Move the cover tilt to a specific position."""
163 knx_tilt_position = 100 - kwargs[ATTR_TILT_POSITION]
164 await self.
_device_device.set_angle(knx_tilt_position)
167 """Open the cover tilt."""
168 if self.
_device_device.angle.writable:
169 await self.
_device_device.set_angle(0)
171 await self.
_device_device.set_short_up()
174 """Close the cover tilt."""
175 if self.
_device_device.angle.writable:
176 await self.
_device_device.set_angle(100)
178 await self.
_device_device.set_short_down()
181 """Stop the cover tilt."""
182 await self.
_device_device.stop()
current_cover_tilt_position
None async_set_cover_tilt_position(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
None __init__(self, KNXModule knx_module, ConfigType config)
None async_close_cover_tilt(self, **Any kwargs)
bool|None is_closed(self)
None async_stop_cover_tilt(self, **Any kwargs)
None async_stop_cover(self, **Any kwargs)
None async_open_cover_tilt(self, **Any kwargs)
None async_close_cover(self, **Any kwargs)
None async_set_cover_position(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, config_entries.ConfigEntry config_entry, AddEntitiesCallback async_add_entities)