Fix validation when automation is saved from frontend (#27195)

This commit is contained in:
Erik Montnemery 2019-10-04 19:17:57 +02:00 committed by Paulus Schoutsen
parent b8f41dbb75
commit e27051aa61

View File

@ -18,7 +18,6 @@ from . import CONF_ACTION, CONF_CONDITION, CONF_TRIGGER, DOMAIN, PLATFORM_SCHEMA
async def async_validate_config_item(hass, config, full_config=None):
"""Validate config item."""
try:
config = PLATFORM_SCHEMA(config)
triggers = []
@ -45,6 +44,14 @@ async def async_validate_config_item(hass, config, full_config=None):
action = await script.async_validate_action_config(hass, action)
actions.append(action)
config[CONF_ACTION] = actions
return config
async def _try_async_validate_config_item(hass, config, full_config=None):
"""Validate config item."""
try:
config = await async_validate_config_item(hass, config, full_config)
except (vol.Invalid, HomeAssistantError, IntegrationNotFound) as ex:
async_log_exception(ex, DOMAIN, full_config or config, hass)
return None
@ -57,7 +64,7 @@ async def async_validate_config(hass, config):
automations = []
validated_automations = await asyncio.gather(
*(
async_validate_config_item(hass, p_config, config)
_try_async_validate_config_item(hass, p_config, config)
for _, p_config in config_per_platform(config, DOMAIN)
)
)