1 """Demo fan platform that has a fake fan."""
3 from __future__
import annotations
12 PRESET_MODE_AUTO =
"auto"
13 PRESET_MODE_SMART =
"smart"
14 PRESET_MODE_SLEEP =
"sleep"
18 FanEntityFeature.SET_SPEED
19 | FanEntityFeature.OSCILLATE
20 | FanEntityFeature.DIRECTION
21 | FanEntityFeature.TURN_OFF
22 | FanEntityFeature.TURN_ON
25 FanEntityFeature.SET_SPEED | FanEntityFeature.TURN_OFF | FanEntityFeature.TURN_ON
31 config_entry: ConfigEntry,
32 async_add_entities: AddEntitiesCallback,
34 """Set up the Demo config entry."""
59 "Percentage Full Fan",
71 "Percentage Limited Fan",
83 "Preset Only Limited Fan",
84 FanEntityFeature.PRESET_MODE
85 | FanEntityFeature.TURN_OFF
86 | FanEntityFeature.TURN_ON,
99 """A demonstration fan component that uses legacy fan speeds."""
101 _attr_should_poll =
False
102 _attr_translation_key =
"demo"
103 _enable_turn_on_off_backwards_compatibility =
False
110 supported_features: FanEntityFeature,
111 preset_modes: list[str] |
None,
113 """Initialize the entity."""
117 self._percentage: int |
None =
None
119 self._preset_mode: str |
None =
None
123 if supported_features & FanEntityFeature.OSCILLATE:
125 if supported_features & FanEntityFeature.DIRECTION:
130 """Return the unique id."""
145 """A demonstration fan component that uses percentages."""
149 """Return the current speed."""
154 """Return the number of speeds the fan supports."""
158 """Set the speed of the fan, as a percentage."""
165 """Return the current preset mode, e.g., auto, smart, interval, favorite."""
170 """Return a list of available preset modes."""
174 """Set new preset mode."""
181 percentage: int |
None =
None,
182 preset_mode: str |
None =
None,
185 """Turn on the entity."""
190 if percentage
is None:
196 """Turn off the entity."""
200 """Set the direction of the fan."""
205 """Set oscillation."""
211 """An async demonstration fan component that uses percentages."""
215 """Return the current speed."""
220 """Return the number of speeds the fan supports."""
224 """Set the speed of the fan, as a percentage."""
231 """Return the current preset mode, e.g., auto, smart, interval, favorite."""
236 """Return a list of available preset modes."""
240 """Set new preset mode."""
247 percentage: int |
None =
None,
248 preset_mode: str |
None =
None,
251 """Turn on the entity."""
256 if percentage
is None:
262 """Turn off the entity."""
267 """Set the direction of the fan."""
272 """Set oscillation."""
None async_set_preset_mode(self, str preset_mode)
list[str]|None preset_modes(self)
None async_set_direction(self, str direction)
None async_oscillate(self, bool oscillating)
str|None preset_mode(self)
None async_set_percentage(self, int percentage)
int|None percentage(self)
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, int|None percentage=None, str|None preset_mode=None, **Any kwargs)
str|None current_direction(self)
None __init__(self, HomeAssistant hass, str unique_id, str name, FanEntityFeature supported_features, list[str]|None preset_modes)
bool|None oscillating(self)
None turn_on(self, int|None percentage=None, str|None preset_mode=None, **Any kwargs)
None turn_off(self, **Any kwargs)
str|None preset_mode(self)
list[str]|None preset_modes(self)
int|None percentage(self)
None set_percentage(self, int percentage)
None oscillate(self, bool oscillating)
None set_preset_mode(self, str preset_mode)
None set_direction(self, str direction)
None set_preset_mode(self, str preset_mode)
None set_percentage(self, int percentage)
None async_set_percentage(self, int percentage)
None async_set_preset_mode(self, str preset_mode)
None async_oscillate(self, bool oscillating)
None async_write_ha_state(self)
None schedule_update_ha_state(self, bool force_refresh=False)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)