Repository navigation
Redirect repairs to the first view with unknown entities - #1172
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe extractor now returns a mapping entity_id → view_path (int|string). The inspector calls the extractor once per dashboard, uses the mapping keys to identify unknown entities, and builds edit URLs using the mapping’s first_view_path for the first unknown entity. ChangesEntity extraction & inspector
Sequence Diagram(s)sequenceDiagram
participant Inspector
participant Extractor
participant IssueCreator
Inspector->>Extractor: __async_extract_entities(config) -> dict(entity_id -> view_path)
Inspector->>Inspector: compute unknown IDs from extracted.keys()
Inspector->>IssueCreator: create issue with edit URL using first_view_path
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@custom_components/spook/ectoplasms/lovelace/repairs/unknown_entity_references.py`:
- Around line 71-72: unknown_entities is a set so using
next(iter(unknown_entities)) yields an arbitrary entity; to pick the first
unknown entity by view order, iterate the insertion-ordered mapping
extracted_entities and select the first key present in unknown_entities, then
assign its value to first_view_path (update the code around first_view_path =
extracted_entities[next(iter(unknown_entities))] to search
extracted_entities.keys() for the first key in unknown_entities).
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@custom_components/spook/ectoplasms/lovelace/repairs/unknown_entity_references.py`:
- Around line 71-76: The StopIteration is caused by keys in extracted_entities
containing comma-separated raw strings while async_filter_known_entity_ids
returns split entity IDs; update __async_extract_entities to normalize/split and
strip comma-separated entity strings into individual keys (e.g., produce entries
for "light.a" and "light.b" rather than "light.a, light.b") so the lookup used
by the next(...) that computes first_view_path against unknown_entities
succeeds; ensure extracted_entities remains a mapping from single entity_id ->
path and adjust any deduplication logic accordingly.
|
b444268 to
bc46c81
Compare
|
I rebased this onto current |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1172 +/- ##
==========================================
+ Coverage 56.84% 56.99% +0.14%
==========================================
Files 119 119
Lines 3008 3016 +8
Branches 382 386 +4
==========================================
+ Hits 1710 1719 +9
- Misses 1260 1261 +1
+ Partials 38 36 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the Lovelace “unknown entity references” repair so the generated “edit” link targets the first view that actually contains an unknown entity, instead of always linking to view 0. This improves usability for dashboards with multiple views by taking users directly to the relevant view (using the view’s path when available, otherwise the view index).
Changes:
- Update entity extraction to return a mapping of
entity_id -> view_path_or_indexto enable view-aware repair links. - Build the repair “edit” URL using the first view that contains an unknown entity.
- Expand tests to validate view-path/index behavior, duplicate entity handling, and comma-separated entities.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
custom_components/spook/ectoplasms/lovelace/repairs/unknown_entity_references.py |
Extracts entities with associated view path/index and uses that to build the repair edit link. |
tests/ectoplasms/lovelace/repairs/test_unknown_entity_references.py |
Updates/extends tests to assert view-aware extraction behavior and the new mapping shape. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|



Description
Redirect repairs to the first view with unknown entities
Motivation and Context
Previously, the "unknown entity references" repair always linked to view
0regardless of which view actually contained the missing entity. This made it harder for users to find and fix the issue, especially in dashboards with many views.Now the repair link points directly to the first view that contains an unknown entity, using the view's path if set or falling back to the view index.
How has this been tested?
Manual testing with dashboards containing multiple views where unknown entities exist in views other than the first one.
Screenshots (if appropriate):
Types of changes
Checklist