1 """Offer device oriented automation."""
3 from __future__
import annotations
5 from typing
import Any, Protocol
7 import voluptuous
as vol
19 DEVICE_TRIGGER_BASE_SCHEMA,
21 async_get_device_automation_platform,
23 from .helpers
import async_validate_device_automation_config
25 TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend({}, extra=vol.ALLOW_EXTRA)
29 """Define the format of device_trigger modules.
31 Each module must define either TRIGGER_SCHEMA or async_validate_trigger_config
36 self, hass: HomeAssistant, config: ConfigType
37 ) -> dict[str, vol.Schema]:
38 """List trigger capabilities."""
41 self, hass: HomeAssistant, device_id: str
42 ) -> list[dict[str, Any]]:
47 hass: HomeAssistant, config: ConfigType
49 """Validate config."""
51 hass, config, TRIGGER_SCHEMA, DeviceAutomationType.TRIGGER
58 action: TriggerActionType,
59 trigger_info: TriggerInfo,
61 """Listen for trigger."""
63 hass, config[CONF_DOMAIN], DeviceAutomationType.TRIGGER
65 return await platform.async_attach_trigger(hass, config, action, trigger_info)
dict[str, vol.Schema] async_get_trigger_capabilities(self, HomeAssistant hass, ConfigType config)
list[dict[str, str]] async_get_triggers(HomeAssistant hass, str device_id)
ConfigType async_validate_device_automation_config(HomeAssistant hass, ConfigType config, vol.Schema automation_schema, DeviceAutomationType automation_type)
ConfigType async_validate_trigger_config(HomeAssistant hass, ConfigType config)
CALLBACK_TYPE async_attach_trigger(HomeAssistant hass, ConfigType config, TriggerActionType action, TriggerInfo trigger_info)
DeviceAutomationTriggerProtocol async_get_device_automation_platform(HomeAssistant hass, str domain, Literal[DeviceAutomationType.TRIGGER] automation_type)