You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 28c771f
Browse filesBrowse the repository at this point in the historyBrowse files
fix(zaptec_cloud): start one-phase cars, hand the charger back, give the cloud time (0.3.0) (#279)
* fix(zaptec_cloud): start one-phase cars, hand the charger back, give 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]>
* fix(zaptec_cloud): keep FTW's pause and the charger minimum through odd 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]>
---------
Signed-off-by: Fredrik Ahlgren <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
-- on exactly one. A single-phase car can then only draw less than Core
23
23
-- budgeted, never more. With no cap in an order it keeps Core's last one.
24
24
--
25
+
-- One exception lets a single-phase car start. Below the charger's minimum
26
+
-- (observation 511, usually 6 A) Zaptec allocates nothing, so a one-phase
27
+
-- order of up to 18 A on an idle three-phase charger came out as 0 A and the
28
+
-- car never started. When Core asks for one phase, the charger draws on no
29
+
-- phase, its state is fresh and the order is at least the minimum on one
30
+
-- phase, the driver offers that minimum, as a resume does. Once the car draws
31
+
-- on one phase, the next order gets its full one-phase current.
32
+
--
33
+
-- The driver never writes a positive current below the charger's minimum.
34
+
-- Zaptec documents that a maximum below the minimum allocates no current; an
35
+
-- owner saw that as "Max Current lower than Min Current" in the portal.
36
+
--
25
37
-- Stand-alone mode (observation 712) makes the charger ignore current set
26
38
-- through the API. The driver then refuses current orders and says why.
27
39
--
28
40
-- When FTW can no longer steer (driver_default_mode) it pauses and sets
29
41
-- 0 A, as easee_cloud does, but only once FTW has written a current in this
30
-
-- run. maxChargeCurrent is stored on the charger, so an owner who stops
31
-
-- using FTW sets it again in the Zaptec app or portal.
42
+
-- run. maxChargeCurrent is stored on the charger. Core runs driver_release
43
+
-- instead when the owner removes or disables this driver: the driver puts
44
+
-- back the maximum it found before FTW's first write in this run, or 32 A
45
+
-- (no charger cap; the installation's own limits still apply) when that is
46
+
-- unknown or below the minimum, and resumes a charger FTW paused. Without
47
+
-- that, the charger stayed at 0 A and neither the Zaptec app nor another
48
+
-- load balancer could start it.
49
+
--
50
+
-- Zaptec Cloud often takes a few seconds per call. The driver asks the host
51
+
-- for 20 s per call (host.set_command_timeout_s), and retries a request once
52
+
-- after a server error or a lost connection. Both writes are idempotent: a
53
+
-- repeated command that changes nothing comes back 528.
32
54
--
33
55
-- Sign convention: positive W is charging (power into the vehicle).
34
56
--
@@ -45,7 +67,7 @@ DRIVER = {
45
67
id="zaptec_cloud",
46
68
name="Zaptec Cloud",
47
69
manufacturer="Zaptec",
48
-
version="0.2.2",
70
+
version="0.3.0",
49
71
protocols= { "http" },
50
72
capabilities= { "ev" },
51
73
description="Zaptec Go / Go 2 / Pro via Zaptec Cloud. Email + password; optional charger serial. FTW sets the charging current and pauses or resumes.",
@@ -71,6 +93,7 @@ local OBS_CURRENT_L1 = 507
71
93
localOBS_CURRENT_L2=508
72
94
localOBS_CURRENT_L3=509
73
95
localOBS_MAX_CURRENT=510
96
+
localOBS_MIN_CURRENT=511
74
97
localOBS_CHARGE_POWER=513
75
98
localOBS_SESSION_ENERGY=553
76
99
localOBS_OP_MODE=710
@@ -91,10 +114,17 @@ local CMD_RESUME = 507
91
114
-- command never reached the charger, so it is a failure.
92
115
localCODE_REJECTED=528
93
116
94
-
-- Charger limits. Below MIN_A a charger allocates no current, so the driver
95
-
-- writes 0 rather than rounding a small order up.
117
+
-- Charger limits. Below its minimum a charger allocates no current, so the
118
+
-- driver writes 0 rather than rounding a small order up. MIN_A is Zaptec's
119
+
-- default minimum; a charger that reports a higher one (511) uses that.
96
120
localMIN_A=6
97
121
localMAX_A=32
122
+
-- What driver_release writes when the owner's own maximum is unknown: no cap
123
+
-- on the charger, so the installation's limits govern as before FTW.
124
+
localHANDBACK_A=32
125
+
-- Time per driver call asked of the host, and the wait before one retry.
126
+
localCOMMAND_TIMEOUT_S=20
127
+
localRETRY_WAIT_MS=1000
98
128
-- A live phase counts when it carries at least this much current.
99
129
localLIVE_PHASE_A=1.0
100
130
-- Rewrite an unchanged current at most this often; small rises wait for it.
@@ -120,13 +150,20 @@ local stand_alone = false
120
150
localop_mode=nil
121
151
localOBS_FINAL_STOP=718
122
152
localphase_currents= { nil, nil, nil }
153
+
localstate_fresh=false-- the last state poll succeeded
154
+
localcharger_min_a=nil-- observation 511
155
+
localcharger_max_a=nil-- observation 510
156
+
localfinal_stop=false-- observation 718
157
+
localowner_max_a=nil-- 510 before FTW's first write in this run
158
+
localwarned_min=false
123
159
localvariant_logged=false
124
160
125
161
-- What the driver last wrote.
126
162
locallast_written_a=nil-- nil until the first write this run
127
163
locallast_write_ms=0
128
164
locallast_cap_a=nil-- Core's last max_amps_per_phase
129
165
localpaused=false-- the charger is paused (506 or the poll says so)
166
+
localftw_paused=false-- FTW sent a 506 that held; only a resume clears it
130
167
localresume_try_ms=nil
131
168
localstood_down=false
132
169
localstand_down_try_ms=nil
@@ -335,6 +372,11 @@ local function post(path, body, content_type)
335
372
access_token=nil
336
373
token_expiry=0
337
374
ifensure_auth() thenerr=once() end
375
+
elseiferrand (tostring(err):match("^HTTP 5%d%d") ornottostring(err):match("^HTTP %d")) then
376
+
-- A server error or a lost connection: Zaptec Cloud has these now and
377
+
-- then. Try once more; both writes are safe to repeat.
378
+
host.sleep(RETRY_WAIT_MS)
379
+
err=once()
338
380
end
339
381
returnerr
340
382
end
@@ -384,22 +426,40 @@ local function live_phase_count()
384
426
returnn
385
427
end
386
428
429
+
-- floor_a is the least current the charger allocates: its own minimum
430
+
-- (511) when it reports one at or above Zaptec's 6 A default, else 6 A.
0 commit comments