1 """Fan support for switch entities."""
3 from __future__
import annotations
18 from .entity
import BaseToggleEntity
23 config_entry: ConfigEntry,
24 async_add_entities: AddEntitiesCallback,
26 """Initialize Fan Switch config entry."""
27 registry = er.async_get(hass)
28 entity_id = er.async_validate_entity_id(
29 registry, config_entry.options[CONF_ENTITY_ID]
39 config_entry.entry_id,
46 """Represents a Switch as a Fan."""
48 _attr_supported_features = FanEntityFeature.TURN_OFF | FanEntityFeature.TURN_ON
49 _enable_turn_on_off_backwards_compatibility =
False
53 """Return true if the entity is on.
55 Fan logic uses speed percentage or preset mode to determine
56 if it's on or off, however, when using a wrapped switch, we
57 just use the wrapped switch's state.
63 percentage: int |
None =
None,
64 preset_mode: str |
None =
None,
69 Arguments of the turn_on methods fan entity differ,
70 thus we need to override them here.
None async_turn_on(self, int|None percentage=None, str|None preset_mode=None, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)