Add alias to DOMAIN import in config and demo (#125570)

This commit is contained in:
epenet 2024-09-10 08:41:47 +02:00 committed by GitHub
parent 7e2e3c4780
commit 2fa0f283ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 14 deletions

View file

@ -4,7 +4,7 @@ from __future__ import annotations
from typing import Any
from homeassistant.components.script import DOMAIN
from homeassistant.components.script import DOMAIN as SCRIPT_DOMAIN
from homeassistant.components.script.config import (
SCRIPT_ENTITY_SCHEMA,
async_validate_config_item,
@ -25,12 +25,14 @@ def async_setup(hass: HomeAssistant) -> bool:
async def hook(action: str, config_key: str) -> None:
"""post_write_hook for Config View that reloads scripts."""
if action != ACTION_DELETE:
await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
await hass.services.async_call(SCRIPT_DOMAIN, SERVICE_RELOAD)
return
ent_reg = er.async_get(hass)
entity_id = ent_reg.async_get_entity_id(DOMAIN, DOMAIN, config_key)
entity_id = ent_reg.async_get_entity_id(
SCRIPT_DOMAIN, SCRIPT_DOMAIN, config_key
)
if entity_id is None:
return
@ -39,7 +41,7 @@ def async_setup(hass: HomeAssistant) -> bool:
hass.http.register_view(
EditScriptConfigView(
DOMAIN,
SCRIPT_DOMAIN,
"config",
SCRIPT_CONFIG_PATH,
cv.slug,