Use entity registry id in toggle_entity device automations (#94995)

* Use entity registry id in toggle_entity device automations

* Update tests

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Erik Montnemery
2023-06-26 09:59:01 +02:00
committed by GitHub
parent 408c613731
commit a338e7e242
27 changed files with 1352 additions and 480 deletions

View File

@@ -25,6 +25,8 @@ STATIC_VALIDATOR = {
DeviceAutomationType.TRIGGER: "TRIGGER_SCHEMA",
}
TOGGLE_ENTITY_DOMAINS = {"fan", "humidifier", "light", "remote", "switch"}
async def async_validate_device_automation_config(
hass: HomeAssistant,
@@ -43,6 +45,16 @@ async def async_validate_device_automation_config(
ConfigType, getattr(platform, STATIC_VALIDATOR[automation_type])(config)
)
# Bypass checks for toggle entity domains
if (
automation_type == DeviceAutomationType.ACTION
and validated_config[CONF_DOMAIN] in TOGGLE_ENTITY_DOMAINS
):
return cast(
ConfigType,
await getattr(platform, DYNAMIC_VALIDATOR[automation_type])(hass, config),
)
# Only call the dynamic validator if the referenced device exists and the relevant
# config entry is loaded
registry = dr.async_get(hass)