From a26390836008cd92e1294329dafd49b6d6b2fcf8 Mon Sep 17 00:00:00 2001 From: Fredrik Ahlgren Date: Sat, 21 Nov 2026 18:28:51 +0100 Subject: [PATCH 1/2] fix(zaptec_cloud): a refused stand-down returns false (0.2.2) Core reads a driver_default_mode result of true or nil as "stood down" and then unblocks control and stops retrying. zaptec_cloud returned nil even when both the 0 A write and the pause failed, so a charger that kept charging looked held. It now returns true only when the write or the pause held, or when FTW wrote nothing in this run, and retries a refused stand-down once a minute. WRITING-A-DRIVER.md: "report held once you give up" is for a device FTW never steered, not for a charger it commanded. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Fredrik Ahlgren --- CHANGELOG.md | 12 +++++++ SUPPORT_STATUS.md | 4 +-- devices.yaml | 2 +- docs/WRITING-A-DRIVER.md | 10 ++++++ drivers/lua/zaptec_cloud.lua | 34 ++++++++++++------- .../lua_harness/test_zaptec_cloud_control.lua | 25 ++++++++++---- index.yaml | 6 ++-- manifests/zaptec_cloud.yaml | 6 ++-- support-status.json | 2 +- 9 files changed, 72 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30207aaa..7d80a8ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ ## [Unreleased] +### zaptec_cloud 0.2.2 + +A refused stand-down now returns `false`. Before, `driver_default_mode` +returned nothing, which Core reads as "stood down", so a charger that kept +charging after a failed 0 A write and a failed pause looked held, and Core +unblocked control and stopped retrying. The driver now returns `true` only +when the 0 A write or the pause held, or when FTW wrote nothing in this run, +and it retries a refused stand-down once a minute instead of every five. + +`docs/WRITING-A-DRIVER.md` now says that "report held after giving up" is for +a device FTW never steered, not for a charger it commanded. + ### alfen 1.1.0 The driver can now steer the charger. It emits `ev` with `DRIVER.capabilities diff --git a/SUPPORT_STATUS.md b/SUPPORT_STATUS.md index cfa4d684..1ac31cd5 100644 --- a/SUPPORT_STATUS.md +++ b/SUPPORT_STATUS.md @@ -182,7 +182,7 @@ Catalog source is not proof that a target can install or run a driver. | wallbox | 1.0.3 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | zap | 3.1.3 | ftw-core | not_assessed | — | not_recorded | not_assessed | | zap | 3.1.3 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | -| zaptec_cloud | 0.2.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | -| zaptec_cloud | 0.2.1 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | +| zaptec_cloud | 0.2.2 | ftw-core | not_assessed | — | not_recorded | not_assessed | +| zaptec_cloud | 0.2.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | zuidwijk_p1 | 1.1.2 | ftw-core | not_assessed | — | not_recorded | not_assessed | | zuidwijk_p1 | 1.1.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | diff --git a/devices.yaml b/devices.yaml index e101950b..472a6b3d 100644 --- a/devices.yaml +++ b/devices.yaml @@ -2114,7 +2114,7 @@ manufacturers: protocols: - protocol: http driver: "zaptec_cloud" - version: "0.2.1" + version: "0.2.2" ders: [ev] control: true firmware_versions: "" diff --git a/docs/WRITING-A-DRIVER.md b/docs/WRITING-A-DRIVER.md index 9bbf6e89..08a6e9b7 100644 --- a/docs/WRITING-A-DRIVER.md +++ b/docs/WRITING-A-DRIVER.md @@ -157,6 +157,16 @@ Once it has given up, report the default as held rather than failed. A permanent `false` has the watchdog escalate against a device that was never under control. +That last rule is for a device FTW never steered: a register that is not +there, a block another EMS owns. It does not hold for a device FTW did +command in this run, such as a charger it set to 16 A. Core reads `true` (or +nothing) from `driver_default_mode` as "stood down": it unblocks control and +stops retrying. So once the driver has written, a stand-down the device +refuses returns `false`, and the driver tries the write again no more than +once a minute, returning `false` in between. That still settles, and Core +keeps the device marked as out of its hands until the write holds. +`zaptec_cloud` is the worked example. + ```bash make refused-write-report ID=example ``` diff --git a/drivers/lua/zaptec_cloud.lua b/drivers/lua/zaptec_cloud.lua index 437bea70..81b10294 100644 --- a/drivers/lua/zaptec_cloud.lua +++ b/drivers/lua/zaptec_cloud.lua @@ -45,7 +45,7 @@ DRIVER = { id = "zaptec_cloud", name = "Zaptec Cloud", manufacturer = "Zaptec", - version = "0.2.1", + version = "0.2.2", protocols = { "http" }, capabilities = { "ev" }, description = "Zaptec Go / Go 2 / Pro via Zaptec Cloud. Email + password; optional charger serial. FTW sets the charging current and pauses or resumes.", @@ -102,7 +102,7 @@ local REFRESH_MS = 300000 local SMALL_RISE_A = 0.5 local SMALL_RISE_HOLD_MS = 60000 -- After a failed stand-down, try again no sooner than this. -local STAND_DOWN_RETRY_MS = 300000 +local STAND_DOWN_RETRY_MS = 60000 -- A positive order on a paused charger resends resume no more often than this. local RESUME_RETRY_MS = 30000 @@ -615,25 +615,33 @@ function driver_command(action, power_w, cmd) end function driver_default_mode() - -- Stand down when FTW can no longer steer: 0 A and pause. Settles: once - -- done it does nothing until a new order, and a failed try waits before - -- the next one. Core runs this at every start too, and maxChargeCurrent is - -- stored on the charger, so it acts only after FTW wrote a current in this - -- run. A charger FTW never steered keeps the owner's own setting. - if not charger_id or not email or not password then return end - if last_written_a == nil then return end - if stood_down then return end + -- Stand down when FTW can no longer steer: 0 A and pause. Core runs this at + -- every start too, and maxChargeCurrent is stored on the charger, so it acts + -- only after FTW wrote a current in this run; a charger FTW never steered + -- keeps the owner's own setting. + -- + -- The return value is what Core believes. true means stood down (or nothing + -- of FTW's to hand back); false keeps Core's control blocked and its + -- recovery retrying. A refused stand-down is false, and the write is tried + -- again no more than once a minute, so it settles without lying. + if not charger_id or not email or not password then return true end + if last_written_a == nil then return true end + if stood_down then return true end local now = host.millis() - if stand_down_try_ms and now - stand_down_try_ms < STAND_DOWN_RETRY_MS then return end + if stand_down_try_ms and now - stand_down_try_ms < STAND_DOWN_RETRY_MS then return false end stand_down_try_ms = now - if not ensure_auth() then return end + if not ensure_auth() then return false end local wrote = write_current(0) local _, applied = send_command(CMD_PAUSE) if applied then paused = true end - if wrote then + -- Either holds the car: below 6 A Zaptec allocates nothing, and a paused + -- charger draws nothing. + if wrote or applied then stood_down = true stand_down_try_ms = nil + return true end + return false end function driver_cleanup() diff --git a/drivers/tests/lua_harness/test_zaptec_cloud_control.lua b/drivers/tests/lua_harness/test_zaptec_cloud_control.lua index 4f92150d..8004e950 100644 --- a/drivers/tests/lua_harness/test_zaptec_cloud_control.lua +++ b/drivers/tests/lua_harness/test_zaptec_cloud_control.lua @@ -292,24 +292,37 @@ assert(#current_writes() == writes, "the stand-down did not settle") assert(order(11040, THREE)) driver_default_mode() assert(last_current() == 0, "a new order must re-arm the stand-down") --- A refused stand-down waits before it tries again. +-- A refused stand-down says so, waits a minute before it tries again, and +-- says so again until it holds. boot() poll(CONNECTED) assert(order(11040, THREE)) post_fail["/update"] = "HTTP 503: down" -driver_default_mode() +post_fail["/sendCommand/506"] = 'HTTP 500: {"Code":520}' +assert(driver_default_mode() == false, "a refused stand-down must not report held") local tries = count("/update") -for _ = 1, 5 do driver_default_mode() end +for _ = 1, 5 do assert(driver_default_mode() == false) end assert(count("/update") == tries, "a refused stand-down retried at once") -later(301000) -driver_default_mode() +later(61000) +assert(driver_default_mode() == false) assert(count("/update") == tries + 1, "the stand-down never retried") +post_fail = {} +later(61000) +assert(driver_default_mode() == true, "a stand-down that held must report it") +assert(driver_default_mode() == true and count("/update") == tries + 2, "a held stand-down wrote again") +-- A pause that held is enough even when the 0 A write failed. +boot() +poll(CONNECTED) +assert(order(11040, THREE)) +post_fail["/update"] = "HTTP 503: down" +assert(driver_default_mode() == true, "a held pause is a stand-down") +post_fail = {} -- Core runs the stand-down at every start: a charger FTW never steered in -- this run keeps the owner's setting. boot() poll(CONNECTED) -for _ = 1, 3 do driver_default_mode() end +for _ = 1, 3 do assert(driver_default_mode() == true) end assert(#current_writes() == 0 and count("/sendCommand/506") == 0, "the stand-down touched a charger FTW never steered") diff --git a/index.yaml b/index.yaml index 25aa7c7c..511c9ca6 100644 --- a/index.yaml +++ b/index.yaml @@ -826,15 +826,15 @@ drivers: size_bytes: 30379 sha256: "b11198e45d761599939b8201c0969514bbbbc6c2571dcf56d12959cf9ade2b5d" - name: "zaptec_cloud" - version: "0.2.1" + version: "0.2.2" tier: community protocol: http connectivity: cloud setup: [vendor_portal] ders: [ev] control: true - size_bytes: 22491 - sha256: "ea8157aaef601ad0d00ccdbc917eac4cc77de84e97729cc670ab2ac352d01a7c" + size_bytes: 22862 + sha256: "c4a6bce3f3f68fa5058c5f02072f974c5ee30b12af8de06265407ee35b2605a0" - name: "zuidwijk_p1" version: "1.1.2" tier: core diff --git a/manifests/zaptec_cloud.yaml b/manifests/zaptec_cloud.yaml index 212a9a67..b44148d7 100644 --- a/manifests/zaptec_cloud.yaml +++ b/manifests/zaptec_cloud.yaml @@ -1,5 +1,5 @@ name: "zaptec_cloud" -version: "0.2.1" +version: "0.2.2" tier: community author: "Sourceful Labs AB" protocol: http @@ -16,9 +16,9 @@ tested_devices: notes: "Zaptec Go / Go 2 / Pro via Zaptec Cloud REST API. Email + password; optional charger serial. Control written from Zaptec's API docs; not yet confirmed on hardware." min_driver_version: "0.1.0" min_host_version: "2.0.0" -size_bytes: 22491 +size_bytes: 22862 dkb_id: "zaptec_cloud" -sha256: "ea8157aaef601ad0d00ccdbc917eac4cc77de84e97729cc670ab2ac352d01a7c" +sha256: "c4a6bce3f3f68fa5058c5f02072f974c5ee30b12af8de06265407ee35b2605a0" signature: "" bytecode_sha256: "" diff --git a/support-status.json b/support-status.json index 99826150..7a3ec2d9 100644 --- a/support-status.json +++ b/support-status.json @@ -1871,7 +1871,7 @@ }, { "catalog_source": true, - "catalog_version": "0.2.1", + "catalog_version": "0.2.2", "driver_id": "zaptec_cloud", "targets": { "blixt-l1": { From 56c6152f91a280cc35ea6f33bcf04b7a6b7b86da Mon Sep 17 00:00:00 2001 From: Fredrik Ahlgren Date: Sat, 21 Nov 2026 18:31:01 +0100 Subject: [PATCH 2/2] fix(zaptec_cloud): resume offers 6 A after a pause that held over a refused 0 A write Review of #247: the driver kept the old current as written, so a manual resume would have offered it until Core's next order. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Fredrik Ahlgren --- CHANGELOG.md | 2 ++ docs/WRITING-A-DRIVER.md | 5 +++-- drivers/lua/zaptec_cloud.lua | 3 +++ drivers/tests/lua_harness/test_zaptec_cloud_control.lua | 4 ++++ index.yaml | 4 ++-- manifests/zaptec_cloud.yaml | 4 ++-- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d80a8ac..2a584922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ charging after a failed 0 A write and a failed pause looked held, and Core unblocked control and stopped retrying. The driver now returns `true` only when the 0 A write or the pause held, or when FTW wrote nothing in this run, and it retries a refused stand-down once a minute instead of every five. +When the pause held but the 0 A write did not, a later resume offers 6 A +instead of the current the charger had before. `docs/WRITING-A-DRIVER.md` now says that "report held after giving up" is for a device FTW never steered, not for a charger it commanded. diff --git a/docs/WRITING-A-DRIVER.md b/docs/WRITING-A-DRIVER.md index 08a6e9b7..c964e3ae 100644 --- a/docs/WRITING-A-DRIVER.md +++ b/docs/WRITING-A-DRIVER.md @@ -163,8 +163,9 @@ command in this run, such as a charger it set to 16 A. Core reads `true` (or nothing) from `driver_default_mode` as "stood down": it unblocks control and stops retrying. So once the driver has written, a stand-down the device refuses returns `false`, and the driver tries the write again no more than -once a minute, returning `false` in between. That still settles, and Core -keeps the device marked as out of its hands until the write holds. +once a minute, returning `false` in between. The write rate stays bounded, +the first write that holds returns `true`, and until then Core keeps the +device marked as out of its hands. `zaptec_cloud` is the worked example. ```bash diff --git a/drivers/lua/zaptec_cloud.lua b/drivers/lua/zaptec_cloud.lua index 81b10294..7ddaf266 100644 --- a/drivers/lua/zaptec_cloud.lua +++ b/drivers/lua/zaptec_cloud.lua @@ -637,6 +637,9 @@ function driver_default_mode() -- Either holds the car: below 6 A Zaptec allocates nothing, and a paused -- charger draws nothing. if wrote or applied then + -- A pause that held over a refused 0 A write leaves the charger's + -- current unknown, so a later resume offers the minimum, not the old one. + if not wrote then last_written_a = nil end stood_down = true stand_down_try_ms = nil return true diff --git a/drivers/tests/lua_harness/test_zaptec_cloud_control.lua b/drivers/tests/lua_harness/test_zaptec_cloud_control.lua index 8004e950..27df2de8 100644 --- a/drivers/tests/lua_harness/test_zaptec_cloud_control.lua +++ b/drivers/tests/lua_harness/test_zaptec_cloud_control.lua @@ -317,6 +317,10 @@ assert(order(11040, THREE)) post_fail["/update"] = "HTTP 503: down" assert(driver_default_mode() == true, "a held pause is a stand-down") post_fail = {} +-- ...and a resume after it offers the minimum, not the old 16 A. +local n_before = #current_writes() +assert(driver_command("ev_resume", 0, nil)) +assert(#current_writes() == n_before + 1 and last_current() == 6, "resume after a held pause offered a stale current") -- Core runs the stand-down at every start: a charger FTW never steered in -- this run keeps the owner's setting. diff --git a/index.yaml b/index.yaml index 511c9ca6..a2e6c2f0 100644 --- a/index.yaml +++ b/index.yaml @@ -833,8 +833,8 @@ drivers: setup: [vendor_portal] ders: [ev] control: true - size_bytes: 22862 - sha256: "c4a6bce3f3f68fa5058c5f02072f974c5ee30b12af8de06265407ee35b2605a0" + size_bytes: 23059 + sha256: "a438e7b2c28c17be1d0eca6511e2e67157dbc1510966ef95ceebe872e24aff58" - name: "zuidwijk_p1" version: "1.1.2" tier: core diff --git a/manifests/zaptec_cloud.yaml b/manifests/zaptec_cloud.yaml index b44148d7..93867f6a 100644 --- a/manifests/zaptec_cloud.yaml +++ b/manifests/zaptec_cloud.yaml @@ -16,9 +16,9 @@ tested_devices: notes: "Zaptec Go / Go 2 / Pro via Zaptec Cloud REST API. Email + password; optional charger serial. Control written from Zaptec's API docs; not yet confirmed on hardware." min_driver_version: "0.1.0" min_host_version: "2.0.0" -size_bytes: 22862 +size_bytes: 23059 dkb_id: "zaptec_cloud" -sha256: "c4a6bce3f3f68fa5058c5f02072f974c5ee30b12af8de06265407ee35b2605a0" +sha256: "a438e7b2c28c17be1d0eca6511e2e67157dbc1510966ef95ceebe872e24aff58" signature: "" bytecode_sha256: ""