mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +00:00
Teach state trigger about entity registry ids (#60271)
* Teach state trigger about entity registry ids * Tweak * Add tests * Tweak tests * Fix tests * Resolve entity ids during config validation * Update device_triggers * Fix mistake * Tweak trigger validator to ensure we don't modify the original config * Add index from entry id to entry * Update scaffold * Pre-compile UUID regex * Address review comment * Tweak mock_registry * Tweak * Apply suggestion from code review
This commit is contained in:
@@ -748,6 +748,7 @@ async def test_wait_basic(hass, action_type):
|
||||
"to": "off",
|
||||
}
|
||||
sequence = cv.SCRIPT_SCHEMA(action)
|
||||
sequence = await script.async_validate_actions_config(hass, sequence)
|
||||
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
|
||||
wait_started_flag = async_watch_for_action(script_obj, wait_alias)
|
||||
|
||||
@@ -848,6 +849,7 @@ async def test_wait_basic_times_out(hass, action_type):
|
||||
"to": "off",
|
||||
}
|
||||
sequence = cv.SCRIPT_SCHEMA(action)
|
||||
sequence = await script.async_validate_actions_config(hass, sequence)
|
||||
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
|
||||
wait_started_flag = async_watch_for_action(script_obj, wait_alias)
|
||||
timed_out = False
|
||||
@@ -904,6 +906,7 @@ async def test_multiple_runs_wait(hass, action_type):
|
||||
{"event": event, "event_data": {"value": 2}},
|
||||
]
|
||||
)
|
||||
sequence = await script.async_validate_actions_config(hass, sequence)
|
||||
script_obj = script.Script(
|
||||
hass, sequence, "Test Name", "test_domain", script_mode="parallel", max_runs=2
|
||||
)
|
||||
@@ -952,6 +955,7 @@ async def test_cancel_wait(hass, action_type):
|
||||
}
|
||||
}
|
||||
sequence = cv.SCRIPT_SCHEMA([action, {"event": event}])
|
||||
sequence = await script.async_validate_actions_config(hass, sequence)
|
||||
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
|
||||
wait_started_flag = async_watch_for_action(script_obj, "wait")
|
||||
|
||||
@@ -1049,6 +1053,7 @@ async def test_wait_timeout(hass, caplog, timeout_param, action_type):
|
||||
action["timeout"] = timeout_param
|
||||
action["continue_on_timeout"] = True
|
||||
sequence = cv.SCRIPT_SCHEMA([action, {"event": event}])
|
||||
sequence = await script.async_validate_actions_config(hass, sequence)
|
||||
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
|
||||
wait_started_flag = async_watch_for_action(script_obj, "wait")
|
||||
|
||||
@@ -1116,6 +1121,7 @@ async def test_wait_continue_on_timeout(
|
||||
if continue_on_timeout is not None:
|
||||
action["continue_on_timeout"] = continue_on_timeout
|
||||
sequence = cv.SCRIPT_SCHEMA([action, {"event": event}])
|
||||
sequence = await script.async_validate_actions_config(hass, sequence)
|
||||
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
|
||||
wait_started_flag = async_watch_for_action(script_obj, "wait")
|
||||
|
||||
@@ -1287,6 +1293,7 @@ async def test_wait_variables_out(hass, mode, action_type):
|
||||
},
|
||||
]
|
||||
sequence = cv.SCRIPT_SCHEMA(sequence)
|
||||
sequence = await script.async_validate_actions_config(hass, sequence)
|
||||
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
|
||||
wait_started_flag = async_watch_for_action(script_obj, "wait")
|
||||
|
||||
@@ -1326,11 +1333,13 @@ async def test_wait_variables_out(hass, mode, action_type):
|
||||
|
||||
async def test_wait_for_trigger_bad(hass, caplog):
|
||||
"""Test bad wait_for_trigger."""
|
||||
sequence = cv.SCRIPT_SCHEMA(
|
||||
{"wait_for_trigger": {"platform": "state", "entity_id": "sensor.abc"}}
|
||||
)
|
||||
sequence = await script.async_validate_actions_config(hass, sequence)
|
||||
script_obj = script.Script(
|
||||
hass,
|
||||
cv.SCRIPT_SCHEMA(
|
||||
{"wait_for_trigger": {"platform": "state", "entity_id": "sensor.abc"}}
|
||||
),
|
||||
sequence,
|
||||
"Test Name",
|
||||
"test_domain",
|
||||
)
|
||||
@@ -1356,11 +1365,13 @@ async def test_wait_for_trigger_bad(hass, caplog):
|
||||
|
||||
async def test_wait_for_trigger_generated_exception(hass, caplog):
|
||||
"""Test bad wait_for_trigger."""
|
||||
sequence = cv.SCRIPT_SCHEMA(
|
||||
{"wait_for_trigger": {"platform": "state", "entity_id": "sensor.abc"}}
|
||||
)
|
||||
sequence = await script.async_validate_actions_config(hass, sequence)
|
||||
script_obj = script.Script(
|
||||
hass,
|
||||
cv.SCRIPT_SCHEMA(
|
||||
{"wait_for_trigger": {"platform": "state", "entity_id": "sensor.abc"}}
|
||||
),
|
||||
sequence,
|
||||
"Test Name",
|
||||
"test_domain",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user