Detect unknown entity references in Template helpers (config-entry based) #1285
Unanswered
pos-ei-don
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem?
Spook's
unknown_entity_referencesrepairs coverautomation,script,scene,lovelace(andgroupviaunknown_members). They do not cover UI-created Template helpers (thetemplateintegration, config-entry based). There is notemplateectoplasm at all.The config-entry helpers that do have repairs (
trend,utility_meter,switch_as_x,integration) only check a singlesource_entityviaunknown_source.py— not multi-ref / template scanning.Result: entity references inside Template helpers break silently. In my setup several were dead for months — Jinja
state/availabilitytemplates andturn_on/turn_offaction targets pointing at renamed/removed entities — and Spook never flagged them, while the same broken refs in automations were flagged.Proposed approach (gauging interest before I open a PR)
A new
ectoplasms/template/repairs/unknown_entity_references.pythat iterateshass.config_entries.async_entries("template")and scansentry.options. The HAtemplateconfig flow stores every entity-ref-bearing field through just two selector types:TemplateSelector(Jinja strings) →async_extract_entities_from_template_stringActionSelector(action sequences) → the recursiveextract_entities_from_action_configalready used by the automation repairSo a generic scan over
entry.options.values()reuses Spook's existing extraction (incl. the proven service-name handling,all/none, template-aware filtering) — no per-helper-type field list needed. It would honor the usualautomatically_clean_up_issues, skip disabled helpers, and filterthis.*self-refs.One open question for you
The cleanest way to map a
templateconfig entry → itsentity_id/ edit URL for the issue placeholders (registry lookup byconfig_entry_id?), since these helpers span many platforms and the entity object may not carry the raw config.Happy to do the implementation + tests (mirrored on the automation repair test) if you're open to it. Would you take such a PR?
Beta Was this translation helpful? Give feedback.
All reactions