evcc icon indicating copy to clipboard operation
evcc copied to clipboard

Vehicle coordinator: same vehicle active on two loadpoints; configured default replaced

Open Alexxtheonly opened this issue 5 months ago β€’ 2 comments

Describe the bug

With two loadpoints that each have an explicitly configured default vehicle, the vehicle coordinator can lose its mutual-exclusion guarantee: the same vehicle ends up active on both loadpoints at once, and one loadpoint's configured default vehicle is silently replaced and never restored.

Observed on a real 2-wallbox + 2-Tesla setup:

  • LP1 (Rechts): default = Luna, actively charging (charger status C)
  • LP2 (Links): default = Calypso, connected but idle (charger status B)

Log trace:

LP1: unknown -> Luna      LP2: unknown -> Calypso     (defaults assigned correctly)
LP1: Luna -> unknown      LP2: Calypso -> Luna        (LP2 abandons its default for Luna)
LP1: unknown -> Luna

Steady state: both loadpoints report vehicle = Luna; LP2's configured default Calypso is gone. The trigger is a status asymmetry between the two loadpoints (one charging / one idle); an offline/sleeping vehicle is just one way to reach that asymmetry, it is not required.

Root cause

core/coordinator/coordinator.go release(vehicle) does an unconditional delete(c.tracked, vehicle). When acquire transfers a vehicle from LP1 to LP2 it sets tracked[vehicle] = LP2 and defers LP1.SetVehicle(nil) on the previous owner. That deferred call runs LP1.setActiveVehicle(nil), and because LP1.vehicle is still the transferred vehicle at that instant, it calls coordinator.Release(vehicle) β€” which deletes the entry acquire just set to LP2.

Net result: the vehicle is left untracked while LP2 still holds it. On the next cycle LP1 re-asserts its default, re-acquires the (now untracked) vehicle cleanly without transferring it away from LP2, and both loadpoints hold it. The untracked vehicle also defeats the exclusion in availableDetectibleVehicles, allowing status detection to hand an already-owned vehicle to another loadpoint.

Fix

Make release owner-keyed so a previous owner's stale SetVehicle(nil) cannot wipe an entry a newer acquire assigned (only delete when tracked[vehicle] == owner). I have a fix + regression tests ready and will open a PR referencing this issue.

Steps to reproduce

Deterministic unit tests in the PR reproduce it: two loadpoints, two ChargeState-capable vehicles with asymmetric status (C / B), each with its own configured default vehicle. Without the fix the same vehicle becomes active on both loadpoints and a default is replaced; with the fix the coordinator keeps exactly one owner per vehicle.

Version

Reproduces on current master (the identify/coordinator interaction is the cause, independent of vehicle templates).

Alexxtheonly avatar Jun 20 '26 15:06 Alexxtheonly

Unfortunately your report is missing a detailed log file. Without log, we donβ€˜t have the information for diagnosing the issue described. See https://docs.evcc.io/docs/faq#wie-kann-ich-ein-logfile-zur-fehleranalyse-erstellen.

andig avatar Jun 21 '26 05:06 andig

LP1: Luna -> unknown

Its unclear why this would happen. Unfortunately log for confirming this is missing.

andig avatar Jun 21 '26 05:06 andig