Only flag SUPPORT_STOP_TILT when tilt available in KNX cover (#64410)

This commit is contained in:
Matthias Alphart 2022-01-19 21:35:36 +01:00 committed by GitHub
parent 53f8225f90
commit b245a0d0ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,22 +80,28 @@ class KNXCover(KnxEntity, CoverEntity):
)
)
self._unsubscribe_auto_updater: Callable[[], None] | None = None
self._attr_entity_category = config.get(CONF_ENTITY_CATEGORY)
self._attr_device_class = config.get(CONF_DEVICE_CLASS) or (
CoverDeviceClass.BLIND if self._device.supports_angle else None
)
self._attr_entity_category = config.get(CONF_ENTITY_CATEGORY)
_supports_tilt = False
self._attr_supported_features = (
SUPPORT_CLOSE | SUPPORT_OPEN | SUPPORT_SET_POSITION
)
if self._device.supports_stop:
self._attr_supported_features |= SUPPORT_STOP | SUPPORT_STOP_TILT
if self._device.supports_angle:
self._attr_supported_features |= SUPPORT_SET_TILT_POSITION
if self._device.step.writable:
_supports_tilt = True
self._attr_supported_features |= (
SUPPORT_CLOSE_TILT | SUPPORT_OPEN_TILT | SUPPORT_STOP_TILT
)
if self._device.supports_angle:
_supports_tilt = True
self._attr_supported_features |= SUPPORT_SET_TILT_POSITION
if self._device.supports_stop:
self._attr_supported_features |= SUPPORT_STOP
if _supports_tilt:
self._attr_supported_features |= SUPPORT_STOP_TILT
self._attr_device_class = config.get(CONF_DEVICE_CLASS) or (
CoverDeviceClass.BLIND if _supports_tilt else None
)
self._attr_unique_id = (
f"{self._device.updown.group_address}_"
f"{self._device.position_target.group_address}"