diff --git a/homeassistant/components/search/__init__.py b/homeassistant/components/search/__init__.py index 22d749d7cb59..2dd93008fd4d 100644 --- a/homeassistant/components/search/__init__.py +++ b/homeassistant/components/search/__init__.py @@ -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] diff --git a/tests/components/search/test_init.py b/tests/components/search/test_init.py index 54186cad4f94..3352250630cf 100644 --- a/tests/components/search/test_init.py +++ b/tests/components/search/test_init.py @@ -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},