Include non-primary entities targeted directly by label

This commit is contained in:
abmantis 2025-07-23 12:59:39 +01:00
parent eb8ca53a03
commit 50cb652b5f
2 changed files with 14 additions and 5 deletions

View File

@ -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):

View File

@ -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"},
),
),