Fix/activity, Area#9
Merged
Merged
Conversation
Add two new shared views to both the Lovelace card and integration panel: - By Activity: circuits sorted by power consumption with expandable graphs - By Area: circuits grouped by HA area with expandable graphs Both views share rendering code via ListViewController and reuse renderCircuitSlot for expanded circuit cards. Includes search filtering, W/A unit toggle, area resolution at discovery time with live registry subscriptions, and configurable tab style (text/icon) for the card.
There was a problem hiding this comment.
Pull request overview
This PR adds two new list-style ways to browse circuits—By Activity and By Area—to both the integration panel UI and the Lovelace card, backed by Home Assistant registry-based area resolution.
Changes:
- Add shared tab bar rendering + new By Activity / By Area tabs in the panel and card.
- Implement list views (search, expand/collapse, unit toggle) and HA area resolution with live registry update subscriptions.
- Add card editor option for tab style (text vs icon) and bump version to 0.9.2 (plus a chart update fix).
Reviewed changes
Copilot reviewed 16 out of 19 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Adds Circuit.area and CardConfig.tab_style types. |
| src/panel/span-panel.ts | Adds Activity/Area tabs and list-view rendering inside the integration panel. |
| src/i18n.ts | Adds new tab/list/editor strings across supported languages. |
| src/editor/span-panel-card-editor.ts | Adds a “Tab Style” selector to the card editor. |
| src/core/tab-bar-renderer.ts | New helper to render a shared tab bar + delegated click binding. |
| src/core/list-view-controller.ts | New controller for list views (rendering, search filtering, expand/collapse, unit change events). |
| src/core/list-renderer.ts | New HTML builders for list UI pieces (rows, expanded content, headers). |
| src/core/grid-renderer.ts | Updates renderCircuitSlot to support inline rendering and hides unknown shedding icon. |
| src/core/area-resolver.ts | New HA registry-based area resolver + live update subscription helper. |
| src/constants.ts | Bumps CARD_VERSION to 0.9.2. |
| src/chart/chart-update.ts | Ensures ha-chart-base receives hass before insertion. |
| src/card/span-panel-card.ts | Adds tabs + list views to the Lovelace card and wires unit-change behavior. |
| src/card/card-styles.ts | Adds shared tab bar and list view styling. |
| src/card/card-discovery.ts | Assigns areas during discovery via resolveAndAssignAreas. |
| package.json | Bumps package version to 0.9.2. |
| package-lock.json | Updates lockfile version metadata to 0.9.2. |
| CHANGELOG.md | Documents the new views, tab bar, and chart fix for 0.9.2. |
- Escape tab.id and tab.icon in buildTabBarHTML via escapeHtml() - Escape t() output in HTML attributes (placeholder, title) - Replace innerHTML error rendering with createElement + textContent - Wrap async area registry handler in try/catch
The By Activity / By Area search filter was lost whenever subscribeAreaUpdates fired (entity or area registry change), because renderActivityView/renderAreaView rebuilt the DOM via innerHTML with a fresh empty search input while _searchQuery persisted only on the controller and was never re-applied. Thread _searchQuery through buildSearchBarHTML so the input renders with its current value, and extract the filtering logic into _applyFilter so both the input handler and render paths apply identical filter state.
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.
Add 'By Activity' and 'By Area' in addition to the existing 'By Panel' views.