From 50cb652b5fafb8c02df95d63b3790bcf63a4db3b Mon Sep 17 00:00:00 2001 From: abmantis Date: Wed, 23 Jul 2025 12:59:39 +0100 Subject: [PATCH] Include non-primary entities targeted directly by label --- homeassistant/helpers/target.py | 5 +---- tests/helpers/test_target.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/homeassistant/helpers/target.py b/homeassistant/helpers/target.py index 239d1e66336..28acafa7566 100644 --- a/homeassistant/helpers/target.py +++ b/homeassistant/helpers/target.py @@ -174,10 +174,7 @@ def async_extract_referenced_entity_ids( selected.missing_labels.add(label_id) for entity_entry in entities.get_entries_for_label(label_id): - if ( - entity_entry.entity_category is None - and entity_entry.hidden_by is None - ): + if entity_entry.hidden_by is None: selected.indirectly_referenced.add(entity_entry.entity_id) for device_entry in dev_reg.devices.get_devices_for_label(label_id): diff --git a/tests/helpers/test_target.py b/tests/helpers/test_target.py index c87a320e378..9c00fb7c2ca 100644 --- a/tests/helpers/test_target.py +++ b/tests/helpers/test_target.py @@ -222,6 +222,13 @@ def registries_mock(hass: HomeAssistant) -> None: labels={"my-label"}, entity_category=EntityCategory.CONFIG, ) + diag_entity_with_my_label = RegistryEntryWithDefaults( + entity_id="light.diag_with_my_label", + unique_id="diag_with_my_label", + platform="test", + labels={"my-label"}, + entity_category=EntityCategory.DIAGNOSTIC, + ) entity_with_label1_from_device = RegistryEntryWithDefaults( entity_id="light.with_label1_from_device", unique_id="with_label1_from_device", @@ -266,6 +273,7 @@ def registries_mock(hass: HomeAssistant) -> None: entity_in_area_a.entity_id: entity_in_area_a, entity_in_area_b.entity_id: entity_in_area_b, config_entity_with_my_label.entity_id: config_entity_with_my_label, + diag_entity_with_my_label.entity_id: diag_entity_with_my_label, entity_with_label1_and_label2_from_device.entity_id: entity_with_label1_and_label2_from_device, entity_with_label1_from_device.entity_id: entity_with_label1_from_device, entity_with_label1_from_device_and_different_area.entity_id: entity_with_label1_from_device_and_different_area, @@ -384,7 +392,11 @@ def registries_mock(hass: HomeAssistant) -> None: {ATTR_LABEL_ID: "my-label"}, False, target.SelectedEntities( - indirectly_referenced={"light.with_my_label"}, + indirectly_referenced={ + "light.with_my_label", + "light.config_with_my_label", + "light.diag_with_my_label", + }, missing_labels={"my-label"}, ), ),