Repository navigation
feat(zaptec_cloud): control the charger's current, pause and resume (0.2.0) - #240
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe2fe8d9ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| local mode = type(cmd.phase_mode) == "string" and cmd.phase_mode or "" | ||
| local one_phase = (mode == "1p") or (mode ~= "3p" and phases_cfg == 1) | ||
| local phases = 3 | ||
| if one_phase and live_phase_count() <= 1 then phases = 1 end |
There was a problem hiding this comment.
Require positive phase evidence before using single-phase math
When a three-phase charger is idle or paused, all phase currents are zero, so live_phase_count() <= 1 incorrectly treats it as confirmed single-phase. With phase_mode = "1p", a 6,900 W order and a 32 A cap, the harness writes 30 A instead of 10 A. Since this driver never switches phases, a three-phase vehicle can then draw 20,700 W rather than the allocated 6,900 W. Missing current observations trigger the same behavior. Keep the conservative three-phase calculation unless single-phase operation is positively established; zero or missing current is not that evidence.
Useful? React with 👍 / 👎.
| local wrote = write_current(0) | ||
| send_command(CMD_PAUSE) | ||
| if wrote then | ||
| stood_down = true |
There was a problem hiding this comment.
Require a successful pause before settling in stand-alone mode
When stand-alone mode is active, the driver explicitly recognizes that API current settings are ignored. Nevertheless, an accepted zero-current write sets stood_down even if the pause command fails. This leaves the charger running without an effective clamp and suppresses all subsequent stand-down attempts until another order arrives. The harness reproduces this with observation 712 set to 1 and a 503 response to command 506: no retry occurs after five minutes. In stand-alone mode, only a successful pause should establish that stand-down completed. This also violates the required safe default mode.
AGENTS.md reference: AGENTS.md:L34-L35
Useful? React with 👍 / 👎.
| setup: [vendor_portal] | ||
| ders: [ev] | ||
| control: false | ||
| control: true |
There was a problem hiding this comment.
Keep control disabled until hardware acceptance is recorded
This enables catalog control and removes the driver's read-only guard while the manifest and changelog explicitly state that control has not been confirmed on hardware. The supplied mock-API tests do not satisfy the repository's requirement for HIL acceptance on every target host; SUPPORT_STATUS.md still records no hardware acceptance for either target. Keep the control path gated and the catalog read-only until the required hardware evidence is available.
AGENTS.md reference: AGENTS.md:L34-L35
Useful? React with 👍 / 👎.
…0.2.0) The driver read a Zaptec Go but declared itself read-only, so FTW accepted the charger and never steered it. An owner whose main fuse was overloaded by the car had no way to see why. Current goes to the charger's maxChargeCurrent, which Zaptec documents for an external party that overrides its load balancer. The installation's AvailableCurrent is not used: Zaptec asks for at most one change per 15 minutes, too slow for a fuse guard. Amps never exceed Core's per-phase budget: three phases are assumed unless Core and the charger both say one, values round down and 0 A goes out below 6 A. Pause is 0 A plus command 506, resume offers the last order plus 507, and codes 520/528 count as done. Stand-alone mode refuses orders and says why. The stand-down settles and retries after five minutes when refused. Missing readings stay nil. Written from Zaptec's API documentation; not yet confirmed on hardware. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
A resume right after a pause read the last poll, which still said charging, and skipped command 507. The charger would have stayed paused. Found by running the driver in FTW's Lua host. Resume now always sends 507; 520 and 528 count as done. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
…safer phases Review findings: - A positive order on a paused charger now also sends 507, so a stand-down or Core restart cannot leave the car paused. - 520 is ErrorCommunicatingWithDevice: the command never arrived, so it fails. 528 counts as done unless the driver paused the charger itself. A 200 carrying a non-zero Code is an error. - A 1p order on an idle charger used one phase, so a three-phase car could draw 32 A on each phase. One phase now needs a one-phase installation, or Core asking for one with exactly one phase drawing. - Resume offers 6 A, never above Core's last cap, instead of a stale order. A missing cap keeps Core's last one. - A 401 signs in again once. A failed poll forgets phase currents. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
A pause Zaptec turned away (528, or no car plugged in) set the paused flag. Once a car plugged in, a positive order resent 507, got 528 for nothing to resume, and reported failure every 30 s until the car drew current. The flag now follows only a pause the charger took. A one-phase config no longer outvotes three phases measured. The unused want_paused state is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
91d12cf to
ce7b219
Compare
What
FTW now controls a Zaptec Go, Go 2 or Pro through Zaptec Cloud. Before this, the driver read the charger but declared
read_only = true. FTW accepted the charger and never steered it. One owner with a 20 A main fuse saw L1 overload whenever the car charged next to the battery.maxChargeCurrent(POST /api/chargers/{id}/update). Zaptec documents that setting for "an external party [that] must override the Zaptec load balancer". The installation'sAvailableCurrentis not used, because Zaptec asks for at most one change per 15 minutes, which is too slow for a fuse guard. The installation's own circuit-breaker limit still applies.max_amps_per_phaseor 32 A.reason_no_current_label.driver_default_mode) writes 0 A and pauses once, then does nothing until a new order. A refused stand-down retries after five minutes.User-Agent: FTW-zaptec_cloud/<version>.The driver does not switch phases.
Evidence
drivers/tests/lua_harness/test_zaptec_cloud_control.lua: watts to amps, the caps, the 1p rule, rounding, deduplication, pause and resume, the codes, stand-alone mode, stand-down settling and retry, nil readings and the User-Agent.httptest). It confirmed the exact POST sequence and bodies, the bearer token, the User-Agent, code 528 on resume and a settling stand-down. That run found a real bug: a resume right after a pause read a stale "charging" poll and skipped 507. The fix is in the second commit, and the harness now covers the case.make test-driver ID=zaptec_cloudandmake checkboth pass (5 092 passed).Hardware
Not yet confirmed on hardware. The control path stays
verification_status = "experimental". A Zaptec Go owner on a 20 A fuse can test it on the beta channel.Sources
The source is Zaptec's API documentation: https://api.zaptec.com/help/index.html and its OpenAPI file, now listed in
upstream_docs. evcc's Zaptec charger was read to understand how the API behaves in the field, including the 520/528 codes and stand-alone mode. That evcc module is not MIT-licensed, so no code was taken from it.Refs #239 (the rule change: a driver that can command its device ships with control on).
🤖 Generated with Claude Code