Use entity registry id in alarm_control_panel device actions (#95241)

This commit is contained in:
Erik Montnemery 2023-06-26 16:59:43 +02:00 committed by GitHub
parent 8e2ba81995
commit 89c9e72768
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 205 additions and 50 deletions

View file

@ -5,7 +5,7 @@ from typing import cast
import voluptuous as vol
from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN
from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.typing import ConfigType
@ -25,7 +25,14 @@ STATIC_VALIDATOR = {
DeviceAutomationType.TRIGGER: "TRIGGER_SCHEMA",
}
TOGGLE_ENTITY_DOMAINS = {"fan", "humidifier", "light", "remote", "switch"}
ENTITY_PLATFORMS = {
Platform.ALARM_CONTROL_PANEL.value,
Platform.FAN.value,
Platform.HUMIDIFIER.value,
Platform.LIGHT.value,
Platform.REMOTE.value,
Platform.SWITCH.value,
}
async def async_validate_device_automation_config(
@ -45,10 +52,10 @@ async def async_validate_device_automation_config(
ConfigType, getattr(platform, STATIC_VALIDATOR[automation_type])(config)
)
# Bypass checks for toggle entity domains
# Bypass checks for entity platforms
if (
automation_type == DeviceAutomationType.ACTION
and validated_config[CONF_DOMAIN] in TOGGLE_ENTITY_DOMAINS
and validated_config[CONF_DOMAIN] in ENTITY_PLATFORMS
):
return cast(
ConfigType,