Collapse supported features list in Deconz (#99233)

* Use shorthand attributes for Deconz

* revert changes
This commit is contained in:
Joost Lekkerkerker 2023-08-30 23:57:23 +02:00 committed by GitHub
parent cc9f0aaf80
commit 99a65fb45b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 16 deletions

View file

@ -59,16 +59,20 @@ class DeconzCover(DeconzDevice[Cover], CoverEntity):
"""Set up cover device."""
super().__init__(cover := gateway.api.lights.covers[cover_id], gateway)
self._attr_supported_features = CoverEntityFeature.OPEN
self._attr_supported_features |= CoverEntityFeature.CLOSE
self._attr_supported_features |= CoverEntityFeature.STOP
self._attr_supported_features |= CoverEntityFeature.SET_POSITION
self._attr_supported_features = (
CoverEntityFeature.OPEN
| CoverEntityFeature.CLOSE
| CoverEntityFeature.STOP
| CoverEntityFeature.SET_POSITION
)
if self._device.tilt is not None:
self._attr_supported_features |= CoverEntityFeature.OPEN_TILT
self._attr_supported_features |= CoverEntityFeature.CLOSE_TILT
self._attr_supported_features |= CoverEntityFeature.STOP_TILT
self._attr_supported_features |= CoverEntityFeature.SET_TILT_POSITION
self._attr_supported_features |= (
CoverEntityFeature.OPEN_TILT
| CoverEntityFeature.CLOSE_TILT
| CoverEntityFeature.STOP_TILT
| CoverEntityFeature.SET_TILT_POSITION
)
self._attr_device_class = DECONZ_TYPE_TO_DEVICE_CLASS.get(cover.type)

View file

@ -60,7 +60,7 @@ class DeconzFan(DeconzDevice[Light], FanEntity):
def __init__(self, device: Light, gateway: DeconzGateway) -> None:
"""Set up fan."""
super().__init__(device, gateway)
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
if device.fan_speed in ORDERED_NAMED_FAN_SPEEDS:
self._default_on_speed = device.fan_speed
@ -80,11 +80,6 @@ class DeconzFan(DeconzDevice[Light], FanEntity):
ORDERED_NAMED_FAN_SPEEDS, self._device.fan_speed
)
@property
def speed_count(self) -> int:
"""Return the number of speeds the fan supports."""
return len(ORDERED_NAMED_FAN_SPEEDS)
@callback
def async_update_callback(self) -> None:
"""Store latest configured speed from the device."""

View file

@ -154,8 +154,9 @@ class DeconzBaseLight(DeconzDevice[_LightDeviceT], LightEntity):
self._attr_supported_color_modes.add(ColorMode.ONOFF)
if device.brightness is not None:
self._attr_supported_features |= LightEntityFeature.FLASH
self._attr_supported_features |= LightEntityFeature.TRANSITION
self._attr_supported_features |= (
LightEntityFeature.FLASH | LightEntityFeature.TRANSITION
)
if device.effect is not None:
self._attr_supported_features |= LightEntityFeature.EFFECT