1 """Support for Big Ass Fans number."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
7 from typing
import cast
9 from aiobafi6
import Device
13 NumberEntityDescription,
20 from .
import BAFConfigEntry
21 from .const
import HALF_DAY_SECS, ONE_DAY_SECS, ONE_MIN_SECS, SPEED_RANGE
22 from .entity
import BAFDescriptionEntity
25 @dataclass(frozen=True, kw_only=True)
27 """Class describing BAF sensor entities."""
29 value_fn: Callable[[Device], int |
None]
32 AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
34 key=
"comfort_min_speed",
35 translation_key=
"comfort_min_speed",
38 native_max_value=SPEED_RANGE[1] - 1,
39 entity_category=EntityCategory.CONFIG,
40 value_fn=
lambda device: cast(int |
None, device.comfort_min_speed),
44 key=
"comfort_max_speed",
45 translation_key=
"comfort_max_speed",
48 native_max_value=SPEED_RANGE[1],
49 entity_category=EntityCategory.CONFIG,
50 value_fn=
lambda device: cast(int |
None, device.comfort_max_speed),
54 key=
"comfort_heat_assist_speed",
55 translation_key=
"comfort_heat_assist_speed",
57 native_min_value=SPEED_RANGE[0],
58 native_max_value=SPEED_RANGE[1],
59 entity_category=EntityCategory.CONFIG,
60 value_fn=
lambda device: cast(int |
None, device.comfort_heat_assist_speed),
65 FAN_NUMBER_DESCRIPTIONS = (
67 key=
"return_to_auto_timeout",
68 translation_key=
"return_to_auto_timeout",
70 native_min_value=ONE_MIN_SECS,
71 native_max_value=HALF_DAY_SECS,
72 entity_category=EntityCategory.CONFIG,
73 native_unit_of_measurement=UnitOfTime.SECONDS,
74 value_fn=
lambda device: cast(int |
None, device.return_to_auto_timeout),
75 mode=NumberMode.SLIDER,
78 key=
"motion_sense_timeout",
79 translation_key=
"motion_sense_timeout",
81 native_min_value=ONE_MIN_SECS,
82 native_max_value=ONE_DAY_SECS,
83 entity_category=EntityCategory.CONFIG,
84 native_unit_of_measurement=UnitOfTime.SECONDS,
85 value_fn=
lambda device: cast(int |
None, device.motion_sense_timeout),
86 mode=NumberMode.SLIDER,
90 LIGHT_NUMBER_DESCRIPTIONS = (
92 key=
"light_return_to_auto_timeout",
93 translation_key=
"light_return_to_auto_timeout",
95 native_min_value=ONE_MIN_SECS,
96 native_max_value=HALF_DAY_SECS,
97 entity_category=EntityCategory.CONFIG,
98 native_unit_of_measurement=UnitOfTime.SECONDS,
99 value_fn=
lambda device: cast(int |
None, device.light_return_to_auto_timeout),
100 mode=NumberMode.SLIDER,
103 key=
"light_auto_motion_timeout",
104 translation_key=
"light_auto_motion_timeout",
106 native_min_value=ONE_MIN_SECS,
107 native_max_value=ONE_DAY_SECS,
108 entity_category=EntityCategory.CONFIG,
109 native_unit_of_measurement=UnitOfTime.SECONDS,
110 value_fn=
lambda device: cast(int |
None, device.light_auto_motion_timeout),
111 mode=NumberMode.SLIDER,
118 entry: BAFConfigEntry,
119 async_add_entities: AddEntitiesCallback,
121 """Set up BAF numbers."""
122 device = entry.runtime_data
123 descriptions: list[BAFNumberDescription] = []
125 descriptions.extend(FAN_NUMBER_DESCRIPTIONS)
127 descriptions.extend(LIGHT_NUMBER_DESCRIPTIONS)
128 if device.has_auto_comfort:
129 descriptions.extend(AUTO_COMFORT_NUMBER_DESCRIPTIONS)
136 entity_description: BAFNumberDescription
140 """Update attrs from device."""
None async_set_native_value(self, float value)
None _async_update_attrs(self)
None async_setup_entry(HomeAssistant hass, BAFConfigEntry entry, AddEntitiesCallback async_add_entities)