1 """Support for Tuya buttons."""
3 from __future__
import annotations
5 from tuya_sharing
import CustomerDevice, Manager
13 from .
import TuyaConfigEntry
14 from .const
import TUYA_DISCOVERY_NEW, DPCode
15 from .entity
import TuyaEntity
19 BUTTONS: dict[str, tuple[ButtonEntityDescription, ...]] = {
24 key=DPCode.RESET_DUSTER_CLOTH,
25 translation_key=
"reset_duster_cloth",
26 entity_category=EntityCategory.CONFIG,
29 key=DPCode.RESET_EDGE_BRUSH,
30 translation_key=
"reset_edge_brush",
31 entity_category=EntityCategory.CONFIG,
34 key=DPCode.RESET_FILTER,
35 translation_key=
"reset_filter",
36 entity_category=EntityCategory.CONFIG,
40 translation_key=
"reset_map",
41 entity_category=EntityCategory.CONFIG,
44 key=DPCode.RESET_ROLL_BRUSH,
45 translation_key=
"reset_roll_brush",
46 entity_category=EntityCategory.CONFIG,
53 key=DPCode.SWITCH_USB6,
54 translation_key=
"snooze",
61 hass: HomeAssistant, entry: TuyaConfigEntry, async_add_entities: AddEntitiesCallback
63 """Set up Tuya buttons dynamically through Tuya discovery."""
64 hass_data = entry.runtime_data
68 """Discover and add a discovered Tuya buttons."""
69 entities: list[TuyaButtonEntity] = []
70 for device_id
in device_ids:
71 device = hass_data.manager.device_map[device_id]
72 if descriptions := BUTTONS.get(device.category):
75 for description
in descriptions
76 if description.key
in device.status
83 entry.async_on_unload(
89 """Tuya Button Device."""
93 device: CustomerDevice,
94 device_manager: Manager,
95 description: ButtonEntityDescription,
97 """Init Tuya button."""
98 super().
__init__(device, device_manager)
103 """Press the button."""
None _send_command(self, list[dict[str, Any]] commands)
ElkSystem|None async_discover_device(HomeAssistant hass, str host)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)