mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 07:51:46 -05:00
Resolve up labeled areas, devices and entities in search (#175464)
This commit is contained in:
@@ -400,14 +400,17 @@ class Searcher:
|
||||
# Areas with this label
|
||||
for area_entry in ar.async_entries_for_label(self._area_registry, label_id):
|
||||
self._add(ItemType.AREA, area_entry.id)
|
||||
self._async_resolve_up_area(area_entry.id)
|
||||
|
||||
# Devices with this label
|
||||
for device in dr.async_entries_for_label(self._device_registry, label_id):
|
||||
self._add(ItemType.DEVICE, device.id)
|
||||
self._async_resolve_up_device(device.id)
|
||||
|
||||
# Entities with this label
|
||||
for entity_entry in er.async_entries_for_label(self._entity_registry, label_id):
|
||||
self._add(ItemType.ENTITY, entity_entry.entity_id)
|
||||
self._async_resolve_up_entity(entity_entry.entity_id)
|
||||
|
||||
# If this entity also exists as a resource, we add it.
|
||||
domain = split_entity_id(entity_entry.entity_id)[0]
|
||||
|
||||
@@ -868,11 +868,20 @@ async def test_search(
|
||||
|
||||
assert not search(ItemType.LABEL, "unknown")
|
||||
assert search(ItemType.LABEL, label_christmas.label_id) == {
|
||||
ItemType.AREA: {living_room_area.id},
|
||||
ItemType.AUTOMATION: {"automation.label"},
|
||||
ItemType.CONFIG_ENTRY: {wled_config_entry.entry_id},
|
||||
ItemType.DEVICE: {wled_device.id},
|
||||
ItemType.FLOOR: {first_floor.floor_id},
|
||||
ItemType.INTEGRATION: {"wled"},
|
||||
}
|
||||
assert search(ItemType.LABEL, label_energy.label_id) == {
|
||||
ItemType.AREA: {kitchen_area.id},
|
||||
ItemType.CONFIG_ENTRY: {hue_config_entry.entry_id},
|
||||
ItemType.DEVICE: {hue_device.id},
|
||||
ItemType.ENTITY: {hue_segment_1_entity.entity_id},
|
||||
ItemType.FLOOR: {first_floor.floor_id},
|
||||
ItemType.INTEGRATION: {"hue"},
|
||||
}
|
||||
assert search(ItemType.LABEL, label_other.label_id) == {
|
||||
ItemType.AREA: {bedroom_area.id},
|
||||
@@ -881,6 +890,7 @@ async def test_search(
|
||||
person_paulus_entity.entity_id,
|
||||
script_scene_entity.entity_id,
|
||||
},
|
||||
ItemType.FLOOR: {second_floor.floor_id},
|
||||
ItemType.PERSON: {person_paulus_entity.entity_id},
|
||||
ItemType.SCENE: {scene_wled_hue_entity.entity_id},
|
||||
ItemType.SCRIPT: {"script.label", script_scene_entity.entity_id},
|
||||
|
||||
Reference in New Issue
Block a user