208 files

This commit is contained in:
Home Assistant Version Control
2026-10-07 02:49:21 +00:00
parent a7107ecbe1
commit cfd0d40c8e
208 changed files with 5434 additions and 901 deletions
@@ -13,6 +13,7 @@ from ....action_extraction import (
async_extract_entities_from_value,
)
from ....entity_filtering import async_get_all_entity_ids, async_get_all_services
from ....reference_extraction import without_disabled_steps
from ....template_extraction import (
KNOWN_DOMAINS,
async_extract_entities_from_config,
@@ -291,6 +292,21 @@ class SpookRepair(AbstractSpookAutomationReferencesRepair):
)
self._known_services = async_get_all_services(self.hass)
async def _async_named_in(self, config: dict[str, Any]) -> set[str]:
"""Return the entities a configuration names, the way this repair reads it.
The same reading the report is built from, structure and templates
alike, so comparing it with and without the disabled steps leaves out
exactly what only those name.
"""
named = await extract_entities_from_automation_config(
self.hass, config, self._known_services
)
named |= await async_extract_entities_from_config(
self.hass, config, self._known_services
)
return named
async def _async_compute_unknown_references(self, entity: Any) -> set[str]:
"""Return unknown entity IDs referenced by ``entity`` (incl. templates)."""
all_entities = set(entity.referenced_entities)
@@ -314,6 +330,15 @@ class SpookRepair(AbstractSpookAutomationReferencesRepair):
)
)
# Home Assistant's own list includes disabled steps, triggers and
# conditions too. Something parked that way does nothing, so what only
# it names is left out of the report: whatever this repair finds in
# the configuration, and no longer finds once those are pruned.
if isinstance(raw_config := getattr(entity, "raw_config", None), dict):
named = await self._async_named_in(raw_config)
still_named = await self._async_named_in(without_disabled_steps(raw_config))
all_entities -= named - still_named
return await async_filter_known_entity_ids_with_templates(
self.hass,
entity_ids=all_entities,