Skip to content

fix(mpc): detect EV drivers by Lua filename when loadpoints absent - #123

Merged
frahlg merged 1 commit into
masterfrom
fix/ev-capacity-detect-by-lua-filename
Apr 19, 2026
Merged

frahlg merged 1 commit into
masterfrom
fix/ev-capacity-detect-by-lua-filename

Conversation

@frahlg

@frahlg frahlg commented Apr 19, 2026

Copy link
Copy Markdown
Member

Summary

Why the prefix allowlist and not a regex

A battery driver named easy_battery.lua would be wrongly excluded by anything broader. Keep the list to EV chargers we actually ship.

Test plan

  • go test ./cmd/forty-two-watts/... passes (existing 3 capacity tests + 2 new: filename fallback + prefix classifier truth table)
  • go test ./... incl. e2e stays green
  • After deploy, check Pi logs: mpc: replanned ... capacity_wh=24800 (down from 99800)
  • Check Fredrik's next replan shows battery_w < 0 in import slots (strict SC now actually biting)

🤖 Generated with Claude Code

PR #121 filtered EV drivers from the MPC battery-pool aggregation by
matching against `loadpoints[].driver_name`. That works when the
operator has migrated to a `loadpoints:` config block, but Fredrik's
production Pi has no loadpoints section — so the easee driver's
`battery_capacity_wh: 75000` (vehicle capacity) still inflates the
MPC pool from ~24.8 kWh to ~99.8 kWh, which is the root cause of
the "morning grid import at 50% SoC" incident the strict
self_consumption bias (PR #122) was supposed to address.

Add a narrow filename-prefix allowlist (easee, ocpp, ctek,
chargestorm) as a fallback so the filter fires even without a
loadpoints block. Applies the same check to
`warnIfEVHasBatteryCapacity` with a slightly different WARN wording
so operators know whether the detection came from config reference
or filename heuristic.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@frahlg
frahlg merged commit ab13ef8 into master Apr 19, 2026
1 check passed
@frahlg
frahlg deleted the fix/ev-capacity-detect-by-lua-filename branch April 19, 2026 07:07
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