span integration configurable frontend and card#3
Merged
cayossarian merged 102 commits intomainfrom Apr 3, 2026
Merged
Conversation
Show amps instead of watts when chart_metric is set to current. Fix Y-axis to 0-125% of breaker rating with NEC reference lines at 80% (yellow, continuous load limit) and 100% (red, breaker rating). Add total current stat to panel header from main meter amperage attribute.
Move _loadHistory, _loadStatisticsHistory, _loadRawHistory, and _collectSubDeviceEntityIds out of SpanPanelCard into src/core/history-loader.js. Export loadHistory and collectSubDeviceEntityIds; internal helpers are module-private. Update _recordPowerHistory to use the imported collectSubDeviceEntityIds and remove now-unused imports.
Move _updateDOM, _updateSubDeviceDOM, and _findPanelEntity out of SpanPanelCard into src/core/dom-updater.js as pure functions updateCircuitDOM, updateSubDeviceDOM, and a module-private _findPanelEntity. The card delegates to these via a thin _updateDOM wrapper.
Moves panel header HTML out of _render() into buildHeaderHTML() in src/core/header-renderer.js. New header adds Grid state, Upstream, Downstream, and A/W unit toggle button with gear icon for panel monitoring config. Adds supporting CSS for gear icon and unit toggle.
Add delegated click handler for .unit-btn buttons that updates chart_metric config and fires config-changed for Lovelace persistence. Update _updateHeaderStats to accept config and switch all header stat values (consumption, upstream, downstream, solar) between kW and A display based on chart_metric, including unit label updates. Battery remains SoC % and grid state shows DSM state text.
Adds a compact summary bar that appears when monitoring is active, showing circuit and mains counts alongside warning, alert, and override counts. Hidden entirely when monitoring is disabled.
Add window duration and cooldown fields to circuit monitoring config (cooldown is read-only/disabled as it is a global-only setting). Wrap all service calls in error handling and display inline errors that auto-dismiss after 5 seconds.
Replace fragile hass.states pattern-matching helpers (_findPanelEntity, _hasPanelEntity, _hasSolarEntity) with direct lookups from topology.panel_entities. Remove the helper functions entirely and drop the now-unnecessary hass parameter from buildHeaderHTML.
- Site stat reads from panel_entities.site_power instead of current_power - Solar stat reads from panel_entities.pv_power entity directly instead of summing circuit power by device_type - A/W toggle wired through panel shell with localStorage persistence - Monitoring tab uses callWS with explicit return_response schema - Monitoring tab shows inline enable toggle and editable global settings calling set_global_monitoring service instead of dead config flow link - Gear icons open side panel in dashboard; panel gear navigates to Monitoring tab - Toggle pills clickable in panel view (turn relays on/off) - Off circuits keep toggle and gear at full opacity - Panel selector always visible (label for single, dropdown for multi) - Settings tab links to specific config entry - Side panel "Configure Global Thresholds" navigates to Monitoring tab instead of crashing by navigating away from custom panel - hass reference propagated from panel shell to dashboard tab on updates
- Unchecking Enabled calls set_global_monitoring with enabled:false - Re-renders tab after enable/disable to reflect current state
- All/None toggle checkbox above all monitored points - Mains and circuits in single unified table - Mains breaker shown as single 240V entry above circuits - Per-circuit and per-mains toggle checkboxes - Toggle-all applies to both mains and circuits
- Fix ha-switch toggle reading hasAttribute instead of .checked property, causing monitoring_enabled to always send true - Check monitoring_enabled field when rendering initial toggle state - Add cache invalidation on side-panel close for fresh data on reopen - Dispatch side-panel-closed event from close() method - Use entity power key consistently for monitoring info lookup - Add inline threshold editing in monitoring tab with debounced saves - Update shedding priority icons on DOM refresh - Use has_override field for override count in summary bar
After saving global threshold changes, re-render the full table so circuits without overrides immediately reflect the new values.
Filter BESS/EVSE sub-devices from panel selector by excluding devices with via_device_id. Pass config_entry_id through all monitoring tab service calls so the correct panel's monitor is targeted. Add cooldown column to the monitored points table.
Remove readOnly flag from cooldown duration row in sidebar. Include cooldown_duration_m in both threshold save handlers and use entity ID consistently for circuit_id. Use hass.formatEntityState for DSM grid state display.
_callDomainService unconditionally sent return_response: true on every WS call, but mutation services (set/clear horizon, set/clear threshold) don't declare supports_response, causing HA to reject them.
Render four simulated circuit cards with power chart lines when the card has no device configured, replacing the plain text placeholder.
The card has no monitoring configuration UI, so showing the toggle is misleading. Add showMonitoring flag to DashboardController and CircuitModeConfig; only the panel dashboard sets it to true.
- Fix t() fallback in horizon selects (t() returns the key when missing, so || fallback never fires; compare against key instead) - Fix inaccurate pruning comments in history.ts (findIndex is linear, not binary) - Use hass.formatEntityState for sub-device entity display values - Add grid.configure_subdevice i18n key for sub-device gear tooltip
Set min-height on chart container from the chart height constant so aspect-ratio cannot shrink it below the chart size on mobile. Read container.clientHeight to size the chart dynamically, allowing it to fill taller containers on wide viewports.
c032717 to
e91cb23
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 58 out of 64 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/editor/span-panel-card-editor.ts:45
- The editor uses
t()for user-facing strings but never callssetLanguage(hass.language), so it will stay in the default language unless some other component happens to set the i18n module’s global language first. ImportsetLanguageand call it in thehasssetter to ensure the editor UI follows HA’s language.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ncy, and tab cleanup - Escape error message in tab-dashboard via escapeHtml to prevent XSS - Use current ?? power entity for monitoring lookup in dashboard-controller to match grid-renderer - Stop all tabs (monitoring, settings) when switching in span-panel to prevent listener leaks
…ggle - Remove standalone Persistent Alerts checkbox (covered by notify.persistent_notification target) - Remove standalone Event Bus checkbox (now a selectable target in dropdown) - Remove legacy notify.notify broadcast and notify.send_message from target discovery - Add "All" checkbox to select/deselect all targets at once - Add Event Bus as virtual target with event type and payload help text - Add "Send Test" button to dispatch sample notification to selected targets - Show friendly label for event_bus in dropdown button text - Flush pending saves before test dispatch to ensure latest selections are used
When the browser is backgrounded for an extended period, HA may drop the websocket and the panel's shadow DOM can become empty. Previously the visibilitychange handler only called _renderTab() which silently returned when #tab-content was missing, leaving a blank panel. - visibilitychange handler now checks for #tab-content and calls _render() to rebuild the full shell if it was lost - set hass() setter also guards against lost DOM after reconnection
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 58 out of 64 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
src/editor/span-panel-card-editor.ts:45
- The editor uses translated strings via
t(...), but it never callssetLanguage(hass.language). If the editor is opened when the card/panel hasn't already set the language (or after a language change), it will render in the default language. CallsetLanguage(hass.language)in the editor’shasssetter (before building UI) to keep translations in sync with Home Assistant.
…ency, and stale state - Guard against undefined dataset values in _bindCircuitHorizons and _bindResetButtons - Match Wh→kWh display conversion in updateSubDeviceDOM to match initial render - Clear horizon maps at start of buildHorizonMaps to prevent stale overrides
The side panel incorrectly showed "Custom" for all circuits because it checked continuous_threshold_pct !== undefined, but the backend always includes resolved threshold values. Use has_override instead, matching the pattern used in tab-settings and tab-monitoring.
When graph settings change (from settings tab or side panel), the open side panel now refreshes with current data. The dashboard controller queries the side panel for its open context (circuit/subdevice/panel) and pushes fresh graphHorizonInfo. Also invalidates the dashboard cache when settings change from the settings tab so tab switches show current data.
…ges" This reverts commit 5a88bbc.
When the browser tab is hidden and HA's WebSocket drops, the panel goes blank. On visibility restore, _renderTab may fail if the WS is still reconnecting. Extract _recoverIfNeeded with retry logic (up to 3 attempts with backoff) so the panel recovers once the connection is re-established.
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.
span repo dashboard changes inclusive
Configurable chart horizons, global and circuit
Span repo frontend with monitoring controls