Support async validation of device trigger (#27333)

This commit is contained in:
Erik Montnemery authored and GitHub committed 2019-10-09 21:04:11 +02:00
1 parent 3194dd3456
commit fdf4f398a7
6 files changed
+87 -64

No files matched your search

+12 -2
View File
@@ -21,8 +21,10 @@ TRIGGER_SCHEMA = TRIGGER_BASE_SCHEMA.extend(
)
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
async def async_validate_trigger_config(hass, config):
"""Validate config."""
config = TRIGGER_SCHEMA(config)
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
zha_device = await async_get_zha_device(hass, config[CONF_DEVICE_ID])
@@ -32,6 +34,14 @@ async def async_attach_trigger(hass, config, action, automation_info):
):
raise InvalidDeviceAutomationConfig
return config
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
zha_device = await async_get_zha_device(hass, config[CONF_DEVICE_ID])
trigger = zha_device.device_automation_triggers[trigger]
event_config = {