1 """Support for binary sensor entities."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
8 from thinqconnect
import DeviceType
9 from thinqconnect.devices.const
import Property
as ThinQProperty
10 from thinqconnect.integration
import ActiveMode
13 BinarySensorDeviceClass,
15 BinarySensorEntityDescription,
20 from .
import ThinqConfigEntry
21 from .entity
import ThinQEntity
24 @dataclass(frozen=True, kw_only=True)
26 """Describes ThinQ sensor entity."""
28 on_key: str |
None =
None
31 BINARY_SENSOR_DESC: dict[ThinQProperty, ThinQBinarySensorEntityDescription] = {
33 key=ThinQProperty.RINSE_REFILL,
34 translation_key=ThinQProperty.RINSE_REFILL,
37 key=ThinQProperty.ECO_FRIENDLY_MODE,
38 translation_key=ThinQProperty.ECO_FRIENDLY_MODE,
41 key=ThinQProperty.POWER_SAVE_ENABLED,
42 translation_key=ThinQProperty.POWER_SAVE_ENABLED,
45 key=ThinQProperty.REMOTE_CONTROL_ENABLED,
46 translation_key=ThinQProperty.REMOTE_CONTROL_ENABLED,
49 key=ThinQProperty.SABBATH_MODE,
50 translation_key=ThinQProperty.SABBATH_MODE,
53 key=ThinQProperty.DOOR_STATE,
54 device_class=BinarySensorDeviceClass.DOOR,
58 key=ThinQProperty.MACHINE_CLEAN_REMINDER,
59 translation_key=ThinQProperty.MACHINE_CLEAN_REMINDER,
60 on_key=
"mcreminder_on",
63 key=ThinQProperty.SIGNAL_LEVEL,
64 translation_key=ThinQProperty.SIGNAL_LEVEL,
65 on_key=
"signallevel_on",
68 key=ThinQProperty.CLEAN_LIGHT_REMINDER,
69 translation_key=ThinQProperty.CLEAN_LIGHT_REMINDER,
70 on_key=
"cleanlreminder_on",
73 key=ThinQProperty.HOOD_OPERATION_MODE,
74 translation_key=
"operation_mode",
78 key=ThinQProperty.WATER_HEATER_OPERATION_MODE,
79 translation_key=
"operation_mode",
83 key=ThinQProperty.ONE_TOUCH_FILTER,
84 translation_key=ThinQProperty.ONE_TOUCH_FILTER,
89 DEVICE_TYPE_BINARY_SENSOR_MAP: dict[
90 DeviceType, tuple[ThinQBinarySensorEntityDescription, ...]
92 DeviceType.COOKTOP: (BINARY_SENSOR_DESC[ThinQProperty.REMOTE_CONTROL_ENABLED],),
93 DeviceType.DISH_WASHER: (
94 BINARY_SENSOR_DESC[ThinQProperty.DOOR_STATE],
95 BINARY_SENSOR_DESC[ThinQProperty.RINSE_REFILL],
96 BINARY_SENSOR_DESC[ThinQProperty.REMOTE_CONTROL_ENABLED],
97 BINARY_SENSOR_DESC[ThinQProperty.MACHINE_CLEAN_REMINDER],
98 BINARY_SENSOR_DESC[ThinQProperty.SIGNAL_LEVEL],
99 BINARY_SENSOR_DESC[ThinQProperty.CLEAN_LIGHT_REMINDER],
101 DeviceType.DRYER: (BINARY_SENSOR_DESC[ThinQProperty.REMOTE_CONTROL_ENABLED],),
102 DeviceType.HOOD: (BINARY_SENSOR_DESC[ThinQProperty.HOOD_OPERATION_MODE],),
103 DeviceType.OVEN: (BINARY_SENSOR_DESC[ThinQProperty.REMOTE_CONTROL_ENABLED],),
104 DeviceType.REFRIGERATOR: (
105 BINARY_SENSOR_DESC[ThinQProperty.DOOR_STATE],
106 BINARY_SENSOR_DESC[ThinQProperty.ECO_FRIENDLY_MODE],
107 BINARY_SENSOR_DESC[ThinQProperty.POWER_SAVE_ENABLED],
108 BINARY_SENSOR_DESC[ThinQProperty.SABBATH_MODE],
110 DeviceType.KIMCHI_REFRIGERATOR: (
111 BINARY_SENSOR_DESC[ThinQProperty.ONE_TOUCH_FILTER],
113 DeviceType.STYLER: (BINARY_SENSOR_DESC[ThinQProperty.REMOTE_CONTROL_ENABLED],),
114 DeviceType.WASHCOMBO_MAIN: (
115 BINARY_SENSOR_DESC[ThinQProperty.REMOTE_CONTROL_ENABLED],
117 DeviceType.WASHCOMBO_MINI: (
118 BINARY_SENSOR_DESC[ThinQProperty.REMOTE_CONTROL_ENABLED],
120 DeviceType.WASHER: (BINARY_SENSOR_DESC[ThinQProperty.REMOTE_CONTROL_ENABLED],),
121 DeviceType.WASHTOWER_DRYER: (
122 BINARY_SENSOR_DESC[ThinQProperty.REMOTE_CONTROL_ENABLED],
124 DeviceType.WASHTOWER: (BINARY_SENSOR_DESC[ThinQProperty.REMOTE_CONTROL_ENABLED],),
125 DeviceType.WASHTOWER_WASHER: (
126 BINARY_SENSOR_DESC[ThinQProperty.REMOTE_CONTROL_ENABLED],
128 DeviceType.WATER_HEATER: (
129 BINARY_SENSOR_DESC[ThinQProperty.WATER_HEATER_OPERATION_MODE],
131 DeviceType.WINE_CELLAR: (BINARY_SENSOR_DESC[ThinQProperty.SABBATH_MODE],),
133 _LOGGER = logging.getLogger(__name__)
138 entry: ThinqConfigEntry,
139 async_add_entities: AddEntitiesCallback,
141 """Set up an entry for binary sensor platform."""
142 entities: list[ThinQBinarySensorEntity] = []
143 for coordinator
in entry.runtime_data.coordinators.values():
145 descriptions := DEVICE_TYPE_BINARY_SENSOR_MAP.get(
146 coordinator.api.device.device_type
149 for description
in descriptions:
152 for property_id
in coordinator.api.get_active_idx(
153 description.key, ActiveMode.READ_ONLY
162 """Represent a thinq binary sensor platform."""
164 entity_description: ThinQBinarySensorEntityDescription
167 """Update status itself."""
176 "[%s:%s] update status: %s -> %s",
177 self.coordinator.device_name,
None _update_status(self)
None async_setup_entry(HomeAssistant hass, ThinqConfigEntry entry, AddEntitiesCallback async_add_entities)