Skip to content

feat(live-chart): surface EV charger power as its own series - #190

Merged
frahlg merged 1 commit into
masterfrom
live-ev-charger
Apr 24, 2026
Merged

frahlg merged 1 commit into
masterfrom
live-ev-charger

Conversation

@frahlg

@frahlg frahlg commented Apr 24, 2026

Copy link
Copy Markdown
Member

Why

When the car is charging the Energy Balance overview clearly shows it (e.g. 7.20 kW), but the Live chart buries that power inside the Load line — so a pattern like "car started pulling 7 kW around 10:15" isn't visible at a glance. Fixes that by giving every EV charger its own series on the Live chart.

What

Mirrors the per-battery discovery already in place:

  • chartEVs map, one series per driver that reports ev_w.
  • Distinct fuchsia/magenta palette so EV lines can't be confused with battery (amber/purple) or PV (green).
  • Dynamic legend entry + click-to-hide, persisted alongside battery legend state.
  • Inline row in the hover tooltip. No "target" column — the EV driver just sends a current setpoint, there's no separate commanded power worth charting.
  • History replay resets and rediscovers both battery and EV sets, so a freshly-plugged-in charger appears on reload rather than waiting for a new status poll.

Test plan

  • go test ./... — 576 tests pass across 38 packages
  • JS syntax check (node --check)
  • Manual: plug in car, watch the Live chart for a new colored line under an EV legend entry. Toggle the legend item to hide/show. Check tooltip renders the EV row with a power value.

🤖 Generated with Claude Code

The Energy Balance overview shows EV charging power, but the Live chart
doesn't — so when the car is pulling 7 kW it's buried inside the Load
line. Now every driver that reports ev_w gets its own chart series
(one per charger), discovered and rendered the same way battery
drivers are.

Mirrors the per-battery discovery pattern:
  - chartEVs map with one series per driver (append on status tick,
    backfill zeros for drivers that go quiet so index alignment with
    chartHistory.timestamps is preserved)
  - Distinct fuchsia/magenta palette (EV_PALETTE) so EV lines can't be
    confused with battery lines (amber/purple) or PV (green)
  - Dynamic legend entry + click-to-hide, persisted via legendHidden
  - Inline EV row in the hover tooltip, without the battery's
    "target" column — EV chargers don't have a separate commanded
    power target worth charting
  - Reset-and-rediscover on history replay so a freshly-plugged-in
    charger shows up on next reload rather than waiting for a new
    /api/status poll
@frahlg
frahlg merged commit 1de21f9 into master Apr 24, 2026
1 check passed
@frahlg
frahlg deleted the live-ev-charger branch April 24, 2026 08:23

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5e124565c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/next-app.js
Comment on lines +125 to +126
var pad = chartHistory.timestamps.length;
var slot = { ev: new Array(pad).fill(0) };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pad new EV series to prior sample count

ensureEVDriver initializes slot.ev with chartHistory.timestamps.length zeros, but callers invoke it after pushing the current timestamp and then append the current ev_w sample. On the first sample for a charger this produces [0, firstSample, ...], so EV values become one index behind chartHistory.timestamps (the newest EV point is not shown at the current time). This affects both live updates (pushChartData) and history replay (loadHistory) whenever an EV driver is first discovered.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant