Skip to content

Add energy grid balance card#51480

Open
MindFreeze wants to merge 7 commits intodevfrom
energy-grid-balance-card
Open

Add energy grid balance card#51480
MindFreeze wants to merge 7 commits intodevfrom
energy-grid-balance-card

Conversation

@MindFreeze
Copy link
Copy Markdown
Member

@MindFreeze MindFreeze commented Apr 9, 2026

Proposed change

Add a new energy card that displays grid energy as an equation showing imported energy minus exported energy equals net consumption. The card includes a visual bar gauge that represents the ratio between imported and exported energy, with the bar filling from a center line toward the dominant direction.
There are tooltips explaining the values

The card is automatically added to the energy dashboard sidebar when grid return (export) is configured.

In theory we can have the same card for batteries but I don't see the value there. And efficiency losses would complicate it.

Screenshots

image

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

To help with the load of incoming pull requests:

Add a new energy card that displays grid energy as an equation
(imported - exported = net) with a visual bar gauge showing the
balance between grid import and export. The card appears in the
energy dashboard sidebar when grid return is configured.
@MindFreeze
Copy link
Copy Markdown
Member Author

This started as something different but it ended up as kind of a replacement for the energy-grid-neutrality-gauge card, so I wonder if we should indeed remove that card from the dashboard 🤔

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new built-in Energy dashboard card to visualize grid import/export as an equation and centered balance bar, and wires it into the Energy dashboard strategy so it is auto-inserted when grid export is configured.

Changes:

  • Introduces hui-energy-grid-balance-card rendering an import − export = net equation with tooltips and a balance bar.
  • Registers the new card type for Lovelace lazy-loading and adds a new energy card config type.
  • Auto-adds the new card to the Energy dashboard sidebar (and a small-screen section) when grid return/export is configured, plus adds English translations.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/translations/en.json Adds localization strings for the new grid balance card title/tooltips.
src/panels/lovelace/create-element/create-card-element.ts Registers energy-grid-balance for lazy-loaded card creation.
src/panels/lovelace/cards/types.ts Adds EnergyGridBalanceCardConfig for the new card type.
src/panels/lovelace/cards/energy/hui-energy-grid-balance-card.ts Implements the new grid balance card UI and data subscription.
src/panels/energy/strategies/energy-view-strategy.ts Auto-inserts the new card into the Energy dashboard when export is configured.

Comment thread src/panels/lovelace/cards/energy/hui-energy-grid-balance-card.ts
Comment thread src/panels/lovelace/cards/energy/hui-energy-grid-balance-card.ts
Comment thread src/panels/energy/strategies/energy-view-strategy.ts Outdated
Comment thread src/panels/lovelace/cards/types.ts
Only add the grid balance card to the dashboard when both import
and export meters are configured, not just export alone.
Add getConfigElement, getStubConfig, editor type union registration,
card registry entry, and documentation URL mapping.
@MindFreeze MindFreeze marked this pull request as ready for review April 9, 2026 10:35
Comment thread src/translations/en.json Outdated
- Split equation tooltip into per-value tooltips matching the bar
- Use custom title from config if provided
- Render with zeros when grid data is missing instead of blank
- Add card name and description for the card picker
- Handle small values with significant digit formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants