fix(areas): return area-controls in canonical order, not entity-iteration order (closes #201)#249
Open
TheDave94 wants to merge 1 commit into
Open
Conversation
…mon42#201) getAreaControls used Set insertion order to determine the order of shortcut icons on area cards. The Set was populated by iterating the entity registry, which returns entities in registration order — that order varies between areas, so two rooms with the same control mix (e.g. light + cover) could end up with the icons in different orders on the area card. Fix: filter CONTROL_DOMAINS by what was found, so the output order is always canonical (light → fan → switch → cover-* in the order declared in the constant). No behaviour change for areas where Set insertion happened to match the canonical order; rooms with reversed order now align with the rest. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #201 — area card shortcut icons (light, cover-shutter, etc.) could appear in a different order between rooms with the same control mix. The reporter saw "light then shutter" in most rooms but "shutter then light" in one specific room, with no obvious reason.
Root cause
`getAreaControls` populated a `Set` while iterating `Registry.getVisibleEntitiesForArea(...)` and returned `[...found]`. JS `Set` preserves insertion order, and the entity registry returns entities in registration order, which differs across areas (depending on when each device was added to HA). So:
light, cover-shutter→ renders "light, shutter"cover-shutter, light→ renders "shutter, light"Fix
Replace
[...found]withCONTROL_DOMAINS.filter((d) => found.has(d)), which uses the canonical declaration order ofCONTROL_DOMAINS(light → fan → switch → cover-shutter → ... → cover-damper). Rooms whose icons happened to be in that order are unchanged; rooms with reversed order now align with the rest.Test plan
AI-drafted under human supervision by @TheDave94. Tested live on Home Assistant — fully when the relevant hardware is available, otherwise only along the code paths that don't require an actual sensor of that type.