1 """Support for Big Ass Fans switch."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
7 from typing
import Any, cast
9 from aiobafi6
import Device
16 from .
import BAFConfigEntry
17 from .entity
import BAFDescriptionEntity
20 @dataclass(frozen=True, kw_only=True)
22 SwitchEntityDescription,
24 """Class describing BAF switch entities."""
26 value_fn: Callable[[Device], bool |
None]
31 key=
"legacy_ir_remote_enable",
32 translation_key=
"legacy_ir_remote_enable",
33 entity_category=EntityCategory.CONFIG,
34 value_fn=
lambda device: cast(bool |
None, device.legacy_ir_remote_enable),
37 key=
"led_indicators_enable",
38 translation_key=
"led_indicators_enable",
39 entity_category=EntityCategory.CONFIG,
40 value_fn=
lambda device: cast(bool |
None, device.led_indicators_enable),
44 AUTO_COMFORT_SWITCHES = [
46 key=
"comfort_heat_assist_enable",
47 translation_key=
"comfort_heat_assist_enable",
48 entity_category=EntityCategory.CONFIG,
49 value_fn=
lambda device: cast(bool |
None, device.comfort_heat_assist_enable),
55 key=
"fan_beep_enable",
56 translation_key=
"fan_beep_enable",
57 entity_category=EntityCategory.CONFIG,
58 value_fn=
lambda device: cast(bool |
None, device.fan_beep_enable),
62 translation_key=
"eco_enable",
63 entity_category=EntityCategory.CONFIG,
64 value_fn=
lambda device: cast(bool |
None, device.eco_enable),
67 key=
"motion_sense_enable",
68 translation_key=
"motion_sense_enable",
69 entity_category=EntityCategory.CONFIG,
70 value_fn=
lambda device: cast(bool |
None, device.motion_sense_enable),
73 key=
"return_to_auto_enable",
74 translation_key=
"return_to_auto_enable",
75 entity_category=EntityCategory.CONFIG,
76 value_fn=
lambda device: cast(bool |
None, device.return_to_auto_enable),
80 translation_key=
"whoosh_enable",
82 value_fn=
lambda device: cast(bool |
None, device.whoosh_enable),
89 key=
"light_dim_to_warm_enable",
90 translation_key=
"light_dim_to_warm_enable",
91 entity_category=EntityCategory.CONFIG,
92 value_fn=
lambda device: cast(bool |
None, device.light_dim_to_warm_enable),
95 key=
"light_return_to_auto_enable",
96 translation_key=
"light_return_to_auto_enable",
97 entity_category=EntityCategory.CONFIG,
98 value_fn=
lambda device: cast(bool |
None, device.light_return_to_auto_enable),
105 entry: BAFConfigEntry,
106 async_add_entities: AddEntitiesCallback,
108 """Set up BAF fan switches."""
109 device = entry.runtime_data
110 descriptions: list[BAFSwitchDescription] = []
111 descriptions.extend(BASE_SWITCHES)
113 descriptions.extend(FAN_SWITCHES)
115 descriptions.extend(LIGHT_SWITCHES)
116 if device.has_auto_comfort:
117 descriptions.extend(AUTO_COMFORT_SWITCHES)
122 """BAF switch component."""
124 entity_description: BAFSwitchDescription
128 """Update attrs from device."""
132 """Turn on the switch."""
136 """Turn off the switch."""
None async_turn_on(self, **Any kwargs)
None _async_update_attrs(self)
None async_turn_off(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, BAFConfigEntry entry, AddEntitiesCallback async_add_entities)