1 """Support for Tuya siren."""
3 from __future__
import annotations
7 from tuya_sharing
import CustomerDevice, Manager
11 SirenEntityDescription,
19 from .
import TuyaConfigEntry
20 from .const
import TUYA_DISCOVERY_NEW, DPCode
21 from .entity
import TuyaEntity
25 SIRENS: dict[str, tuple[SirenEntityDescription, ...]] = {
30 key=DPCode.ALARM_SWITCH,
37 key=DPCode.ALARM_SWITCH,
44 key=DPCode.SIREN_SWITCH,
51 key=DPCode.ALARM_SWITCH,
52 entity_category=EntityCategory.CONFIG,
59 hass: HomeAssistant, entry: TuyaConfigEntry, async_add_entities: AddEntitiesCallback
61 """Set up Tuya siren dynamically through Tuya discovery."""
62 hass_data = entry.runtime_data
66 """Discover and add a discovered Tuya siren."""
67 entities: list[TuyaSirenEntity] = []
68 for device_id
in device_ids:
69 device = hass_data.manager.device_map[device_id]
70 if descriptions := SIRENS.get(device.category):
73 for description
in descriptions
74 if description.key
in device.status
81 entry.async_on_unload(
87 """Tuya Siren Entity."""
89 _attr_supported_features = SirenEntityFeature.TURN_ON | SirenEntityFeature.TURN_OFF
94 device: CustomerDevice,
95 device_manager: Manager,
96 description: SirenEntityDescription,
98 """Init Tuya Siren."""
99 super().
__init__(device, device_manager)
105 """Return true if siren is on."""
109 """Turn the siren on."""
113 """Turn the siren off."""
None _send_command(self, list[dict[str, Any]] commands)
None turn_off(self, **Any kwargs)
None __init__(self, CustomerDevice device, Manager device_manager, SirenEntityDescription description)
None turn_on(self, **Any kwargs)
ElkSystem|None async_discover_device(HomeAssistant hass, str host)
None async_setup_entry(HomeAssistant hass, TuyaConfigEntry entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)