Repository navigation
fix(mpc): detect EV drivers by Lua filename when loadpoints absent - #123
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
config.yamlhas aloadpoints:section. Fredrik's production Pi does not — so the easee driver's 75 kWh vehicle capacity is still being aggregated into the MPC battery pool (capacity_wh = 99800instead of 24800).easee,ocpp,ctek,chargestorm) as a fallback insidedriverCapacitiesFromandwarnIfEVHasBatteryCapacity.Why the prefix allowlist and not a regex
A battery driver named
easy_battery.luawould 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 greenmpc: replanned ... capacity_wh=24800(down from 99800)battery_w < 0in import slots (strict SC now actually biting)🤖 Generated with Claude Code