mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Add alias to DOMAIN import in config and demo (#125570)
This commit is contained in:
parent
7e2e3c4780
commit
2fa0f283ea
@ -5,8 +5,8 @@ from __future__ import annotations
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from homeassistant.components.automation import DOMAIN as AUTOMATION_DOMAIN
|
||||||
from homeassistant.components.automation.config import (
|
from homeassistant.components.automation.config import (
|
||||||
DOMAIN,
|
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
async_validate_config_item,
|
async_validate_config_item,
|
||||||
)
|
)
|
||||||
@ -27,13 +27,15 @@ def async_setup(hass: HomeAssistant) -> bool:
|
|||||||
"""post_write_hook for Config View that reloads automations."""
|
"""post_write_hook for Config View that reloads automations."""
|
||||||
if action != ACTION_DELETE:
|
if action != ACTION_DELETE:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN, SERVICE_RELOAD, {CONF_ID: config_key}
|
AUTOMATION_DOMAIN, SERVICE_RELOAD, {CONF_ID: config_key}
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
ent_reg = er.async_get(hass)
|
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(
|
||||||
|
AUTOMATION_DOMAIN, AUTOMATION_DOMAIN, config_key
|
||||||
|
)
|
||||||
|
|
||||||
if entity_id is None:
|
if entity_id is None:
|
||||||
return
|
return
|
||||||
@ -42,7 +44,7 @@ def async_setup(hass: HomeAssistant) -> bool:
|
|||||||
|
|
||||||
hass.http.register_view(
|
hass.http.register_view(
|
||||||
EditAutomationConfigView(
|
EditAutomationConfigView(
|
||||||
DOMAIN,
|
AUTOMATION_DOMAIN,
|
||||||
"config",
|
"config",
|
||||||
AUTOMATION_CONFIG_PATH,
|
AUTOMATION_CONFIG_PATH,
|
||||||
cv.string,
|
cv.string,
|
||||||
|
@ -6,7 +6,7 @@ from typing import Any
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from homeassistant.components.scene import (
|
from homeassistant.components.scene import (
|
||||||
DOMAIN,
|
DOMAIN as SCENE_DOMAIN,
|
||||||
PLATFORM_SCHEMA as SCENE_PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA as SCENE_PLATFORM_SCHEMA,
|
||||||
)
|
)
|
||||||
from homeassistant.config import SCENE_CONFIG_PATH
|
from homeassistant.config import SCENE_CONFIG_PATH
|
||||||
@ -27,13 +27,13 @@ def async_setup(hass: HomeAssistant) -> bool:
|
|||||||
async def hook(action: str, config_key: str) -> None:
|
async def hook(action: str, config_key: str) -> None:
|
||||||
"""post_write_hook for Config View that reloads scenes."""
|
"""post_write_hook for Config View that reloads scenes."""
|
||||||
if action != ACTION_DELETE:
|
if action != ACTION_DELETE:
|
||||||
await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
|
await hass.services.async_call(SCENE_DOMAIN, SERVICE_RELOAD)
|
||||||
return
|
return
|
||||||
|
|
||||||
ent_reg = er.async_get(hass)
|
ent_reg = er.async_get(hass)
|
||||||
|
|
||||||
entity_id = ent_reg.async_get_entity_id(
|
entity_id = ent_reg.async_get_entity_id(
|
||||||
DOMAIN, HOMEASSISTANT_DOMAIN, config_key
|
SCENE_DOMAIN, HOMEASSISTANT_DOMAIN, config_key
|
||||||
)
|
)
|
||||||
|
|
||||||
if entity_id is None:
|
if entity_id is None:
|
||||||
@ -43,7 +43,7 @@ def async_setup(hass: HomeAssistant) -> bool:
|
|||||||
|
|
||||||
hass.http.register_view(
|
hass.http.register_view(
|
||||||
EditSceneConfigView(
|
EditSceneConfigView(
|
||||||
DOMAIN,
|
SCENE_DOMAIN,
|
||||||
"config",
|
"config",
|
||||||
SCENE_CONFIG_PATH,
|
SCENE_CONFIG_PATH,
|
||||||
cv.string,
|
cv.string,
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
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 (
|
from homeassistant.components.script.config import (
|
||||||
SCRIPT_ENTITY_SCHEMA,
|
SCRIPT_ENTITY_SCHEMA,
|
||||||
async_validate_config_item,
|
async_validate_config_item,
|
||||||
@ -25,12 +25,14 @@ def async_setup(hass: HomeAssistant) -> bool:
|
|||||||
async def hook(action: str, config_key: str) -> None:
|
async def hook(action: str, config_key: str) -> None:
|
||||||
"""post_write_hook for Config View that reloads scripts."""
|
"""post_write_hook for Config View that reloads scripts."""
|
||||||
if action != ACTION_DELETE:
|
if action != ACTION_DELETE:
|
||||||
await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
|
await hass.services.async_call(SCRIPT_DOMAIN, SERVICE_RELOAD)
|
||||||
return
|
return
|
||||||
|
|
||||||
ent_reg = er.async_get(hass)
|
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:
|
if entity_id is None:
|
||||||
return
|
return
|
||||||
@ -39,7 +41,7 @@ def async_setup(hass: HomeAssistant) -> bool:
|
|||||||
|
|
||||||
hass.http.register_view(
|
hass.http.register_view(
|
||||||
EditScriptConfigView(
|
EditScriptConfigView(
|
||||||
DOMAIN,
|
SCRIPT_DOMAIN,
|
||||||
"config",
|
"config",
|
||||||
SCRIPT_CONFIG_PATH,
|
SCRIPT_CONFIG_PATH,
|
||||||
cv.slug,
|
cv.slug,
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.notify import DOMAIN, NotifyEntity, NotifyEntityFeature
|
from homeassistant.components.notify import (
|
||||||
|
DOMAIN as NOTIFY_DOMAIN,
|
||||||
|
NotifyEntity,
|
||||||
|
NotifyEntityFeature,
|
||||||
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
@ -35,7 +39,7 @@ class DemoNotifyEntity(NotifyEntity):
|
|||||||
self._attr_unique_id = unique_id
|
self._attr_unique_id = unique_id
|
||||||
self._attr_supported_features = NotifyEntityFeature.TITLE
|
self._attr_supported_features = NotifyEntityFeature.TITLE
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, unique_id)},
|
identifiers={(NOTIFY_DOMAIN, unique_id)},
|
||||||
name=device_name,
|
name=device_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user