close
Skip to content

fix(easee): disable phase switching on non TN grid installations#28411

Merged
andig merged 5 commits into
evcc-io:masterfrom
GrimmiMeloni:fix/easee-it-grid-phase
Mar 22, 2026
Merged

fix(easee): disable phase switching on non TN grid installations#28411
andig merged 5 commits into
evcc-io:masterfrom
GrimmiMeloni:fix/easee-it-grid-phase

Conversation

@GrimmiMeloni
Copy link
Copy Markdown
Collaborator

@GrimmiMeloni GrimmiMeloni commented Mar 20, 2026

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 read DetectedPowerGridType. Circuit
control 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

GrimmiMeloni and others added 3 commits March 20, 2026 21:17
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>
@GrimmiMeloni GrimmiMeloni self-assigned this Mar 20, 2026
@GrimmiMeloni GrimmiMeloni added the bug Something isn't working label Mar 20, 2026
@GrimmiMeloni GrimmiMeloni changed the title fix(easee): skip circuit-level phase switching on IT grid installations fix(easee): disable phase switching on non TN grid installations Mar 20, 2026
@GrimmiMeloni
Copy link
Copy Markdown
Collaborator Author

@mggevaer do you have the necessary skills to create a build and run this PR locally?

Comment thread charger/easee.go Outdated
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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that looks like a hard error

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — charger config fetch failure now propagates as an error from NewEasee.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@andig
Copy link
Copy Markdown
Member

andig commented Mar 21, 2026

Lgtm- good to merge?

@GrimmiMeloni
Copy link
Copy Markdown
Collaborator Author

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.

@GrimmiMeloni
Copy link
Copy Markdown
Collaborator Author

@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....

@andig
Copy link
Copy Markdown
Member

andig commented Mar 21, 2026

@premultiply

@andig andig marked this pull request as ready for review March 21, 2026 22:37
@andig andig enabled auto-merge (squash) March 21, 2026 22:37
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@premultiply
Copy link
Copy Markdown
Member

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?

@andig andig added enhancement New feature or request and removed bug Something isn't working labels Mar 22, 2026
@andig andig merged commit d921a82 into evcc-io:master Mar 22, 2026
8 checks passed
@mggevaer
Copy link
Copy Markdown

@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.
The documentation (https://docs.evcc.io/en/docs/installation/home-assistant) under Installation when selecting Nightly is very straightforward but I'm only seeing evcc, not evcc (nightly). Could just be some quirk on my end, definitely a different issue than the it-grid fix in this PR.

Is there value in me trying to set the nightly evcc up in my Linux WSL and reporting back?

@GrimmiMeloni
Copy link
Copy Markdown
Collaborator Author

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.
I'd say, just stay on the lookout for the next release (0.303.3) - once it lands you could upgrade and test.

@mggevaer
Copy link
Copy Markdown

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.

@mggevaer
Copy link
Copy Markdown

mggevaer commented Apr 3, 2026

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.
No warnings from the car or EVCC.
Thanks for the quick fix folks!

@GrimmiMeloni GrimmiMeloni deleted the fix/easee-it-grid-phase branch April 3, 2026 09:50
@andig
Copy link
Copy Markdown
Member

andig commented Apr 3, 2026

Thanks for letting us know!

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants