Add unique ID to scripts (#70345)

This commit is contained in:
Franck Nijhof 2022-04-21 20:04:02 +02:00 committed by GitHub
parent ac88d0be14
commit d08b751a85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -25,7 +25,7 @@ from homeassistant.core import (
split_entity_id,
)
from homeassistant.exceptions import ServiceNotFound
from homeassistant.helpers import template
from homeassistant.helpers import entity_registry as er, template
from homeassistant.helpers.event import async_track_state_change
from homeassistant.helpers.script import (
SCRIPT_MODE_CHOICES,
@ -205,7 +205,8 @@ async def test_reload_service(hass, running):
await hass.async_block_till_done()
if running != "same":
assert hass.states.get(ENTITY_ID) is None
state = hass.states.get(ENTITY_ID)
assert state.attributes["restored"] is True
assert not hass.services.has_service(script.DOMAIN, "test")
assert hass.states.get("script.test2") is not None
@ -482,6 +483,11 @@ async def test_config_basic(hass):
assert test_script.name == "Script Name"
assert test_script.attributes["icon"] == "mdi:party"
registry = er.async_get(hass)
entry = registry.async_get("script.test_script")
assert entry
assert entry.unique_id == "test_script"
async def test_config_multiple_domains(hass):
"""Test splitting configuration over multiple domains."""