From 99a65fb45b764d3e1a8ded161ede4fbf135be579 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 30 Aug 2023 23:57:23 +0200 Subject: [PATCH] Collapse supported features list in Deconz (#99233) * Use shorthand attributes for Deconz * revert changes --- homeassistant/components/deconz/cover.py | 20 ++++++++++++-------- homeassistant/components/deconz/fan.py | 7 +------ homeassistant/components/deconz/light.py | 5 +++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/deconz/cover.py b/homeassistant/components/deconz/cover.py index 3eac9cafd52..012f064dd07 100644 --- a/homeassistant/components/deconz/cover.py +++ b/homeassistant/components/deconz/cover.py @@ -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) diff --git a/homeassistant/components/deconz/fan.py b/homeassistant/components/deconz/fan.py index a0d62126b92..278d702d63b 100644 --- a/homeassistant/components/deconz/fan.py +++ b/homeassistant/components/deconz/fan.py @@ -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.""" diff --git a/homeassistant/components/deconz/light.py b/homeassistant/components/deconz/light.py index 46d10a77271..47ca1eda0d8 100644 --- a/homeassistant/components/deconz/light.py +++ b/homeassistant/components/deconz/light.py @@ -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