Skip to content

fix(history): record per-driver ev_w so live chart can plot EV power - #209

Merged
erikarenhill merged 1 commit into
masterfrom
fix-livechart-ev-zero
Apr 27, 2026
Merged

erikarenhill merged 1 commit into
masterfrom
fix-livechart-ev-zero

Conversation

@erikarenhill

Copy link
Copy Markdown
Collaborator

Summary

The live chart's EV trace was always zero. recordHistory() in main.go was packing per-driver bat_w / pv_w / meter_w into the history JSON column but not ev_w — so the chart's per-driver lookup (`d.ev_w` in `web/next-app.js:1866`) returned undefined and the trace plotted as zero.

The in-memory `/api/status` path was unaffected (it always emitted `ev_w` from the easee-cloud driver), which is why operators saw the correct number on the dashboard cards but a flat-zero chart.

Fix

Pull `DerEV.SmoothedW` into the per-driver history row alongside the existing types. Three lines.

if r := tel.Get(name, telemetry.DerEV); r != nil {
    row[\"ev_w\"] = r.SmoothedW
}

Verification

5-step 3Φ ramp at 6/7/8/9/10 A on a real Easee charger:

Step Requested W Observed ev_w
6A 3Φ 4140 0 (awaiting start)
7A 3Φ 4830 4774
8A 3Φ 5520 5470
9A 3Φ 6210 6108
10A 3Φ 6900 6793

/api/history history points now show the same values inside the per-driver easee-cloud map, and the live chart renders the stair-step trace as expected.

Why no test

The fix is a single-pass-through line in recordHistory and is verified end-to-end against real hardware. Adding a cmd/forty-two-watts unit test would require lifting recordHistory into a testable package — appropriate for a follow-up refactor, not this minimal bug fix.

🤖 Generated with Claude Code

The dashboard's live chart (web/next-app.js:1866) reads `d.ev_w` per
driver from /api/history to plot the EV trace. recordHistory() in
main.go was packing per-driver bat_w / pv_w / meter_w into the
history JSON column but never ev_w — so the chart's per-driver
lookup returned undefined for EV drivers and the trace plotted as
zero.

The in-memory /api/status path was unaffected (it always emitted
ev_w from the easee-cloud driver), which is why operators saw the
correct number on the dashboard cards but a flat-zero chart.

Fix: pull DerEV.SmoothedW into the per-driver row alongside the
existing types.

Verified on hardware: 5-step 3Φ ramp at 6/7/8/9/10 A produced the
expected stair-step values in /api/history (0 → 4774 → 5470 → 6108
→ 6793 W) and rendered correctly on the live chart.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes missing per-driver EV power (ev_w) in persisted history points so the web live chart can correctly plot EV charging power from /api/history.

Changes:

  • Adds telemetry.DerEV sampling to recordHistory()’s per-driver JSON payload (drivers[driver].ev_w).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@erikarenhill
erikarenhill merged commit 64049f8 into master Apr 27, 2026
5 checks passed
@erikarenhill
erikarenhill deleted the fix-livechart-ev-zero branch April 27, 2026 10:08
HuggeK pushed a commit to HuggeK/ftw that referenced this pull request Nov 10, 2026
…ware 7.x (srcfl#1962)

Moves the pin to srcfl/device-drivers@e463c653 (srcfl#209). Only the Zap driver
changes. The new tests use the payload a Zap on 7.0.3 sent for a simulated
Solis.

Signed-off-by: David Mozart <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants