1 """Support for Big Ass Fans fan."""
3 from __future__
import annotations
8 from aiobafi6
import OffOnAuto
19 percentage_to_ranged_value,
20 ranged_value_to_percentage,
23 from .
import BAFConfigEntry
24 from .const
import PRESET_MODE_AUTO, SPEED_COUNT, SPEED_RANGE
25 from .entity
import BAFEntity
30 entry: BAFConfigEntry,
31 async_add_entities: AddEntitiesCallback,
33 """Set up SenseME fans."""
34 device = entry.runtime_data
40 """BAF ceiling fan component."""
42 _attr_supported_features = (
43 FanEntityFeature.SET_SPEED
44 | FanEntityFeature.DIRECTION
45 | FanEntityFeature.PRESET_MODE
46 | FanEntityFeature.TURN_OFF
47 | FanEntityFeature.TURN_ON
49 _enable_turn_on_off_backwards_compatibility =
False
50 _attr_preset_modes = [PRESET_MODE_AUTO]
51 _attr_speed_count = SPEED_COUNT
53 _attr_translation_key =
"baf"
57 """Update attrs from device."""
60 if self.
_device_device.reverse_enable:
62 if self.
_device_device.speed
is not None:
64 SPEED_RANGE, self.
_device_device.speed
68 auto = self.
_device_device.fan_mode == OffOnAuto.AUTO
73 """Set the speed of the fan, as a percentage."""
75 if device.fan_mode != OffOnAuto.ON:
76 device.fan_mode = OffOnAuto.ON
81 percentage: int |
None =
None,
82 preset_mode: str |
None =
None,
85 """Turn the fan on with a percentage or preset mode."""
86 if preset_mode
is not None:
89 if percentage
is None:
90 self.
_device_device.fan_mode = OffOnAuto.ON
95 """Turn the fan off."""
96 self.
_device_device.fan_mode = OffOnAuto.OFF
99 """Set the preset mode of the fan."""
100 self.
_device_device.fan_mode = OffOnAuto.AUTO
103 """Set the direction of the fan."""
104 self.
_device_device.reverse_enable = direction == DIRECTION_REVERSE
None async_set_preset_mode(self, str preset_mode)
None async_turn_off(self, **Any kwargs)
None async_set_percentage(self, int percentage)
None _async_update_attrs(self)
None async_turn_on(self, int|None percentage=None, str|None preset_mode=None, **Any kwargs)
None async_set_direction(self, str direction)
None async_set_percentage(self, int percentage)
None async_set_preset_mode(self, str preset_mode)
None async_setup_entry(HomeAssistant hass, BAFConfigEntry entry, AddEntitiesCallback async_add_entities)
float percentage_to_ranged_value(tuple[float, float] low_high_range, float percentage)
int ranged_value_to_percentage(tuple[float, float] low_high_range, float value)