Skip to content

hello-sebastian/Energy-Horizon

Repository files navigation

Energy Horizon Card

Elegant energy comparisons for Home Assistant dashboards — cumulative usage now vs a historical reference, with optional forecast.

Home Assistant version HACS License

  • Clear comparisons: see “this period so far” vs a reference period at a glance.
  • Readable timelines: smart axis labels that stay legible on mobile.
  • Always-usable charts: automatic aggregation keeps the chart clean.
  • Optional forecast: a dashed estimate for the period total when it’s meaningful.

This card is built for long-term statistics (energy history), not live power charts.

Energy Horizon Card screenshot

Quick start (copy/paste)

1) Install

  • HACS (recommended): HACS → FrontendAdd repository → install Energy Horizon Card → restart Home Assistant.
  • Manual: download energy-horizon-card.js from the latest release → copy to config/www/.

2) Add the Lovelace resource

Settings → Dashboards → Resources:

url: /hacsfiles/energy-horizon-card/energy-horizon-card.js
type: module

Manual installs usually use:

url: /local/energy-horizon-card.js
type: module

3) Add the card

type: custom:energy-horizon-card
entity: sensor.your_energy_statistic
comparison_preset: year_over_year

4) If you see an empty chart

Most often, the selected entity has no long-term statistics.

Basic configuration (first knobs to turn)

These are the options most people adjust first. Everything else is in the Wiki and README.advanced.md.

Option What it does Learn more
comparison_preset Pick the comparison: year-over-year / month-over-year / month-over-month. First Comparisons: Quick Recipes
aggregation Control the chart resolution (hour/day/week/month) or omit for auto. How-To: Aggregation & Performance
show_forecast Show/hide the dashed forecast line. Forecast and Data Internals
precision Decimal places for UI numbers. Configuration and Customization
force_prefix Unit scaling (auto, none, k, M, …). Configuration and Customization
primary_color Current series line/fill color; default is the card’s brand teal (#119894). Use ha-primary or var(--primary-color) to follow your HA theme. README.advanced.md
show_comparison_summary, show_forecast_total_panel, show_narrative_comment Hide specific card sections (comparison panel, Forecast | Total panel, narrative comment). Configuration and Customization
title, icon Card header customization. Configuration and Customization

Key features (in plain words)

Smart X-axis (labels that “just make sense”)

The card adjusts date/time labels automatically so they stay readable (especially on phones). With two or more windows, the shared axis length follows the largest nominal slot count at the chart’s aggregation (e.g. February vs March at daily grain uses 31 slots); tick dates follow window 0’s calendar (with an ordinal tail if the axis is longer), and the “now” marker is based on today inside window 0. Forecast progress still uses window 0 only, so the axis can be longer than the forecast period. Tooltip headers use that same slot index and the Home Assistant time zone for calendar text (not the browser’s zone). For YoY/MoY/MoM, adaptive labels drop redundant years or months so the axis matches the comparison story (see wiki mental model). Long-term statistics that expose sum are mapped so each daily (or hourly) increment sits under the correct calendar bucket on that axis; when LTS has only min/max (common for misclassified cumulative templates), increments use max - min. See Forecast and Data Internals and README.advanced.

Automatic aggregation

If you don’t set aggregation, the card picks a sensible bucket size so you get a clear chart instead of thousands of cramped points.

Forecast

When there’s enough data and a valid reference, the dashed line estimates the period total based on your history.

Advanced configuration (power users)

Want more control? Start here:

Documentation map

Support and releases

If this card saves you time, you can support development:

Buy Me A Coffee Buy me a coffee on buycoffee.to

Development

Stack: TypeScript (strict), Lit 3, Apache ECharts 5, Luxon 3 (time windows), Vite 6, Vitest 2.

User-visible strings live in src/translations/ (en.json is the key reference). Use one full sentence per message with {{camelCase}} placeholders for injected values — see specs/002-i18n-localization/.

npm install
npm run build
npm run dev
npm test
npm run lint

License

MIT

About

A Lovelace card for Home Assistant that compares cumulative energy usage between the current period and a corresponding historical period (eg. year-over-year or month-over-year), with a chart, summary stats, and optional forecast.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors