Skip to content

easee: clamp DCC to 7A before ChargeStart and remove overshoot protection - #30774

Merged
andig merged 7 commits into
evcc-io:masterfrom
GrimmiMeloni:easee-remove-overshoot-protection
Jun 25, 2026
Merged

andig merged 7 commits into
evcc-io:masterfrom
GrimmiMeloni:easee-remove-overshoot-protection

Conversation

@GrimmiMeloni

@GrimmiMeloni GrimmiMeloni commented Jun 13, 2026 •

Copy link
Copy Markdown
Collaborator

fix #30253

Summary

  • Alternate approach for Easee: delayed charge start at minA #30417: instead of removing overshoot protection entirely, clamp DCC from 6A to 7A before sending ChargeStart
  • Removes the waitForDynamicChargerCurrent / overshoot protection from Enable() — the loadpoint's syncCharger corrects offeredCurrent on the next control interval
  • Also fixes a latent timeout on Enable(false) where waitForDynamicChargerCurrent(0) always timed out

Test plan

  • Verify ChargeStart at 6A sends DCC clamp to 7A before the start command
  • Verify ChargeStart at ≥7A does not send an extra DCC clamp
  • Verify ChargeResume path is unaffected
  • Run go test ./charger/ -run TestEasee_Enable_clampsCurrentOnChargeStart

🤖 Generated with Claude Code

GrimmiMeloni and others added 6 commits June 13, 2026 09:52
Let the charger start at its default current (32A) after resume.
The loadpoint's syncCharger corrects offeredCurrent on the next
control interval. The 60s chargerSwitchDuration grace period
suppresses charger logic error warnings during the transition.

Also eliminates a latent timeout on Enable(false) where
waitForDynamicChargerCurrent(0) always timed out.

fix evcc-io#30417

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Tests now expect Enable(false) before circuit settings and verify
no DCC:7 override is sent. Tests will fail until implementation
is updated in the next commit.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Replace the DCC:7 workaround with Enable(false) before sending
circuit settings, mirroring the charger-level phase switch path.
The loadpoint re-enables the charger via syncCharger when it
detects the disabled state within the phaseSwitchDuration window.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Easee firmware delays ~5 min when starting at 6A. The vendor docs
recommend 7A minimum. Clamp DCC from 6A to 7A before sending the
ChargeStart command (welcome charge). The loadpoint corrects to
the real target current on the next control interval.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@GrimmiMeloni

Copy link
Copy Markdown
Collaborator Author

Refs #30253

@andig

andig commented Jun 13, 2026

Copy link
Copy Markdown
Member

This looks a lot more digestable ;)

@andig andig added the devices Specific device support label Jun 13, 2026
iseeberg79 pushed a commit to iseeberg79/evcc that referenced this pull request Jun 14, 2026
easee: clamp DCC to 7A before ChargeStart
Co-Authored-By: Claude Opus 4.6 <[email protected]>
@github-actions github-actions Bot added the stale Outdated and ready to close label Jun 20, 2026
@GrimmiMeloni GrimmiMeloni self-assigned this Jun 25, 2026
@GrimmiMeloni
GrimmiMeloni marked this pull request as ready for review June 25, 2026 04:47

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The clamp threshold of 7A is currently hard-coded in both the implementation and tests; consider extracting this to a named constant (with a brief comment) so the firmware-specific minimum is clearly documented and easier to adjust in one place if Easee changes their recommendation.
  • The new if action == easee.ChargeStart && c.current < 7 condition compares floats directly; if current can come from non-integer sources, consider adding a small tolerance or treating values in a narrow band around 7A consistently to avoid unexpected behavior due to floating-point representation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The clamp threshold of 7A is currently hard-coded in both the implementation and tests; consider extracting this to a named constant (with a brief comment) so the firmware-specific minimum is clearly documented and easier to adjust in one place if Easee changes their recommendation.
- The new `if action == easee.ChargeStart && c.current < 7` condition compares floats directly; if `current` can come from non-integer sources, consider adding a small tolerance or treating values in a narrow band around 7A consistently to avoid unexpected behavior due to floating-point representation.

## Individual Comments

### Comment 1
<location path="charger/easee.go" line_range="540" />
<code_context>
+	// Easee firmware delays ~5 min when starting at 6A.
+	// Vendor docs recommend 7A minimum, clamp DCC before start.
+	if action == easee.ChargeStart && c.current < 7 {
+		if err := c.MaxCurrent(7); err != nil {
+			return err
+		}
</code_context>
<issue_to_address>
**suggestion:** Avoid hard-coding the `7A` threshold and consider expressing it as a named constant or configuration.

This `7A` value comes from vendor guidance and may vary by installation or change over time. Keeping it as a literal makes those semantics harder to adjust and document centrally. Defining a named constant (e.g. `minStartCurrentAmp`) or using a configurable setting will improve maintainability and clarify its special meaning.

Suggested implementation:

```golang
	// Easee firmware delays ~5 min when starting at 6A.
	// Vendor docs recommend a minimum start current, clamp DCC before start.
	if action == easee.ChargeStart && c.current < easeeMinStartCurrentAmp {
		if err := c.MaxCurrent(easeeMinStartCurrentAmp); err != nil {
			return err
		}
	}

```

Define a package-level constant for the minimum start current, including a short comment documenting the vendor guidance and why this value is special. For example, near the other constants in `charger/easee.go`:

```go
const easeeMinStartCurrentAmp = 7 // vendor-recommended minimum to avoid ~5 min start delay at 6A
```

If your project prefers configuration-driven values, replace this constant with a configurable setting (e.g. from a config struct or environment) and use that instead of the literal `7`.
</issue_to_address>

### Comment 2
<location path="charger/easee_test.go" line_range="801-809" />
<code_context>
+			err := e.Enable(true)
+			assert.NoError(t, err)
+
+			if tc.expectClamp {
+				assert.Equal(t, []string{"settings", "start"}, callOrder,
+					"DCC clamp should be sent before ChargeStart")
+				assert.Equal(t, 7.0, e.current, "current should be clamped to 7")
+			} else {
+				assert.Equal(t, []string{"start"}, callOrder,
+					"no DCC clamp should be sent")
+				assert.Equal(t, tc.current, e.current, "current should be unchanged")
+			}
+		})
+	}
</code_context>
<issue_to_address>
**suggestion (testing):** Strengthen the assertions by verifying the actual DCC payload sent in the settings call

The test currently checks call order and that `e.current` is set to 7, but it doesn’t verify that the HTTP `settings` request actually sends a "7A" limit. To make the test more robust, inspect the `req` in the `settingsURI` responder and assert that the parsed JSON/current value is 7 when `expectClamp` is true, and that no `settings` call is made when `expectClamp` is false. This confirms the DCC is clamped on the wire, not just in an internal field.

Suggested implementation:

```golang
				// Transition to expected state for waitForChargerEnabledState(true)
				e.mux.Lock()
				e.opMode = easee.ModeAwaitingStart
				e.mux.Unlock()
				return httpmock.NewStringResponse(200, ""), nil
			})

			err := e.Enable(true)
			assert.NoError(t, err)

			if tc.expectClamp {
				// settings endpoint must have been called with clamped current
				assert.True(t, settingsCalled, "settings endpoint should be called when clamping is expected")

				if assert.NotNil(t, settingsPayload, "settings payload must be captured") {
					// Accept either "7A" or numeric 7, depending on how the DCC limit is encoded
					var (
						limitStr string
						limitNum float64
						ok       bool
					)

					if limitStr, ok = settingsPayload["maxCurrent"].(string); ok {
						assert.Equal(t, "7A", limitStr, "settings maxCurrent should be clamped to 7A")
					} else if limitNum, ok = settingsPayload["maxCurrent"].(float64); ok {
						assert.Equal(t, 7.0, limitNum, "settings maxCurrent should be clamped to 7")
					} else {
						t.Fatalf("settings maxCurrent must be string or number, got: %#v", settingsPayload["maxCurrent"])
					}
				}
			} else {
				// when clamping is not expected, no settings call should be made
				assert.False(t, settingsCalled, "settings endpoint should not be called when clamping is not expected")
			}
		})
	}
}

func TestEasee_Enable_clampsCurrentOnChargeStart(t *testing.T) {
	const chargerID = "TESTTEST"

	tests := []struct {
		name        string
		current     float64
		expectClamp bool
	}{

```

To make these assertions work, you also need to:

1. In `TestEasee_Enable_clampsCurrentOnChargeStart`, before registering the responder for the `settings` URI, declare variables in the test case scope to capture the call and payload, e.g.:

```go
var (
    settingsCalled  bool
    settingsPayload map[string]interface{}
)
```

2. Update the `settingsURI` responder used in this test to parse and store the JSON body:

```go
httpmock.RegisterResponder("POST", settingsURI, func(req *http.Request) (*http.Response, error) {
    settingsCalled = true
    defer req.Body.Close()

    var payload map[string]interface{}
    if err := json.NewDecoder(req.Body).Decode(&payload); err != nil {
        t.Fatalf("failed to decode settings payload: %v", err)
    }
    settingsPayload = payload

    return httpmock.NewStringResponse(200, ``), nil
})
```

