291 files

This commit is contained in:
Home Assistant Version Control
2026-10-14 18:10:18 +00:00
parent c4e0178d8a
commit 280501d2e8
291 changed files with 32540 additions and 3280 deletions
@@ -2,6 +2,7 @@
from __future__ import annotations
from functools import partial
from typing import TYPE_CHECKING
from homeassistant.components import script
@@ -9,7 +10,8 @@ from homeassistant.helpers import label_registry as lr
from ....entity_filtering import async_filter_known_label_ids, async_get_all_label_ids
from ....reference_extraction import (
extract_targets_from_config,
async_raw_config_references,
core_references,
only_in_disabled_steps,
)
from ....repairs import AbstractSpookEntityComponentUnknownReferencesRepair
@@ -39,16 +41,17 @@ class SpookRepair(AbstractSpookEntityComponentUnknownReferencesRepair):
async def _async_compute_unknown_references(self, entity: Any) -> set[str]:
"""Return unknown label IDs referenced by ``entity``."""
label_ids = set(entity.script.referenced_labels)
label_ids = core_references(entity, "labels")
# Also walk the raw configuration; the built-in extraction misses
# references nested in some step types, like repeat sequences.
if raw_config := getattr(entity, "raw_config", None):
label_ids.update(extract_targets_from_config(raw_config).label_ids)
# Templates that look up a label that is not there are read too.
references = partial(async_raw_config_references, self.hass, kind="labels")
label_ids.update(references(raw_config))
# A disabled step does nothing, so what only it names is left out.
label_ids -= only_in_disabled_steps(
raw_config, lambda found: extract_targets_from_config(found).label_ids
)
# Read the same way, or a template there still counts.
label_ids -= only_in_disabled_steps(raw_config, references)
return async_filter_known_label_ids(
self.hass,