Skip to content

fix(ferroamp): read per-phase grid current from iext not il - #161

Merged
frahlg merged 1 commit into
masterfrom
160-ferroamp-iext-phase-currents
Apr 21, 2026
Merged

fix(ferroamp): read per-phase grid current from iext not il#161
frahlg merged 1 commit into
masterfrom
160-ferroamp-iext-phase-currents

Conversation

@frahlg

@frahlg frahlg commented Apr 21, 2026

Copy link
Copy Markdown
Member

Closes #160.

Summary

  • `drivers/ferroamp.lua` now reads `iext` (service-entrance CT current) for `meter.l1_a` / `l2_a` / `l3_a` instead of `il` (inverter AC current).
  • Power (`w`) keeps reading `pext`; that was already correct. After the fix `sum(l*_a) × V ≈ w` for any load mix.
  • `go/cmd/sim-ferroamp` emits both `iext` and `il` so the e2e harness stays valid for any downstream still peeking at `il`.

Why

On a live Ferroamp install with CTs at the service entrance and an 11 kW EV charger on a separate breaker, the dashboard showed `grid_w = 11 kW` but fuse bars summed to `≈ 874 W` — a ~12× under-read. `il` only sees what flows through the Ferroamp inverter; the EV charger is invisible to it but visible to `pext` / `iext`. Same bug fed into the `fuse_over_limit` notification rule added in #159, so that would also miss EV-driven overloads.

Test plan

  • `go build ./...`
  • `go test ./...`
  • `make e2e` — full stack passes in 25 s (sim-ferroamp now emits both fields)
  • Live validation on the reporting site: verify `sum(l*_a) × 230 ≈ grid_w` during a known EV-charging event

🤖 Generated with Claude Code

The driver was reading `il` (inverter AC current) for meter.l*_a while
meter.w came from `pext` (service-entrance CT power). In Ferroamp's
ehub JSON `il` only sees what flows through the inverter; any load
behind the main fuse but outside the inverter path — the common case
being an EV charger on a separate breaker — is invisible to `il` but
visible to `pext`/`iext`. Symptom: fuse bars and fuse_over_limit
detection under-read by the EV share of total import (measured ~12×
at 11 kW EV-charging during grid import).

Fix: read `iext` for the phase-current fields. pext (W) stays; it was
already correct. After this sum(l*_a) × V agrees with w for any load
mix.

Sim-ferroamp now emits both `iext` and `il` at W/V for compatibility
— driver prefers iext, but anything downstream that still inspects il
keeps working.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@frahlg
frahlg merged commit b657014 into master Apr 21, 2026
1 check passed
@frahlg
frahlg deleted the 160-ferroamp-iext-phase-currents branch April 21, 2026 03:57
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.

fix(ferroamp): read per-phase grid current from iext not il (fuse bars undercount by ~12×)

1 participant