1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Improve validation of device action config (#27029)

This commit is contained in:
Erik Montnemery
2019-10-02 05:35:36 +02:00
committed by Paulus Schoutsen
parent 2090d650c6
commit 5a1da72d5e
3 changed files with 64 additions and 11 deletions

View File

@@ -7,10 +7,10 @@ import voluptuous as vol
from homeassistant.const import CONF_PLATFORM
from homeassistant.config import async_log_exception, config_without_domain
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_per_platform
from homeassistant.helpers import config_per_platform, script
from homeassistant.loader import IntegrationNotFound
from . import CONF_TRIGGER, DOMAIN, PLATFORM_SCHEMA
from . import CONF_ACTION, CONF_TRIGGER, DOMAIN, PLATFORM_SCHEMA
# mypy: allow-untyped-calls, allow-untyped-defs
# mypy: no-check-untyped-defs, no-warn-return-any
@@ -32,6 +32,12 @@ async def async_validate_config_item(hass, config, full_config=None):
)
triggers.append(trigger)
config[CONF_TRIGGER] = triggers
actions = []
for action in config[CONF_ACTION]:
action = await script.async_validate_action_config(hass, action)
actions.append(action)
config[CONF_ACTION] = actions
except (vol.Invalid, HomeAssistantError, IntegrationNotFound) as ex:
async_log_exception(ex, DOMAIN, full_config or config, hass)
return None