Skip to content

Add Chargepoint Home Flex charger#28512

Draft
blampe wants to merge 14 commits intoevcc-io:masterfrom
blampe:blampe/chargepoint-pr
Draft

Add Chargepoint Home Flex charger#28512
blampe wants to merge 14 commits intoevcc-io:masterfrom
blampe:blampe/chargepoint-pr

Conversation

@blampe
Copy link
Contributor

@blampe blampe commented Mar 24, 2026

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.

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`.
@blampe blampe force-pushed the blampe/chargepoint-pr branch from b977a60 to 580a5a7 Compare March 24, 2026 04:16
Copy link
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:

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

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.

}

// StopSession stops the active charging session on the given device.
func (a *API) StopSession(deviceID int) error {
Copy link
Member

Choose a reason for hiding this comment

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

evcc never stops a charging session.

Session is only ended by disconnecting the vehicle.

Copy link
Contributor Author

@blampe blampe Mar 24, 2026

Choose a reason for hiding this comment

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

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!

Copy link
Member

Choose a reason for hiding this comment

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

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).
Copy link
Member

Choose a reason for hiding this comment

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

really 8A?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep!

{
  "chargeLimit": 48,
  "inProgress": false,
  "possibleChargeLimit": [8, 9, 10, ..., 46, 47, 48]
}

Copy link
Member

@premultiply premultiply Mar 26, 2026

Choose a reason for hiding this comment

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

Does not look like a valid IEC charger.
Is this a legacy U.S. device?

v.SSOSessionID = res.SSOSessionID

if err := settings.SetJson(v.settingsKey, v.identityState); err != nil {
return fmt.Errorf("persisting chargepoint identity: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

pls keep errors similar to other implementations

@andig
Copy link
Member

andig commented Mar 24, 2026

This is quite a bit how code. How wide-spread is this charger? And does it by chance support OCPP?

@andig andig added the devices Specific device support label Mar 24, 2026
@blampe
Copy link
Contributor Author

blampe commented Mar 25, 2026

This is quite a bit how code. How wide-spread is this charger?

I have no frame of reference but Amazon numbers put it about on par with Emporia so I guess fairly popular?

image

And does it by chance support OCPP?

I wish 😭 It's apparently only supported on their commercial chargers.

I'm obviously more than happy to maintain the implementation!

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)
Copy link
Member

Choose a reason for hiding this comment

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

return an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@premultiply premultiply marked this pull request as draft March 26, 2026 05:36
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.

3 participants