1 """Platform for eq3 number entities."""
3 from collections.abc
import Awaitable, Callable
4 from dataclasses
import dataclass
5 from typing
import TYPE_CHECKING
7 from eq3btsmart
import Thermostat
8 from eq3btsmart.const
import (
14 from eq3btsmart.models
import Presets
19 NumberEntityDescription,
26 from .
import Eq3ConfigEntry
31 ENTITY_KEY_WINDOW_OPEN_TEMPERATURE,
32 ENTITY_KEY_WINDOW_OPEN_TIMEOUT,
35 from .entity
import Eq3Entity
38 @dataclass(frozen=True, kw_only=True)
40 """Entity description for eq3 number entities."""
42 value_func: Callable[[Presets], float]
43 value_set_func: Callable[
45 Callable[[float], Awaitable[
None]],
47 mode: NumberMode = NumberMode.BOX
48 entity_category: EntityCategory |
None = EntityCategory.CONFIG
51 NUMBER_ENTITY_DESCRIPTIONS = [
53 key=ENTITY_KEY_COMFORT,
54 value_func=
lambda presets: presets.comfort_temperature.value,
55 value_set_func=
lambda thermostat: thermostat.async_configure_comfort_temperature,
56 translation_key=ENTITY_KEY_COMFORT,
57 native_min_value=EQ3BT_MIN_TEMP,
58 native_max_value=EQ3BT_MAX_TEMP,
59 native_step=EQ3BT_STEP,
60 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
61 device_class=NumberDeviceClass.TEMPERATURE,
65 value_func=
lambda presets: presets.eco_temperature.value,
66 value_set_func=
lambda thermostat: thermostat.async_configure_eco_temperature,
67 translation_key=ENTITY_KEY_ECO,
68 native_min_value=EQ3BT_MIN_TEMP,
69 native_max_value=EQ3BT_MAX_TEMP,
70 native_step=EQ3BT_STEP,
71 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
72 device_class=NumberDeviceClass.TEMPERATURE,
75 key=ENTITY_KEY_WINDOW_OPEN_TEMPERATURE,
76 value_func=
lambda presets: presets.window_open_temperature.value,
77 value_set_func=
lambda thermostat: thermostat.async_configure_window_open_temperature,
78 translation_key=ENTITY_KEY_WINDOW_OPEN_TEMPERATURE,
79 native_min_value=EQ3BT_MIN_TEMP,
80 native_max_value=EQ3BT_MAX_TEMP,
81 native_step=EQ3BT_STEP,
82 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
83 device_class=NumberDeviceClass.TEMPERATURE,
86 key=ENTITY_KEY_OFFSET,
87 value_func=
lambda presets: presets.offset_temperature.value,
88 value_set_func=
lambda thermostat: thermostat.async_configure_temperature_offset,
89 translation_key=ENTITY_KEY_OFFSET,
90 native_min_value=EQ3BT_MIN_OFFSET,
91 native_max_value=EQ3BT_MAX_OFFSET,
92 native_step=EQ3BT_STEP,
93 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
94 device_class=NumberDeviceClass.TEMPERATURE,
97 key=ENTITY_KEY_WINDOW_OPEN_TIMEOUT,
98 value_set_func=
lambda thermostat: thermostat.async_configure_window_open_duration,
99 value_func=
lambda presets: presets.window_open_time.value.total_seconds() / 60,
100 translation_key=ENTITY_KEY_WINDOW_OPEN_TIMEOUT,
104 native_unit_of_measurement=UnitOfTime.MINUTES,
111 entry: Eq3ConfigEntry,
112 async_add_entities: AddEntitiesCallback,
114 """Set up the entry."""
118 for entity_description
in NUMBER_ENTITY_DESCRIPTIONS
123 """Base class for all eq3 number entities."""
125 entity_description: Eq3NumberEntityDescription
128 self, entry: Eq3ConfigEntry, entity_description: Eq3NumberEntityDescription
130 """Initialize the entity."""
132 super().
__init__(entry, entity_description.key)
137 """Return the state of the entity."""
140 assert self.
_thermostat_thermostat.status
is not None
141 assert self.
_thermostat_thermostat.status.presets
is not None
146 """Set the state of the entity."""
152 """Return whether the entity is available."""
156 and self.
_thermostat_thermostat.status.presets
is not None
None async_set_native_value(self, float value)
None __init__(self, Eq3ConfigEntry entry, Eq3NumberEntityDescription entity_description)
None async_setup_entry(HomeAssistant hass, Eq3ConfigEntry entry, AddEntitiesCallback async_add_entities)