fix(easee): disable phase switching on non TN grid installations#28411
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Chargers on IT grids (e.g. Belgian, Norwegian installations) were incorrectly assigned to circuit-level phase control. The charger config API now gates this assignment: only confirmed TN grids (types 1-3) engage circuit control. IT grids, API failures, and unknown types fall back to charger-level phase control (c.circuit = 0). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@mggevaer do you have the necessary skills to create a build and run this PR locally? |
| func (c *Easee) determineCircuit(site easee.Site) { | ||
| config, err := c.chargerConfig(c.charger) | ||
| if err != nil { | ||
| c.log.WARN.Printf("charger config unavailable, using charger-level phase control: %v", err) |
There was a problem hiding this comment.
Fixed — charger config fetch failure now propagates as an error from NewEasee.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Lgtm- good to merge? |
I think so. Tested a couple of phase changes on my end. Continues to work as always. Lets put it out there. Might also make it easier for @mggevaer to test once it is in the nightly. |
|
@andig the ocpp test is flaky. Bumped into this a couple of times recently. Not related, but probably worth to investigate what's going on. Have only seen it on GHA CI though, not locally.... |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
determineCircuitbehavior returns an error when the config endpoint is unavailable, but the PR description states that unreachable config should fall back to charger-level control; consider treating config fetch failures as a non-fatal condition and skipping circuit assignment instead of failingNewEasee. - In tests and logic you rely on raw integers (e.g. 4 and 5) to represent IT grid types; consider defining named constants for these values in
types.goto avoid magic numbers and make the grid-type handling clearer and less error-prone.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `determineCircuit` behavior returns an error when the config endpoint is unavailable, but the PR description states that unreachable config should fall back to charger-level control; consider treating config fetch failures as a non-fatal condition and skipping circuit assignment instead of failing `NewEasee`.
- In tests and logic you rely on raw integers (e.g. 4 and 5) to represent IT grid types; consider defining named constants for these values in `types.go` to avoid magic numbers and make the grid-type handling clearer and less error-prone.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
I’m not entirely familiar with this type of grid network, but the conclusion and its implementation seem sensible to me. But I am asking myself if that should not be a general configuration for all type of chargers? |
|
@GrimmiMeloni Given I've previously set up evcc on my Home Assistant so I tried to go for the nightly build of the home assistant add-on. Is there value in me trying to set the nightly evcc up in my Linux WSL and reporting back? |
It would be valuable, but not to the extent that it warrants the effort. |
|
Ok, thank you for the quick handling of this bug fix! I'll post test results here when I have them, and look forwarding to starting my sponsorship if it works as expected. |
|
Just want to confirm that this does in fact solve my issue with EVCC on my IT grid, the charger is now able to cleanly switch between stop, start, increase/decrease charge speed. |
|
Thanks for letting us know! |
Problem
Easee chargers installed on IT grids (common in Belgium and Norway) experienced
broken phase switching. When evcc detected a sole charger on a circuit, it
engaged circuit-level phase control — setting dynamic circuit currents P2 and
P3 to zero for 1-phase operation. On IT grids this is incorrect: the IT wiring
uses L1+L3 (no neutral), so zeroing P3 cuts the return conductor and disrupts
charging.
Additionally the aforementioned use of L1+L3 also lead to incorrect detection of 3p charging for IT-grid based installations.
The root cause was that evcc's circuit assignment logic did not account for
grid type. A sole charger on a circuit would always get circuit-level phase
control, regardless of whether the installation was TN or IT.
Fix
Before assigning circuit-level phase control, query the Easee charger config
API (
GET /api/chargers/{id}/config) to readDetectedPowerGridType. Circuitcontrol is only engaged for confirmed TN grids (types 1–3). IT grids (types 4–5),
unreachable config endpoints, and any unknown grid type all fall back to
charger-level phase control, which is safe for all grid types.
fixes #27911