Repository navigation
easee: clamp DCC to 7A before ChargeStart and remove overshoot protection - #30774
Conversation
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]>
This reverts commit 20f8741.
This reverts commit 008db54.
|
Refs #30253 |
|
This looks a lot more digestable ;) |
easee: clamp DCC to 7A before ChargeStart Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
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 < 7condition compares floats directly; ifcurrentcan 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Tested this the last 2 weeks locally. I did not notice any problems caused by it. |
|
Much smaller fix surface :) |
|
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) |
|
Shall we use 8 then ;) |
|
or maybe minimum set + 1? ;-) |
|
…and getvthat minimum from loadpointController? |
Yes. It would just keep things at 7A. |
|
ok I'll just give it a try then ;-) |
I also have this issue 🤨 Isn't there a solution having also the 6A but phase switching works? |
|
I mean this issue:
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? |
|
see discussions like this and the answer: #30253 |
|
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. 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. |
fix #30253
Summary
waitForDynamicChargerCurrent/ overshoot protection fromEnable()— the loadpoint'ssyncChargercorrectsofferedCurrenton the next control intervalEnable(false)wherewaitForDynamicChargerCurrent(0)always timed outTest plan
ChargeStartat 6A sends DCC clamp to 7A before the start commandChargeStartat ≥7A does not send an extra DCC clampChargeResumepath is unaffectedgo test ./charger/ -run TestEasee_Enable_clampsCurrentOnChargeStart🤖 Generated with Claude Code