Support dynamic schema validation in device conditions and actions (#52007)

* Allow integrations to provide dynamic schema validation in device conditions and actions

* Add tests

* re-add type

* mypy
This commit is contained in:
Raman Gupta
2021-06-28 03:23:46 -04:00
committed by GitHub
parent 5d3f3c756f
commit bef8be9256
4 changed files with 48 additions and 5 deletions

View File

@@ -256,7 +256,10 @@ async def async_validate_action_config(
platform = await device_automation.async_get_device_automation_platform(
hass, config[CONF_DOMAIN], "action"
)
config = platform.ACTION_SCHEMA(config) # type: ignore
if hasattr(platform, "async_validate_action_config"):
config = await platform.async_validate_action_config(hass, config) # type: ignore
else:
config = platform.ACTION_SCHEMA(config) # type: ignore
elif action_type == cv.SCRIPT_ACTION_CHECK_CONDITION:
if config[CONF_CONDITION] == "device":