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
@@ -9,7 +9,9 @@ from homeassistant.helpers import device_registry as dr
from ....entity_filtering import async_filter_known_device_ids, async_get_all_device_ids
from ....reference_extraction import (
core_references,
extract_targets_from_config,
names_given_to_templates,
only_in_disabled_steps,
)
from ....template_extraction import extract_device_ids_from_config
@@ -74,7 +76,7 @@ class SpookRepair(AbstractSpookAutomationReferencesRepair):
async def _async_compute_unknown_references(self, entity: Any) -> set[str]:
"""Return unknown device IDs referenced by ``entity``."""
device_ids = set(entity.referenced_devices)
device_ids = core_references(entity, "devices")
if hasattr(entity, "raw_config") and entity.raw_config:
# Also walk the raw configuration; the built-in extraction misses
@@ -92,14 +94,18 @@ class SpookRepair(AbstractSpookAutomationReferencesRepair):
entity.raw_config.get("triggers")
)
)
# Devices referenced via device_entities() in templates.
device_ids.update(extract_device_ids_from_config(entity.raw_config))
# Devices referenced through the device functions in templates.
# The variables and fields it gives its templates hide a call.
shadowed = names_given_to_templates(entity.raw_config)
device_ids.update(
extract_device_ids_from_config(entity.raw_config, shadowed)
)
# A disabled step does nothing, so what only it names is left out.
device_ids -= only_in_disabled_steps(
entity.raw_config,
lambda found: (
extract_targets_from_config(found).device_ids
| extract_device_ids_from_config(found)
| extract_device_ids_from_config(found, shadowed)
),
)