Conversation
This adds support for the Chargepoint Home Flex charger. The API requires a username/password and hands out a long-lived (6 month) token from that. Too many login attempts will result in 401 response codes, so we persist it in settings. Once you have a valid token there don't seem to be any limits on it. The API also forces brotli compression, hence `util/transport/brotli.go`.
b977a60 to
580a5a7
Compare
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In util/transport/brotli.go, BrotliCompression always overwrites the Accept-Encoding header with "br"; consider only setting it when the header is empty or appending "br" to preserve any existing encodings when the caller explicitly configured them.
- The comment for newDeviceData in charger/chargepoint/identity.go says the device fingerprint is derived from the machine hostname, but the implementation derives it from the username; update the comment to match the actual behavior to avoid confusion.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In util/transport/brotli.go, BrotliCompression always overwrites the Accept-Encoding header with "br"; consider only setting it when the header is empty or appending "br" to preserve any existing encodings when the caller explicitly configured them.
- The comment for newDeviceData in charger/chargepoint/identity.go says the device fingerprint is derived from the machine hostname, but the implementation derives it from the username; update the comment to match the actual behavior to avoid confusion.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
charger/chargepoint/api.go
Outdated
| } | ||
|
|
||
| // StopSession stops the active charging session on the given device. | ||
| func (a *API) StopSession(deviceID int) error { |
There was a problem hiding this comment.
evcc never stops a charging session.
Session is only ended by disconnecting the vehicle.
There was a problem hiding this comment.
In my testing Enable(false) is called when PV surplus is no longer available, or when battery boost reaches its cutoff. I must be misunderstanding something. Maybe this would be more appropriately called StopCharging? Edit: I've renamed it to Start/StopCharging, hopefully that's clearer!
There was a problem hiding this comment.
Enable does not start or stop a charging session. Never try to use it this way.
A session is created by the charger itself and will only end by disconnecting the vehicle.
Enable grants or revokes charging permission. Most chargers implement it by toggeling the current between >= 6A (granted) or 0A (revoked).
If the charger does not support this concept it is not compatible.
| description: | ||
| generic: Min. Current | ||
| help: | ||
| en: Minimum charging current in Ampere (8–48 A). |
There was a problem hiding this comment.
Yep!
{
"chargeLimit": 48,
"inProgress": false,
"possibleChargeLimit": [8, 9, 10, ..., 46, 47, 48]
}
There was a problem hiding this comment.
Does not look like a valid IEC charger.
Is this a legacy U.S. device?
charger/chargepoint/identity.go
Outdated
| v.SSOSessionID = res.SSOSessionID | ||
|
|
||
| if err := settings.SetJson(v.settingsKey, v.identityState); err != nil { | ||
| return fmt.Errorf("persisting chargepoint identity: %w", err) |
There was a problem hiding this comment.
pls keep errors similar to other implementations
|
This is quite a bit how code. How wide-spread is this charger? And does it by chance support OCPP? |
Co-authored-by: andig <cpuidle@gmail.com>
Co-authored-by: andig <cpuidle@gmail.com>
Co-authored-by: andig <cpuidle@gmail.com>
…lampe/chargepoint-pr
…chargepoint-pr
| a.log.DEBUG.Printf("pollAck %s attempt %d/5 (ackId=%d): %v", action, i+1, ackID, err) | ||
| } | ||
|
|
||
| a.log.WARN.Printf("charger did not acknowledge %s within 5s, assuming it succeeded", action) |
There was a problem hiding this comment.
So this charger can get into very weird states, like it thinks the vehicle is plugged in but it's not, or it just refuses to let you toggle charging. I've observed this under totally normal operation, completely independent of EVCC, zero automation. The only way I've found to restore it to the correct state is a hard reboot, but I would strongly prefer to not bake that into EVCC.
I originally had this return an error but during testing it got into one of these weird states, and that just caused an endless loop of EVCC trying to control it with it refusing. Making this best effort for now seems like the safe choice, and I'll probably spend more time trying to understand if there's a better way to nudge it out of these invalid states.

This adds support for the Chargepoint Home Flex charger.
The API requires a username/password and hands out a long-lived (6 month) token from that. Too many login attempts will result in 401 response codes, so we persist it in settings. Once you have a valid token there doesn't seem to be any limits on it.
The API also forces brotli compression, hence
util/transport/brotli.go.