Skip to content

fix(driver): ferroamp aggregates battery across N ESOs - #295

Merged
frahlg merged 3 commits into
masterfrom
fix/ferroamp-multi-eso
May 25, 2026
Merged

fix(driver): ferroamp aggregates battery across N ESOs#295
frahlg merged 3 commits into
masterfrom
fix/ferroamp-multi-eso

Conversation

@erikarenhill

Copy link
Copy Markdown
Collaborator

Summary

  • ferroamp.lua cached only the most-recently-published ESO in a single eso_data slot, so the battery power readout was the per-unit number instead of the cluster aggregate. On a 2×ESO site this halved bat_w; the controller's grid-chase loop fed on the wrong number and dispatch stuck ~190 W of import against a 0 W target.
  • Replace the single slot with eso_data_by_id keyed on each ESO's id field. Sum DC power across all live ESOs (cell-monitor ubat × ibat), average voltage / SoC / DC-link, sum currents and Wh counters, surface per-ESO faults via worst-of relay/faultcode.
  • Backward-compatible: messages without an id field land under a synthetic key, so single-ESO firmware and sims keep behaving identically.
  • New eso_count diagnostic metric so operators can see how many ESOs the driver is summing.

How it was discovered

Live debugging session on a 2×ESO (21030026 + 23010216) Ferroamp install:

Source Battery output
42 bat_w 153 W
Ferroamp ehub.pbat (aggregate DC) 306 W
Σ per-ESO ubat × ibat 305.8 W

After the fix the same site shows ratio 1.00 between 42 and ehub.pbat, and the grid chase converges normally.

Test plan

  • go test ./internal/drivers/ -run Ferroamp -v — 8 existing tests + 2 new (TestFerroampDriverSumsBatteryPowerAcrossMultipleESOs, TestFerroampDriverSurfacesPerESOFaultsWorstOf)
  • go test ./... — full suite green
  • Deployed to a live 2×ESO site; bat_w matches ehub.pbat 1:1 over multiple snapshots; dispatch target tracks delivered discharge; grid converged inside grid_tolerance_w.

🤖 Generated with Claude Code

Single-slot `eso_data` cache reflected only the most-recently-published
ESO. At a 2×ESO site this halved bat_w; the controller's grid-chase
loop fed on the wrong number and dispatch stuck ~190 W of import
against a 0 W grid target. Switch to a per-ESO map keyed by `id`, sum
DC power across all live ESOs, average ubat / SoC / DC-link voltage,
sum ibat and Wh counters, and surface per-ESO faults via worst-of.
Backward-compatible: messages without `id` land under a synthetic key,
so single-ESO setups behave identically.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@erikarenhill

Copy link
Copy Markdown
Collaborator Author

@frahlg please have a test-drive with this driver in your system too and merge if its working. Tested on a ferroamp site with 2 ESO's which fixed lots of incorrect reportings

@erikarenhill
erikarenhill requested a review from frahlg May 24, 2026 21:15
@frahlg
frahlg merged commit cc4099c into master May 25, 2026
1 check passed
@frahlg
frahlg deleted the fix/ferroamp-multi-eso branch May 25, 2026 09:00
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