1 """Support for event entity."""
3 from __future__
import annotations
7 from thinqconnect
import DeviceType
8 from thinqconnect.integration
import ActiveMode, ThinQPropertyEx
14 from .
import ThinqConfigEntry
15 from .coordinator
import DeviceDataUpdateCoordinator
16 from .entity
import ThinQEntity
19 key=ThinQPropertyEx.NOTIFICATION,
20 translation_key=ThinQPropertyEx.NOTIFICATION,
23 key=ThinQPropertyEx.ERROR,
24 translation_key=ThinQPropertyEx.ERROR,
26 ALL_EVENTS: tuple[EventEntityDescription, ...] = (
28 NOTIFICATION_EVENT_DESC,
30 DEVICE_TYPE_EVENT_MAP: dict[DeviceType, tuple[EventEntityDescription, ...]] = {
31 DeviceType.AIR_CONDITIONER: (NOTIFICATION_EVENT_DESC,),
32 DeviceType.AIR_PURIFIER_FAN: (NOTIFICATION_EVENT_DESC,),
33 DeviceType.AIR_PURIFIER: (NOTIFICATION_EVENT_DESC,),
34 DeviceType.DEHUMIDIFIER: (NOTIFICATION_EVENT_DESC,),
35 DeviceType.DISH_WASHER: ALL_EVENTS,
36 DeviceType.DRYER: ALL_EVENTS,
37 DeviceType.HUMIDIFIER: (NOTIFICATION_EVENT_DESC,),
38 DeviceType.KIMCHI_REFRIGERATOR: (NOTIFICATION_EVENT_DESC,),
39 DeviceType.MICROWAVE_OVEN: (NOTIFICATION_EVENT_DESC,),
40 DeviceType.OVEN: (NOTIFICATION_EVENT_DESC,),
41 DeviceType.REFRIGERATOR: (NOTIFICATION_EVENT_DESC,),
42 DeviceType.ROBOT_CLEANER: ALL_EVENTS,
43 DeviceType.STICK_CLEANER: (NOTIFICATION_EVENT_DESC,),
44 DeviceType.STYLER: ALL_EVENTS,
45 DeviceType.WASHCOMBO_MAIN: ALL_EVENTS,
46 DeviceType.WASHCOMBO_MINI: ALL_EVENTS,
47 DeviceType.WASHER: ALL_EVENTS,
48 DeviceType.WASHTOWER_DRYER: ALL_EVENTS,
49 DeviceType.WASHTOWER: ALL_EVENTS,
50 DeviceType.WASHTOWER_WASHER: ALL_EVENTS,
51 DeviceType.WINE_CELLAR: (NOTIFICATION_EVENT_DESC,),
54 _LOGGER = logging.getLogger(__name__)
59 entry: ThinqConfigEntry,
60 async_add_entities: AddEntitiesCallback,
62 """Set up an entry for event platform."""
63 entities: list[ThinQEventEntity] = []
64 for coordinator
in entry.runtime_data.coordinators.values():
66 descriptions := DEVICE_TYPE_EVENT_MAP.get(
67 coordinator.api.device.device_type
70 for description
in descriptions:
73 for property_id
in coordinator.api.get_active_idx(
74 description.key, ActiveMode.READ_ONLY
83 """Represent an thinq event platform."""
87 coordinator: DeviceDataUpdateCoordinator,
88 entity_description: EventEntityDescription,
91 """Initialize an event platform."""
92 super().
__init__(coordinator, entity_description, property_id)
98 """Update status itself."""
102 "[%s:%s] update status: %s, event_types=%s",
103 self.coordinator.device_name,
113 """Handle the event."""
list[str] event_types(self)
None _trigger_event(self, str event_type, dict[str, Any]|None event_attributes=None)
None __init__(self, DeviceDataUpdateCoordinator coordinator, EventEntityDescription entity_description, str property_id)
None _async_handle_update(self, str value)
None _update_status(self)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ThinqConfigEntry entry, AddEntitiesCallback async_add_entities)