Repository navigation
fix(zaptec_cloud): start one-phase cars, hand the charger back, give the cloud time (0.3.0) - #279
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. |
…the cloud time (0.3.0)
First field test (Zaptec Go, 20 A fuse, two one-phase cars) could not charge.
- A one-phase order on an idle three-phase charger was divided over three
phases, so up to 18 A came out under 6 A and was written as 0 A. The
driver now offers the charger's minimum when Core asks for one phase and
the charger draws on none, as a resume does.
- Every stop left 0 A stored on the charger ("Max Current lower than Min
Current"). driver_release puts back the owner's maximum, or 32 A, and
resumes a charger FTW paused, when the owner removes the driver.
- Zaptec Cloud is slow: ask for 20 s per call and retry once after a
server error or a lost connection.
- Read the charger's minimum (511) and never write a positive current
below it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Fredrik Ahlgren <[email protected]>
710d797 to
6a9533e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 710d797716
ℹ️ 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".
| if phases == 3 and mode == "1p" and live == 0 and state_fresh | ||
| and w / voltage >= floor and (cap == nil or cap >= floor) then | ||
| return floor |
There was a problem hiding this comment.
Exclude known three-phase cars from the one-phase start exception
When a car previously measured on three phases stops drawing, the next successful idle poll makes this exception eligible again: no phase history is retained. Reproducing a three-phase charging poll, a zero-current order, an idle poll and then a 1,380 W 1p order offers 6 A on all three phases, allowing 4,140 W instead of the requested 1,380 W. This contradicts the stated exclusion of cars seen on three phases and AGENTS.md's requirement for limits that never exceed what Core asked for. Retain the observed multi-phase capability for the connected session and exclude those cars from this start path.
AGENTS.md reference: AGENTS.md:L39-L42
Useful? React with 👍 / 👎.
| local sent, applied = send_command(CMD_PAUSE) | ||
| if applied then paused = true end | ||
| if applied then paused = true; ftw_paused = true end |
There was a problem hiding this comment.
Preserve pause ownership when a retry returns 528
If Zaptec applies command 506 but its response is lost, the new retry can receive 528 because the charger is already paused. send_command then returns true, false, so this assignment never records that FTW paused the charger. If the owner removes the driver before another state poll, driver_release() restores the current but skips 507 and returns success, leaving the charger paused. The same assignment pattern exists in driver_default_mode(). Preserve the uncertain pause ownership across retries or confirm the resulting state before deciding that release needs no resume.
Useful? React with 👍 / 👎.
…dd replies Review findings on 0.3.0: - A pause whose first reply was lost and whose retry got 528 did not count as FTW's, so a removal left the charger paused. Any pause that held now counts. - A poll that still showed charging just after FTW's pause cleared it. Only a resume clears FTW's pause now. - A state document without 511 reset the minimum to 6 A, letting a write fall below a higher minimum. The last known value stays. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
Problem
The first field test of Zaptec control (Zaptec Go, 3-phase site, 20 A main fuse, Pixii battery, two one-phase cars) never got the car charging under FTW. The help report from v0.167.0-beta.1 showed three faults:
amps_fordivides by three phases. Core asked for 6–17 A on one phase (1 380–3 910 W), which came out as 2–5.7 A and was written asmaxChargeCurrent = 0. The resume path wrote 6 A, the car drew 1.3 kW, and the next order wrote 0 A again. Core then reportedoffered_current_lower, blaming the charger for FTW's own 0 A.driver_default_modewrites 0 A and sends 506 at every Core stop and when the owner removes the driver.maxChargeCurrentis stored on the charger. The owner found "Max Current lower than Min Current" in the Zaptec portal; the Zaptec app and the owner's other load balancer could not start the charger until the owner fixed it by hand.Change (zaptec_cloud 0.3.0)
ChargerMinCurrent) and never write a positive current below it. Start and resume use it.driver_release(). Puts back the maximum found before FTW's first write in this run, or 32 A (no charger cap; the installation's own limits still apply) when that is unknown or below the minimum. It resumes a charger FTW paused, or one left at 0 A with a final stop by an earlier run. It leaves a charger FTW never touched alone. Core calls it only when the owner removes or disables the driver (paired PR in srcfl/ftw); restarts still stand down at 0 A.host.set_command_timeout_s(guarded; older hosts keep 5 s). Retry a request once, after 1 s, on a 5xx or a lost connection. Both writes are safe to repeat; a repeated command that changes nothing gets 528.driver_releaseandset_command_timeout_sindocs/WRITING-A-DRIVER.md,spec/driver-contract.md,spec/host-api.mdand the host API profile. Zaptec's public constants added toupstream_docs.Tests
make test-driver ID=zaptec_cloudandmake check(5 433 passed, 928 skipped) on this machine. New harness cases cover the field case (6, 12 and 17 A one-phase orders while idle → 6 A; the ramp; full 17 A once drawing on one phase; no start for a car seen on three phases or before a fresh poll), a 10 A charger minimum, retry on 503 and on a lost connection, no retry on 400, the 20 s request, and every release path (after a pause, after a stand-down, owner value captured before FTW's first write, left at 0 A by an earlier run, untouched charger, 528, refused write).The control path stays
experimentaluntil a field report confirms it.🤖 Generated with Claude Code