Repository navigation
fix(loadpoint): surplus counts our orders, not a charger's late reading #1850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2878b1b
fix(loadpoint): surplus counts our orders, not a charger's late reading
frahlg 04a61e8
fix(loadpoint): a raise shows once a reading passes halfway to it
frahlg 957ff4e
Merge remote-tracking branch 'origin/master' into fix/surplus-late-re…
frahlg cbfa7d4
Merge remote-tracking branch 'origin/master' into fix/surplus-late-re…
frahlg 395f15d
Merge branch 'master' into fix/surplus-late-readback
frahlg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ftw": patch | ||
| --- | ||
|
|
||
| Surplus charging now holds a steady level when the charger reports its draw late, as Easee Cloud does. A raise on its way already uses the room it was sent for, so Core waits for a reading to show it before raising again. A charger told to stop no longer counts its old draw as spare solar. Before, the car stepped up past the surplus, landed in import and paused about every minute and a half. |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package loadpoint | ||
|
|
||
| import ( | ||
| "testing" | ||
| "time" | ||
| ) | ||
|
|
||
| // A charger reports its draw late: Easee Cloud about 10 s after the draw. | ||
| // Surplus counts each charger at what the meter may show of our orders, not | ||
| // at its late reading. A raise on its way already claims its room; a | ||
| // charger ordered off is leaving; a smaller cut keeps the reading until it | ||
| // lands. | ||
| func TestSurplusCountsOurOrdersNotALateReading(t *testing.T) { | ||
| start := time.Date(2026, 10, 21, 22, 15, 0, 0, time.UTC) | ||
| for _, tc := range []struct { | ||
| name string | ||
| orders []float64 // each sent 2 s apart; the last is the latest | ||
| readings []float64 // each read 1 s after the latest order | ||
| wantAdj, wantRaise float64 | ||
| }{ | ||
| {"ordered off, the reading still shows the draw", []float64{6210, 0}, []float64{6210}, -6210, 0}, | ||
| {"a raise on its way", []float64{4830, 6900}, []float64{4830}, 2070, 6900}, | ||
| {"a raise the reading has shown", []float64{4830, 6900}, []float64{4830, 6900}, 0, 0}, | ||
| {"one step up from 9 A, on its way", []float64{6210, 6900}, []float64{6210}, 690, 6900}, | ||
| {"one step up from 9 A, shown", []float64{6210, 6900}, []float64{6210, 6900}, 0, 0}, | ||
| {"a raise after a cut that has not landed", []float64{8970, 4830, 6210}, []float64{8970}, -2760, 6210}, | ||
| {"a restart under the draw read before the stop", []float64{6210, 0, 4830}, []float64{6210}, -1380, 4830}, | ||
| {"a cut on its way keeps the reading", []float64{8970, 3450}, []float64{8970}, 0, 0}, | ||
| } { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| c := newTestController(t, []Config{{ID: "garage", DriverName: "easee", SurplusOnly: true, MinChargeW: 4140, MaxChargeW: 11040}}, nil, nil, &fakeSender{}) | ||
| now := start | ||
| for _, w := range tc.orders { | ||
| now = now.Add(2 * time.Second) | ||
| c.manager.SetCommanded("garage", w, "pv_surplus") | ||
| c.noteSurplusOrder("garage", now, w) | ||
| } | ||
| var adj, raise float64 | ||
| for _, r := range tc.readings { | ||
| now = now.Add(time.Second) | ||
| c.manager.Observe("garage", true, r, 0, true) | ||
| adj, raise = c.surplusOrderAdjustW(now, "garage") | ||
| } | ||
| if adj != tc.wantAdj || raise != tc.wantRaise { | ||
| t.Fatalf("adjust %.0f W, raise on its way %.0f W; want %.0f and %.0f", adj, raise, tc.wantAdj, tc.wantRaise) | ||
| } | ||
| }) | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When solar disappears after a restart but before the charger's readback catches up, this adjustment can hide grid import entirely. The production reader in
go/cmd/ftw/main.gocallsSurplusAvailableForEVW, which already floors negative surplus to zero (go/internal/loadpoint/surplus_reserve.go:127–135). For example, with a pending 6,900 W order, a late 0 W EV reading, no battery flow and 6,900 W grid import, the reader returns zero and this adjustment turns it back into 6,900 W of apparent surplus. Surplus-only charging therefore continues importing until readback catches up or the settle timeout expires, instead of reducing immediately. Apply the adjustment to the signed surplus before its zero floor so the import remains visible.Useful? React with 👍 / 👎.