Find related items scripts/automations (#31293)
* Find related items scripts/automations * Update manifest
This commit is contained in:
parent
881437c085
commit
424e15c7a7
11 changed files with 586 additions and 49 deletions
|
@ -358,9 +358,8 @@ async def test_turning_no_scripts_off(hass):
|
|||
|
||||
async def test_async_get_descriptions_script(hass):
|
||||
"""Test async_set_service_schema for the script integration."""
|
||||
script = hass.components.script
|
||||
script_config = {
|
||||
script.DOMAIN: {
|
||||
DOMAIN: {
|
||||
"test1": {"sequence": [{"service": "homeassistant.restart"}]},
|
||||
"test2": {
|
||||
"description": "test2",
|
||||
|
@ -375,18 +374,75 @@ async def test_async_get_descriptions_script(hass):
|
|||
}
|
||||
}
|
||||
|
||||
await async_setup_component(hass, script.DOMAIN, script_config)
|
||||
await async_setup_component(hass, DOMAIN, script_config)
|
||||
descriptions = await hass.helpers.service.async_get_all_descriptions()
|
||||
|
||||
assert descriptions[script.DOMAIN]["test1"]["description"] == ""
|
||||
assert not descriptions[script.DOMAIN]["test1"]["fields"]
|
||||
assert descriptions[DOMAIN]["test1"]["description"] == ""
|
||||
assert not descriptions[DOMAIN]["test1"]["fields"]
|
||||
|
||||
assert descriptions[script.DOMAIN]["test2"]["description"] == "test2"
|
||||
assert descriptions[DOMAIN]["test2"]["description"] == "test2"
|
||||
assert (
|
||||
descriptions[script.DOMAIN]["test2"]["fields"]["param"]["description"]
|
||||
descriptions[DOMAIN]["test2"]["fields"]["param"]["description"]
|
||||
== "param_description"
|
||||
)
|
||||
assert (
|
||||
descriptions[script.DOMAIN]["test2"]["fields"]["param"]["example"]
|
||||
== "param_example"
|
||||
descriptions[DOMAIN]["test2"]["fields"]["param"]["example"] == "param_example"
|
||||
)
|
||||
|
||||
|
||||
async def test_extraction_functions(hass):
|
||||
"""Test extraction functions."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
{
|
||||
DOMAIN: {
|
||||
"test1": {
|
||||
"sequence": [
|
||||
{
|
||||
"service": "test.script",
|
||||
"data": {"entity_id": "light.in_both"},
|
||||
},
|
||||
{
|
||||
"service": "test.script",
|
||||
"data": {"entity_id": "light.in_first"},
|
||||
},
|
||||
{"domain": "light", "device_id": "device-in-both"},
|
||||
]
|
||||
},
|
||||
"test2": {
|
||||
"sequence": [
|
||||
{
|
||||
"service": "test.script",
|
||||
"data": {"entity_id": "light.in_both"},
|
||||
},
|
||||
{
|
||||
"condition": "state",
|
||||
"entity_id": "sensor.condition",
|
||||
"state": "100",
|
||||
},
|
||||
{"scene": "scene.hello"},
|
||||
{"domain": "light", "device_id": "device-in-both"},
|
||||
{"domain": "light", "device_id": "device-in-last"},
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
assert set(script.scripts_with_entity(hass, "light.in_both")) == {
|
||||
"script.test1",
|
||||
"script.test2",
|
||||
}
|
||||
assert set(script.entities_in_script(hass, "script.test1")) == {
|
||||
"light.in_both",
|
||||
"light.in_first",
|
||||
}
|
||||
assert set(script.scripts_with_device(hass, "device-in-both")) == {
|
||||
"script.test1",
|
||||
"script.test2",
|
||||
}
|
||||
assert set(script.devices_in_script(hass, "script.test2")) == {
|
||||
"device-in-both",
|
||||
"device-in-last",
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue