mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 05:05:09 +02:00
Use more shorthand attrs in bond fan (#106740)
This commit is contained in:
@@ -72,6 +72,14 @@ class BondFan(BondEntity, FanEntity):
|
|||||||
super().__init__(hub, device, bpup_subs)
|
super().__init__(hub, device, bpup_subs)
|
||||||
if self._device.has_action(Action.BREEZE_ON):
|
if self._device.has_action(Action.BREEZE_ON):
|
||||||
self._attr_preset_modes = [PRESET_MODE_BREEZE]
|
self._attr_preset_modes = [PRESET_MODE_BREEZE]
|
||||||
|
features = FanEntityFeature(0)
|
||||||
|
if self._device.supports_speed():
|
||||||
|
features |= FanEntityFeature.SET_SPEED
|
||||||
|
if self._device.supports_direction():
|
||||||
|
features |= FanEntityFeature.DIRECTION
|
||||||
|
if self._device.has_action(Action.BREEZE_ON):
|
||||||
|
features |= FanEntityFeature.PRESET_MODE
|
||||||
|
self._attr_supported_features = features
|
||||||
|
|
||||||
def _apply_state(self) -> None:
|
def _apply_state(self) -> None:
|
||||||
state = self._device.state
|
state = self._device.state
|
||||||
@@ -81,18 +89,6 @@ class BondFan(BondEntity, FanEntity):
|
|||||||
breeze = state.get("breeze", [0, 0, 0])
|
breeze = state.get("breeze", [0, 0, 0])
|
||||||
self._attr_preset_mode = PRESET_MODE_BREEZE if breeze[0] else None
|
self._attr_preset_mode = PRESET_MODE_BREEZE if breeze[0] else None
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> FanEntityFeature:
|
|
||||||
"""Flag supported features."""
|
|
||||||
features = FanEntityFeature(0)
|
|
||||||
if self._device.supports_speed():
|
|
||||||
features |= FanEntityFeature.SET_SPEED
|
|
||||||
if self._device.supports_direction():
|
|
||||||
features |= FanEntityFeature.DIRECTION
|
|
||||||
if self._device.has_action(Action.BREEZE_ON):
|
|
||||||
features |= FanEntityFeature.PRESET_MODE
|
|
||||||
return features
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _speed_range(self) -> tuple[int, int]:
|
def _speed_range(self) -> tuple[int, int]:
|
||||||
"""Return the range of speeds."""
|
"""Return the range of speeds."""
|
||||||
|
Reference in New Issue
Block a user