guard against invalid trigger and action scenarios (#32512)
This commit is contained in:
1 parent
ae0ea0f088
commit
b5022f5bcb
2 files changed
+16
-5
No files matched your search
@@ -27,7 +27,10 @@ async def async_validate_trigger_config(hass, config):
|
||||
|
||||
if "zha" in hass.config.components:
|
||||
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
|
||||
zha_device = await async_get_zha_device(hass, config[CONF_DEVICE_ID])
|
||||
try:
|
||||
zha_device = await async_get_zha_device(hass, config[CONF_DEVICE_ID])
|
||||
except (KeyError, AttributeError):
|
||||
raise InvalidDeviceAutomationConfig
|
||||
if (
|
||||
zha_device.device_automation_triggers is None
|
||||
or trigger not in zha_device.device_automation_triggers
|
||||
@@ -40,8 +43,10 @@ async def async_validate_trigger_config(hass, 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])
|
||||
|
||||
try:
|
||||
zha_device = await async_get_zha_device(hass, config[CONF_DEVICE_ID])
|
||||
except (KeyError, AttributeError):
|
||||
return None
|
||||
trigger = zha_device.device_automation_triggers[trigger]
|
||||
|
||||
event_config = {
|
||||
|
||||
Reference in new issue
Block a user