mirror of
https://github.com/home-assistant/core
synced 2024-07-15 09:42:11 +02:00
Use more shorthand attrs in bond fan (#106740)
This commit is contained in:
parent
1849d68e78
commit
969f9e2e3f
@ -72,6 +72,14 @@ class BondFan(BondEntity, FanEntity):
|
||||
super().__init__(hub, device, bpup_subs)
|
||||
if self._device.has_action(Action.BREEZE_ON):
|
||||
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:
|
||||
state = self._device.state
|
||||
@ -81,18 +89,6 @@ class BondFan(BondEntity, FanEntity):
|
||||
breeze = state.get("breeze", [0, 0, 0])
|
||||
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
|
||||
def _speed_range(self) -> tuple[int, int]:
|
||||
"""Return the range of speeds."""
|
||||
|
Loading…
Reference in New Issue
Block a user