3. Ensure the test file imports `encoding/json` if it is not already imported.

Adjust the exact field name (`"maxCurrent"`) and endpoint/method (`"POST", settingsURI`) to match the actual Easee API wrapper and existing test conventions if they differ.
</issue_to_address>

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.

Comment thread charger/easee.go Resolved
Comment thread charger/easee_test.go Resolved
@GrimmiMeloni

Copy link
Copy Markdown
Collaborator Author

Tested this the last 2 weeks locally. I did not notice any problems caused by it.

@GrimmiMeloni GrimmiMeloni removed the stale Outdated and ready to close label Jun 25, 2026
@GrimmiMeloni
GrimmiMeloni requested a review from andig June 25, 2026 04:51
@GrimmiMeloni GrimmiMeloni changed the title easee: clamp DCC to 7A before ChargeStart easee: clamp DCC to 7A before ChargeStart and remove overshoot protection Jun 25, 2026
@andig
andig merged commit 3f9e087 into evcc-io:master Jun 25, 2026
14 checks passed
@andig

andig commented Jun 25, 2026

Copy link
Copy Markdown
Member

Much smaller fix surface :)

@pasqualito79

Copy link
Copy Markdown

Will this also work if minimum current is set to 7A? Because with 6A my easee will not change from 1 phase to 3 phases automatically. This was always like that and still is the case with most current easee firmware and evcc versions. With 7A no problems at all, switching from 1p to 3p and back (I think it has something to do with the equalizer, but never found out the root cause)

@andig

andig commented Jun 28, 2026

Copy link
Copy Markdown
Member

Shall we use 8 then ;)

@pasqualito79

Copy link
Copy Markdown

or maybe minimum set + 1? ;-)

@andig

andig commented Jun 28, 2026

Copy link
Copy Markdown
Member

…and getvthat minimum from loadpointController?

@GrimmiMeloni

Copy link
Copy Markdown
Collaborator Author

Will this also work if minimum current is set to 7A?

Yes. It would just keep things at 7A.

@pasqualito79

Copy link
Copy Markdown

ok I'll just give it a try then ;-)

@davesen83

Copy link
Copy Markdown

Will this also work if minimum current is set to 7A? Because with 6A my easee will not change from 1 phase to 3 phases automatically. This was always like that and still is the case with most current easee firmware and evcc versions. With 7A no problems at all, switching from 1p to 3p and back (I think it has something to do with the equalizer, but never found out the root cause)

I also have this issue 🤨 Isn't there a solution having also the 6A but phase switching works?

@GrimmiMeloni

Copy link
Copy Markdown
Collaborator Author

I also have this issue 🤨
Which issue exactly? This is a PR.

Isn't there a solution having also the 6A but phase switching works?
It does. But some cars might not like the delay.

@davesen83

Copy link
Copy Markdown

I also have this issue 🤨

Which issue exactly? This is a PR.

Isn't there a solution having also the 6A but phase switching works?

It does. But some cars might not like the delay.

I mean this issue:

Because with 6A my easee will not
change from 1 phase to 3 phases
automatically.

Yes sorry I know this issue has (maybe) no link to this change, but it was mentioned here.

You say, there is a solution? How must I configure the settings, that easee makes the phase switching and I also can use 6A?

@pasqualito79

pasqualito79 commented Jun 29, 2026 •

Copy link
Copy Markdown

see discussions like this and the answer: #30253
It will just not work with 6A, there is no possibility in evcc config to get it working. The only way is to open an incident with easee and let them fix it (which will probably need a lot of time and nerves which I don't have ;-)

@GrimmiMeloni

Copy link
Copy Markdown
Collaborator Author

We have to be exact, as it seems things are getting mixed up here right now.

To be clear: Phase switching generally works.

It is the start of a charge (or REstart of a charge after phase switch) which gets delayed by 5 minutes if DCC is set to 6A.

How bad this is, depends on the individual vehicle.
For my vehicles (Skoda (3.x FW) and Fiat), this is not an issue - they will happily wait for 5 minutes and then start charging. If anything, the delay is simply a nuisance.

But for others, e.g. Mercedes EQ-series cars this is a more pressing issue. These vehicles' onboard charger does not like the 5 minutes delay. Once the Easee finally wants to start charging, the vehicle has timed out and gone into a permanent error state which they can only get out of by replugging. That's what #30253 is about. I was hoping that removing the overshoot protection would also fix this, but it does not, as it only is effective during charge start.

If you look more closely at the commit in the branch you see I also experimented with disabling and reenabling the charger, but that lead to charger logic errors. So it is not an option either.

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

Labels

devices Specific device support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants