1 """Support for Netatmo/Bubendorff fans."""
3 from __future__
import annotations
6 from typing
import Final
8 from pyatmo
import modules
as NaModules
16 from .const
import CONF_URL_CONTROL, NETATMO_CREATE_FAN
17 from .data_handler
import HOME, SIGNAL_NAME, NetatmoDevice
18 from .entity
import NetatmoModuleEntity
20 _LOGGER = logging.getLogger(__name__)
22 DEFAULT_PERCENTAGE: Final = 50
24 PRESET_MAPPING = {
"slow": 1,
"fast": 2}
25 PRESETS = {v: k
for k, v
in PRESET_MAPPING.items()}
31 async_add_entities: AddEntitiesCallback,
33 """Set up the Netatmo fan platform."""
36 def _create_entity(netatmo_device: NetatmoDevice) ->
None:
38 _LOGGER.debug(
"Adding cover %s", entity)
41 entry.async_on_unload(
47 """Representation of a Netatmo fan."""
49 _attr_preset_modes = [
"slow",
"fast"]
50 _attr_supported_features = FanEntityFeature.PRESET_MODE
51 _attr_configuration_url = CONF_URL_CONTROL
54 _enable_turn_on_off_backwards_compatibility =
False
56 def __init__(self, netatmo_device: NetatmoDevice) ->
None:
57 """Initialize of Netatmo fan."""
59 self._publishers.extend(
63 "home_id": self.
homehome.entity_id,
64 SIGNAL_NAME: f
"{HOME}-{self.home.entity_id}",
69 self.
_attr_unique_id_attr_unique_id = f
"{self.device.entity_id}-{self.device_type}"
72 """Set the preset mode of the fan."""
73 await self.
devicedevice.async_set_fan_speed(PRESET_MAPPING[preset_mode])
77 """Update the entity's state."""
78 if self.
devicedevice.fan_speed
is None:
None async_update_callback(self)
None async_set_preset_mode(self, str preset_mode)
None __init__(self, NetatmoDevice netatmo_device)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)