Skip to content

Should a charger socket reconnect end Charge now? #1788

Closed

Description

@frahlg

Decision needed

Fredrik's rule (#1772): Charge now
runs until Stop, unplug or the car stops asking; nothing else stops it.

Today a dropped charger socket also stops it. When an OCPP charger loses its
Wi-Fi and comes back, still plugged in, FTW turns Charge now into a pause and
waits for someone to press Start. Earlier work chose that on purpose
(cf41766, 6 Sep 2026, in #1074),
and tests pin it. #1778 left it open for this decision.

Question: should a socket reconnect end Charge now?

Proposal: no. A socket reconnect, or a hardware identity that is missing
for a while, is not an unplug. Charge now goes on unless FTW sees an unplug,
the charger proves to be other hardware (another serial), the session ID
changes, or the loadpoint's config changes.

What happens today

On master, and with #1778:

  1. The socket drops. OCPP reports connection_unknown. FTW sends nothing, so
    the charger keeps its last profile and the car keeps charging.
  2. observeConnectionProof (loadpoint/session_state.go) clears the
    charger's hardware identity, as it must while the socket is down.
  3. restoreManualHoldForSession (loadpoint/controller_hold_restore.go)
    reads the new connection, or the missing identity, as another session. It
    turns the hold into a 0 W pause, sets manual_restore_unconfirmed and
    saves the pause, so a restart keeps it too.
  4. The same charger returns with the same serial and the car still plugged
    in. FTW sends 0 W and the car stops. The page says "Confirm how to
    continue charging. FTW could not confirm the charger or connection."
    Charging resumes only after Start.

No notice goes out: FTW ordered the 0 W itself, so charging.interrupted
does not fire. The same path runs when a driver's identity goes missing
without a socket change
(TestLostHardwareProofPausesOldStartButAllowsANewExplicitStart).

Evidence

Unit test TestChargeNowSurvivesOCPPSocketBlip (go/cmd/ftw, local; it comes
with the PR): FTW's OCPP server, an ocpp-go charge point and the real
currentEVSample path. Charge now at 11 040 W, the socket closes, the
charger dials again and boots.

Case Today (#1778 head 2413095) With the change
Same charger, a tick sees the socket down commands [0 0], pause, unconfirmed [11040 11040], hold kept
Same charger, socket back between ticks [0 0], pause, unconfirmed [11040 11040], hold kept
Other charger (serial B) on the same OCPP id pause, unconfirmed pause, unconfirmed
Same charger, then Available hold cleared (unplug) hold cleared (unplug)

Simulator rig: the harness from the 21 October simulator report plus one
scenario. srcfl/device-simulator 3965d8e, OCPP 1.6 charger, 25 A fuse, house
3 A per phase. Charge now at 11 040 W for 90 s, then the rig kills the OCPP
proxy between charger and FTW for 15 s, so both ends see the socket close.
The simulated charger dials again 5 s later, boots and reports connector 1
Charging, about 20 s after the drop.

a: #1778 head 2413095 b: a + #1779 c: b + prototype
Car, 30 s before the drop 10 971 W 10 971 W 10 971 W
Car while the socket is down 10 957 W or more 10 957 W or more 10 957 W or more
manual_restore_unconfirmed true 2 s after the drop true 2 s after the drop false throughout
Car after the charger returns 0 W within 2 s 0 W within 2 s 10 957 W or more
Last 60 s, 150 s after the return 0 W, paused 0 W, paused 10 971 W, charging

The car charges through the outage; FTW stops it once the charger is back.
#1779 does not change this.

Risk each way

Keep today's rule. Every socket drop during Charge now stops the car until
someone presses Start, and the owner learns of it only in the app. The rule
guards one case: another car plugged in while the socket was down, with the
unplug unseen, would get Charge now.

Change it. That car gets Charge now until it is full, unplugged or
stopped. It costs money at worst. The fuse guard does not change, and nor do
Stop, unplug and the car that stops asking.

How likely is the unseen swap? A swap takes a minute or more, so a drop of a
few seconds cannot hide one; a router restart can. When an OCPP charger
returns, it reports its status as it is now, so an Available from the
outage is lost unless the charger replays it. OCPP sends no session ID, so
the new transaction brings no new ID either. #1778 accepted
the same risk for a Core restart, which the charger also sees as a dropped
socket.

Simplest change

A prototype, not pushed, in controller_hold_restore.go only (about 20
lines). A new socket or a missing identity no longer counts as a change. The
hold keeps its power, and the binding keeps the last proven charger. When the
charger proves itself again:

  • same serial: Charge now goes on;
  • other serial, or a session ID that differs from the one before: pause and
    ask for Start, as today;
  • config change: pause, as today.

A Start pressed before the charger ever proved its identity binds to the
first proof, as today, now also across a socket drop. No setting and no
timer. It sits on #1778, which changes the same file.

Three tests encode today's rule and would say the opposite:

  • TestManualStartWithoutHardwareCannotFollowAnotherSocket
  • TestLostHardwareProofPausesOldStartButAllowsANewExplicitStart
  • TestOCPPReconnectDoesNotUnplugOrResumeOldStart, the power=4140 cases
    (the fast=false case returns with another serial and still pauses; only
    its check during the outage changes)

All other loadpoint and cmd/ftw tests pass with the prototype.

Prototype diff
 	previous, bound := c.manualBindings[id]
-	changed := bound && (previous.configuration != current.configuration ||
-		(previous.connectionGeneration != 0 && current.connectionGeneration != 0 && previous.connectionGeneration != current.connectionGeneration))
+	changed := bound && previous.configuration != current.configuration
+	// A dropped socket or a lost hardware proof is not an unplug. Keep the
+	// last proof until the charger proves itself again: the same charger
+	// keeps Charge now, other hardware or another session does not.
+	reconnected := bound && (previous.proofLost || (previous.connectionGeneration != 0 &&
+		current.connectionGeneration != 0 && previous.connectionGeneration != current.connectionGeneration))
 	if bound && previous.deviceID != "" {
-		changed = changed || previous.deviceID != current.deviceID
-		// ObserveSession preserves the generation for a valid first proof.
-		// A changed generation therefore means a new connection or a counter
-		// reset, even when the earlier session ID was still unknown.
-		changed = changed || previous.generation != current.generation
+		switch {
+		case current.deviceID == "":
+			if !changed {
+				current = previous
+				current.proofLost = true
+			}
+		case reconnected:
+			changed = changed || previous.deviceID != current.deviceID ||
+				(previous.sessionID != "" && current.sessionID != "" && previous.sessionID != current.sessionID)
+		default:
+			changed = changed || previous.deviceID != current.deviceID
+			// ObserveSession preserves the generation for a valid first proof.
+			// A changed generation therefore means a counter reset or a new
+			// session, even when the earlier session ID was still unknown.
+			changed = changed || previous.generation != current.generation
+		}
 	}

plus a proofLost bool field on manualSessionBinding.

A stricter variant is possible: also end Charge now when the charger's
session energy falls after it returns, which is how a queued
StopTransaction/StartTransaction pair shows up. It would catch a swap on
chargers that queue those messages. But FTW would have to keep the energy
baseline across the identity loss (session_state.go), and a charger that
starts a new transaction on reconnect would then stop Charge now again. I
suggest the simple change first.

Not decided here

The same drop also forgets the SoC the owner entered:
observeConnectionProof clears socConfirmed and the saved record, so a
"Charge now to 80 %" then counts from an assumed level. It is the same
question (is this still the same car?), but a separate change.

Activity

  1. added
    question
    on Oct 21, 2026
  2. frahlg commented on Oct 28, 2026

    @frahlg
    MemberAuthor

    Decided and built in #1848: a socket reconnect or a missing hardware identity no longer ends Charge now. The part left open here, the owner-entered SoC lost on reconnect, is now #1928.

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions