Repository navigation
fix(ocpp): take up a running 1.6 transaction after a Core restart - #1787
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89f2cceea6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| s.transactionID = txID | ||
| s.sessionStartMeterWh = meterWh |
There was a problem hiding this comment.
Reject non-finite readings before adopting a transaction
If the first energy register received after restart contains "NaN" or "Inf", strconv.ParseFloat accepts it without an error, and this assignment permanently stores a non-finite session baseline. Every subsequent valid reading then produces non-finite session energy, and pushReading cannot marshal its telemetry payload because JSON rejects these values. Unlike a bad sample during an ordinarily started transaction, later valid samples cannot recover this session. Check that the converted meter reading is finite before adopting the transaction so a later valid reading can establish its baseline.
Useful? React with 👍 / 👎.
89f2cce to
f5ca0f6
Compare
A charger keeps its transaction while Core restarts and keeps naming it in MeterValues. Core started every charger with no transaction, so session energy stayed at 0 until unplug and the stop reported the lifetime meter total. Take the transaction up from its first meter value, count energy from that reading, and start transaction ids from the clock so a restart does not hand out an id a charger still holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eter readings A stop that names another transaction than the running one, such as a queued stop from before a restart, ended the running transaction and took MeterStop as its session energy. Keep the running one and confirm the stop. ParseFloat accepts NaN and Inf; taken up as the start reading of a resumed transaction, one spoiled every later session value. Skip non-finite sampled values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f5ca0f6 to
92230c0
Compare
Start sets the settle wait next to bootLimit instead of in NewHandler, which keeps this branch from touching the line #1787 changes there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After a Core restart a two-socket 1.6 charger may report socket 1 Available and then send socket 2's meter values for its running transaction before socket 2's status. Without #1787 FTW holds no transaction id then, so the 0 A start limit went to the whole charger and paused that car. A 1.6 meter value that names a transaction or measures power above zero now cancels the pending limit, as a status with a car does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(ocpp): a managed charger starts at 0 A on boot Until FTW's first order lands, an OCPP charger runs at its own default, usually its rating. In random rig seed 207534 the charger booted at 5.0 s, a car plugged in at 7.3 s and drew 11040 W from 10 s until FTW's first 0 A took effect at 13.5 s, with 18.9 A on a 16 A fuse. On BootNotification (1.6 and 2.0.1) from a charger a loadpoint names, send the same 0 A TxDefaultProfile FTW sends to pause: profile id 1, stack level 0, connector or EVSE 0, with the usual connector-1 retry. FTW's first order has the same id, purpose and stack level, so it replaces the boot profile. Skip chargers listed only under ocpp.chargers (FTW never orders them), pending chargers, a boot that answers FTW's own identity probe, and a boot on a socket that already reported a car. A refusal is logged once and not retried until the next boot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ocpp): no start limit in measurement mode or mid-session reconnect Setup measurement mode blocks every charger write, standdowns included. The boot limit went straight to setLimit, so a charger named by a loadpoint saved during setup got 0 A and kept it until restart. Both the start and the hot-reload paths now pass no managed chargers while Core runs in the mode it booted in. Much firmware sends its own BootNotification on every reconnect. The car guard read only the new socket, so a Wi-Fi drop mid-session paused the car. The guard now reads the last status FTW holds, which survives the reconnect, and any open transaction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ocpp): wait for a status before the 0 A start limit Rig s7s-restart-short-25A failed twice on 964643e: after a Core restart the charger sent its own BootNotification at once, the new process held no status or transaction, and FTW sent the 0 A start limit mid Charge now. The car went to SuspendedEVSE for a second. A boot now only marks the charger. The first connector status after it decides: no car and no transaction sends the 0 A limit; a car sends nothing. Connector 0 Available on 1.6 does not decide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ocpp): start limit waits for every socket's status The 0 A start limit goes to connector or EVSE 0, the whole charger. It went out on the first connector status after a boot that showed no car. On a two-socket 1.6 charger or a two-EVSE 2.0.1 station, a Core restart while a car charged on socket 2 sent 0 A as soon as socket 1 reported Available, and paused that car. FTW now waits until the statuses after the boot have been quiet for one second. Any status that shows a car or a transaction cancels the limit as it arrives, since the last status wins in FTW's one state per charger. An order from FTW during the wait also cancels it, so the 0 A cannot land after that order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(ocpp): set the boot-limit wait beside the boot-limit sender Start sets the settle wait next to bootLimit instead of in NewHandler, which keeps this branch from touching the line #1787 changes there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ocpp): meter values showing a car cancel the start limit After a Core restart a two-socket 1.6 charger may report socket 1 Available and then send socket 2's meter values for its running transaction before socket 2's status. Without #1787 FTW holds no transaction id then, so the 0 A start limit went to the whole charger and paused that car. A 1.6 meter value that names a transaction or measures power above zero now cancels the pending limit, as a status with a car does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Item E1 of the stable plan (27 Oct 2026). OCPP 1.6 only; 2.0.1 Updated and Ended follow in a separate PR.
Problem
Core restarts on every update. An OCPP 1.6 charger keeps its transaction through the restart and goes on naming it in MeterValues. Core started every charger with no transaction (
transactionID−1) and handed out ids from 1 again. For a session that spans a restart:session_whstayed at 0 until unplug, becauseOnMeterValuescounts energy only while a transaction is known. Rig s7-25 with fix(loadpoint): Charge now keeps charging after a restart #1778 ended withev_session_wh0 while the car drew 11 kW.MeterStop − 0, the charger's lifetime register. Example: a car on transaction 42 finishes at a register of 12,345,678 Wh; Core reported a 12.3 MWh session to the loadpoint, the UI, the cloud link and theev_session_whmetric.MeterStop9,000,000 settransactionIDto −1,chargingto false andsession_whto 8,999,000.strconv.ParseFloataccepts"NaN"and"Inf". Taken up as the start reading, one would spoil every later session value, andpushReadingcannot marshal a non-finite value (Codex P2 on this PR).Change
All in
go/internal/ocpp/handlers.go:session_whand records noev_session_whmetric. It still endschargingand clears measured power as before.chargingandconnected.What this does not fix
restoreOffers) is still not restored for OCPP.OnTransactionEvent. It comes next.Tests
transaction_resume_test.go: eight tests. The take-up, unseen-stop, id and lifetime-register tests fail on master.TestOCPP16StopForAnotherTransactionKeepsTheRunningOneandTestOCPP16NonFiniteRegisterIsNotTakenUpfail on this PR's previous head and pass now. The last two are the audit's repro tests (TestReproStopNotMatchedToTransaction,TestReproRestartStop16ReportsLifetimeRegister) under normal names.cd go && go test -race ./internal/ocpp/... -count=1: ok.go vet ./...andgo build ./...: ok.ev_session_whread 0 after the restart; with it the log saysOCPP running transaction taken up txid=25371034 meter_wh=3337andev_session_whcounts again. Rig R4 in the stable plan covers it on this head.Risk
Low. Nothing here touches dispatch, fuse math, signs or the command path. The one new state rule keeps a running transaction when a stop names another id. If a charger sends a wrong id for the real stop, Core keeps the transaction id until the next StartTransaction replaces it, and that session records no
ev_session_whmetric.charging,connectedand measured power still follow the status notifications and meter values, so control sees the car stop.🤖 Generated with Claude Code