Find referenced floors in automations & scripts (#113802)

This commit is contained in:
Franck Nijhof 2024-03-19 14:18:53 +01:00 committed by GitHub
parent 44211dc761
commit 38d0854b70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 232 additions and 10 deletions

View file

@ -1561,6 +1561,8 @@ async def test_extraction_functions_not_setup(hass: HomeAssistant) -> None:
assert automation.devices_in_automation(hass, "automation.test") == []
assert automation.automations_with_entity(hass, "light.in_both") == []
assert automation.entities_in_automation(hass, "automation.test") == []
assert automation.automations_with_floor(hass, "floor-in-both") == []
assert automation.floors_in_automation(hass, "automation.test") == []
async def test_extraction_functions_unknown_automation(hass: HomeAssistant) -> None:
@ -1570,6 +1572,7 @@ async def test_extraction_functions_unknown_automation(hass: HomeAssistant) -> N
assert automation.blueprint_in_automation(hass, "automation.unknown") is None
assert automation.devices_in_automation(hass, "automation.unknown") == []
assert automation.entities_in_automation(hass, "automation.unknown") == []
assert automation.floors_in_automation(hass, "automation.unknown") == []
async def test_extraction_functions_unavailable_automation(hass: HomeAssistant) -> None:
@ -1595,6 +1598,8 @@ async def test_extraction_functions_unavailable_automation(hass: HomeAssistant)
assert automation.devices_in_automation(hass, entity_id) == []
assert automation.automations_with_entity(hass, "light.in_both") == []
assert automation.entities_in_automation(hass, entity_id) == []
assert automation.automations_with_floor(hass, "floor-in-both") == []
assert automation.floors_in_automation(hass, entity_id) == []
async def test_extraction_functions(
@ -1694,6 +1699,10 @@ async def test_extraction_functions(
"service": "test.test",
"target": {"area_id": "area-in-both"},
},
{
"service": "test.test",
"target": {"floor_id": "floor-in-both"},
},
],
},
{
@ -1813,6 +1822,14 @@ async def test_extraction_functions(
"service": "test.test",
"target": {"area_id": "area-in-last"},
},
{
"service": "test.test",
"target": {"floor_id": "floor-in-both"},
},
{
"service": "test.test",
"target": {"floor_id": "floor-in-last"},
},
],
},
]
@ -1855,6 +1872,14 @@ async def test_extraction_functions(
"area-in-both",
"area-in-last",
}
assert set(automation.automations_with_floor(hass, "floor-in-both")) == {
"automation.test1",
"automation.test3",
}
assert set(automation.floors_in_automation(hass, "automation.test3")) == {
"floor-in-both",
"floor-in-last",
}
assert automation.blueprint_in_automation(hass, "automation.test3") is None