1 """Support for select entities."""
3 from __future__
import annotations
7 from thinqconnect
import DeviceType
8 from thinqconnect.devices.const
import Property
as ThinQProperty
9 from thinqconnect.integration
import ActiveMode
15 from .
import ThinqConfigEntry
16 from .coordinator
import DeviceDataUpdateCoordinator
17 from .entity
import ThinQEntity
19 SELECT_DESC: dict[ThinQProperty, SelectEntityDescription] = {
21 key=ThinQProperty.MONITORING_ENABLED,
22 translation_key=ThinQProperty.MONITORING_ENABLED,
25 key=ThinQProperty.COOK_MODE,
26 translation_key=ThinQProperty.COOK_MODE,
29 key=ThinQProperty.DISPLAY_LIGHT,
30 translation_key=ThinQProperty.DISPLAY_LIGHT,
33 key=ThinQProperty.CURRENT_JOB_MODE,
34 translation_key=ThinQProperty.CURRENT_JOB_MODE,
37 key=ThinQProperty.FRESH_AIR_FILTER,
38 translation_key=ThinQProperty.FRESH_AIR_FILTER,
41 AIR_FLOW_SELECT_DESC: dict[ThinQProperty, SelectEntityDescription] = {
43 key=ThinQProperty.WIND_STRENGTH,
44 translation_key=ThinQProperty.WIND_STRENGTH,
47 key=ThinQProperty.WIND_ANGLE,
48 translation_key=ThinQProperty.WIND_ANGLE,
51 OPERATION_SELECT_DESC: dict[ThinQProperty, SelectEntityDescription] = {
53 key=ThinQProperty.AIR_CLEAN_OPERATION_MODE,
54 translation_key=
"air_clean_operation_mode",
57 key=ThinQProperty.DISH_WASHER_OPERATION_MODE,
58 translation_key=
"operation_mode",
61 key=ThinQProperty.DRYER_OPERATION_MODE,
62 translation_key=
"operation_mode",
65 key=ThinQProperty.HYGIENE_DRY_MODE,
66 translation_key=ThinQProperty.HYGIENE_DRY_MODE,
69 key=ThinQProperty.LIGHT_BRIGHTNESS,
70 translation_key=ThinQProperty.LIGHT_BRIGHTNESS,
73 key=ThinQProperty.OVEN_OPERATION_MODE,
74 translation_key=
"operation_mode",
77 key=ThinQProperty.STYLER_OPERATION_MODE,
78 translation_key=
"operation_mode",
81 key=ThinQProperty.WASHER_OPERATION_MODE,
82 translation_key=
"operation_mode",
86 DEVICE_TYPE_SELECT_MAP: dict[DeviceType, tuple[SelectEntityDescription, ...]] = {
87 DeviceType.AIR_CONDITIONER: (
88 SELECT_DESC[ThinQProperty.MONITORING_ENABLED],
89 OPERATION_SELECT_DESC[ThinQProperty.AIR_CLEAN_OPERATION_MODE],
91 DeviceType.AIR_PURIFIER_FAN: (
92 AIR_FLOW_SELECT_DESC[ThinQProperty.WIND_STRENGTH],
93 AIR_FLOW_SELECT_DESC[ThinQProperty.WIND_ANGLE],
94 SELECT_DESC[ThinQProperty.DISPLAY_LIGHT],
95 SELECT_DESC[ThinQProperty.CURRENT_JOB_MODE],
97 DeviceType.AIR_PURIFIER: (
98 AIR_FLOW_SELECT_DESC[ThinQProperty.WIND_STRENGTH],
99 SELECT_DESC[ThinQProperty.CURRENT_JOB_MODE],
101 DeviceType.DEHUMIDIFIER: (AIR_FLOW_SELECT_DESC[ThinQProperty.WIND_STRENGTH],),
102 DeviceType.DISH_WASHER: (
103 OPERATION_SELECT_DESC[ThinQProperty.DISH_WASHER_OPERATION_MODE],
105 DeviceType.DRYER: (OPERATION_SELECT_DESC[ThinQProperty.DRYER_OPERATION_MODE],),
106 DeviceType.HUMIDIFIER: (
107 AIR_FLOW_SELECT_DESC[ThinQProperty.WIND_STRENGTH],
108 SELECT_DESC[ThinQProperty.DISPLAY_LIGHT],
109 SELECT_DESC[ThinQProperty.CURRENT_JOB_MODE],
110 OPERATION_SELECT_DESC[ThinQProperty.HYGIENE_DRY_MODE],
113 SELECT_DESC[ThinQProperty.COOK_MODE],
114 OPERATION_SELECT_DESC[ThinQProperty.OVEN_OPERATION_MODE],
116 DeviceType.REFRIGERATOR: (SELECT_DESC[ThinQProperty.FRESH_AIR_FILTER],),
117 DeviceType.STYLER: (OPERATION_SELECT_DESC[ThinQProperty.STYLER_OPERATION_MODE],),
118 DeviceType.WASHCOMBO_MAIN: (
119 OPERATION_SELECT_DESC[ThinQProperty.WASHER_OPERATION_MODE],
121 DeviceType.WASHCOMBO_MINI: (
122 OPERATION_SELECT_DESC[ThinQProperty.WASHER_OPERATION_MODE],
124 DeviceType.WASHER: (OPERATION_SELECT_DESC[ThinQProperty.WASHER_OPERATION_MODE],),
125 DeviceType.WASHTOWER_DRYER: (
126 OPERATION_SELECT_DESC[ThinQProperty.WASHER_OPERATION_MODE],
128 DeviceType.WASHTOWER: (
129 OPERATION_SELECT_DESC[ThinQProperty.DRYER_OPERATION_MODE],
130 OPERATION_SELECT_DESC[ThinQProperty.WASHER_OPERATION_MODE],
132 DeviceType.WASHTOWER_WASHER: (
133 OPERATION_SELECT_DESC[ThinQProperty.WASHER_OPERATION_MODE],
135 DeviceType.WATER_HEATER: (SELECT_DESC[ThinQProperty.CURRENT_JOB_MODE],),
136 DeviceType.WINE_CELLAR: (OPERATION_SELECT_DESC[ThinQProperty.LIGHT_BRIGHTNESS],),
139 _LOGGER = logging.getLogger(__name__)
144 entry: ThinqConfigEntry,
145 async_add_entities: AddEntitiesCallback,
147 """Set up an entry for select platform."""
148 entities: list[ThinQSelectEntity] = []
149 for coordinator
in entry.runtime_data.coordinators.values():
151 descriptions := DEVICE_TYPE_SELECT_MAP.get(
152 coordinator.api.device.device_type
155 for description
in descriptions:
158 for property_id
in coordinator.api.get_active_idx(
159 description.key, ActiveMode.WRITABLE
168 """Represent a thinq select platform."""
172 coordinator: DeviceDataUpdateCoordinator,
173 entity_description: SelectEntityDescription,
176 """Initialize a select entity."""
177 super().
__init__(coordinator, entity_description, property_id)
182 """Update status itself."""
191 "[%s:%s] update status: %s -> %s, options:%s",
192 self.coordinator.device_name,
200 """Change the selected option."""
202 "[%s:%s] async_select_option: %s",
203 self.coordinator.device_name,
None async_call_api(self, Coroutine[Any, Any, Any] target, Callable[[], None]|None on_fail_method=None)
None __init__(self, DeviceDataUpdateCoordinator coordinator, SelectEntityDescription entity_description, str property_id)
None _update_status(self)
None async_select_option(self, str option)
str|None current_option(self)
None async_setup_entry(HomeAssistant hass, ThinqConfigEntry entry, AddEntitiesCallback async_add_entities)