1 """Support for Lutron Caseta fans."""
3 from __future__
import annotations
7 from pylutron_caseta
import FAN_HIGH, FAN_LOW, FAN_MEDIUM, FAN_MEDIUM_HIGH, FAN_OFF
17 ordered_list_item_to_percentage,
18 percentage_to_ordered_list_item,
21 from .entity
import LutronCasetaUpdatableEntity
22 from .models
import LutronCasetaConfigEntry
24 DEFAULT_ON_PERCENTAGE = 50
25 ORDERED_NAMED_FAN_SPEEDS = [FAN_LOW, FAN_MEDIUM, FAN_MEDIUM_HIGH, FAN_HIGH]
30 config_entry: LutronCasetaConfigEntry,
31 async_add_entities: AddEntitiesCallback,
33 """Set up the Lutron Caseta fan platform.
35 Adds fan controllers from the Caseta bridge associated with the config_entry
38 data = config_entry.runtime_data
40 fan_devices = bridge.get_devices_by_domain(FAN_DOMAIN)
45 """Representation of a Lutron Caseta fan. Including Fan Speed."""
47 _attr_supported_features = (
48 FanEntityFeature.SET_SPEED
49 | FanEntityFeature.TURN_OFF
50 | FanEntityFeature.TURN_ON
52 _attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
53 _enable_turn_on_off_backwards_compatibility =
False
57 """Return the current speed percentage."""
62 return ordered_list_item_to_percentage(
68 percentage: int |
None =
None,
69 preset_mode: str |
None =
None,
72 """Turn the fan on."""
73 if percentage
is None:
74 percentage = DEFAULT_ON_PERCENTAGE
79 """Turn the fan off."""
83 """Set the speed of the fan."""
87 named_speed = percentage_to_ordered_list_item(
88 ORDERED_NAMED_FAN_SPEEDS, percentage
95 """Return true if device is on."""
int|None percentage(self)
None async_set_percentage(self, int percentage)
int|None percentage(self)
None async_set_percentage(self, int percentage)
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, int|None percentage=None, str|None preset_mode=None, **Any kwargs)
None async_setup_entry(HomeAssistant hass, LutronCasetaConfigEntry config_entry, AddEntitiesCallback async_add_entities)