Repository navigation
fix(loadpoint): one unplug reading does not end Charge now - #1898
Merged
Merged
Conversation
The loadpoint cleared a manual hold on the first Connected=false reading, while the cars runtime keeps the session for UnplugGrace (30 s). Clear the hold only after the cable has read out for UnplugGrace, or when the next connected reading names another device or session. Both layers now share loadpoint.UnplugGrace. Item D3 of the stable plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…plug rebindAfterUnplug carried the old session id into the binding, but restoreManualHoldForSession ran on the same tick and overwrote it with the empty id the charger reported. A charger that names the session one reading after the cable, as Easee Cloud does, then let a new session inherit Charge now at full power. Keep the last proven session id while the charger names none, so the later proof is compared with it. Add tests for another session and for the same session named one reading late. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Item D3 of the stable plan.
Problem
The loadpoint cleared Charge now on the first
Connected=falsereading (controller.go:1429-1437). The cars runtime waits 30 s (cars.UnplugGrace) before it ends the session, and resumes it if the cable comes back. So the two layers disagree on the same flap.Scenario: Charge now runs at 4140 W on device
dev-1, sessionsess-1. One 5 s poll reads not connected, for example an OCPPUnavailablestatus after a charger reboot. The next poll shows the same device and session. On master the hold is gone and the car falls back to the plan, which at night is 0 W. The clear is also saved to disk, so a restart does not bring it back.Change
loadpoint.UnplugGrace(30 s).cars.UnplugGracenow points to it, so both layers use one constant.tickOneclears the hold only once the cable has read out forUnplugGrace.observeTickskips the session check, since an unplugged reading says nothing about the next car.session_idnil until it confirms the session). Until a session is named, the binding keeps the one from before the unplug. If the charger then names another session, the hold turns into a pause, as a new session after a restart or socket drop does. The same session keeps Charge now.Unplug reset of surplus state and of the SoC record is unchanged.
Tests
controller_unplug_grace_test.go:TestOneUnpluggedReadingKeepsChargeNow(the audit repro from caa-29, renamed),TestUnpluggedReadingWithoutSessionKeepsChargeNowandTestOtherSessionAfterShortUnplugClearsChargeNow. The first two fail on master withheld=false last order=0 W; the third passes on both.TestLateOtherSessionAfterShortUnplugEndsChargeNowandTestLateSameSessionAfterShortUnplugKeepsChargeNowcover a session named one reading after the cable. Without the second commit the first fails withlate other session inherited Charge now: last=4140 W.UnplugGracefirst:TestPersistentManualHoldClearedOnUnplug(also checks the hold survives the first reading),TestChargeNowWithoutSessionIDResumesAfterRestart,TestMissingReadingDoesNotEndManualSession,TestChargeNowSurvivesOCPPSocketBlip,TestOCPPReconnectIsNotAnUnplugandTestOldSocketStatusCannotClearPauseAfterReconnect.go test -race -count=1on loadpoint, cars, api, control, ocpp, appproto, appuplink, mpc, state, units and cmd/ftw: all ok.go vet ./...andgo build ./...: ok.Risk
Low. No command changes:
tickOnestill returns before dispatch while unplugged, and the fuse budget only counts connected chargers. A Charge now or Pause hold stays visible for up to 30 s after a real unplug. On a charger that never reports a session id, a different car plugged in within 30 s keeps Charge now; that is the same trade #1848 accepted for socket drops. A charger that reports the session id late is covered: the later id is compared with the one before the unplug.🤖 Generated with Claude Code