Skip to content

Commit f98d5c5

Browse files
frahlgclaude
andauthored
feat(easee_cloud): emit request_active so the host can tell car-declined from box-paused (#103)
Easee reason 50 ("secondary unit not requesting current") and op_mode 4 ("completed") are the vehicle's side of the conversation; 52/53/100, pending authorization and schedule states are ours. Emitting the distinction lets the FTW host's existing 90 s debounce do its job: the session-completion latch stops the planner allocating energy to a full car, a manual Start hold auto-releases instead of offering power all night, and the charging-interrupted notification stops firing on the car's own renegotiation bursts. Editing this FTW-promoted driver wakes the full catalog suite, so the driver now also meets it: every host.http_get and host.json_decode is pcall-wrapped (safe_http_get / safe_json_decode) so a raising host or a garbage API response degrades to (nil, err) instead of killing the poll. The catalog manifest had already drifted to 1.1.1 while the DRIVER block said 1.0.1; both now agree on 1.2.0. Claude-Session: https://claude.ai/code/session_01C1d4uknzs7QUv7nE9rW4fi Signed-off-by: Fredrik Ahlgren <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
1 parent 19dd64c commit f98d5c5

7 files changed

Lines changed: 65 additions & 19 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ Driver versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html
99

1010
### Changed
1111

12+
- **easee_cloud** 1.2.0 — emit `request_active`: false only when the vehicle
13+
side has explicitly stopped requesting current (Easee `reasonForNoCurrent`
14+
50, or `op_mode` 4 "completed"); every box-ordered pause (52/53/100, pending
15+
authorization, schedules, fuse limits) stays true. Lets the FTW host tell
16+
"the car declined" from "we paused it": the session-completion latch stops
17+
the planner allocating energy to a full car, a manual Start hold
18+
auto-releases instead of offering power all night, and the
19+
charging-interrupted notification stops firing on the car's own
20+
renegotiation bursts. Field-observed 2026-08-29: a car at its own charge
21+
limit held reason 50 overnight while the box kept offering 11 kW and paged
22+
the operator twice.
23+
1224
- **zap** 3.1.0 — P1/HAN remains the default. `read_pv` and `read_battery` are opt-in, read-only ingest of devices Zap already talks to (closed inverter Modbus, or an RS-485 bus Zap owns). Off by default so a native FTW driver is not doubled. The driver still never writes. Chargers stay out: add those in FTW.
1325
- **`nibe_local` 1.1.3** — heat-pump diagnostic metrics convert vendor kW/kWh to W/Wh at emit (case and surrounding spaces folded, so `kW ` still converts). Headline names `hp_energy_consumed_kwh` and `hp_energy_produced_kwh` stay so existing series keys do not move; the unit field is Wh. `DRIVER.read_only = true` so the signed artifact matches the observe-only command path. HTTP GET and JSON decode wrap in `pcall`.
1426
- **`myuplink` 1.2.1** — bulk kW/kWh points and the `hp_power_w` headline convert to W/Wh at emit. There are no `hp_energy_*_kwh` headlines; energy, if the pump reports it, is a sanitized bulk name with unit Wh.

‎SUPPORT_STATUS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ Catalog source is not proof that a target can install or run a driver.
4646
| deye | 2.1.1 | blixt-l1 | not_assessed | — | — | not_recorded | — | not_assessed | no |
4747
| easee | 1.0.4 | ftw-core | not_assessed | — | — | not_recorded | — | not_assessed | no |
4848
| easee | 1.0.4 | blixt-l1 | not_assessed | — | — | not_recorded | — | not_assessed | no |
49-
| easee_cloud | 1.1.1 | ftw-core | not_assessed | — | — | not_recorded | — | not_assessed | no |
50-
| easee_cloud | 1.1.1 | blixt-l1 | not_assessed | — | — | not_recorded | — | not_assessed | no |
49+
| easee_cloud | 1.2.0 | ftw-core | not_assessed | — | — | not_recorded | — | not_assessed | no |
50+
| easee_cloud | 1.2.0 | blixt-l1 | not_assessed | — | — | not_recorded | — | not_assessed | no |
5151
| esphome-dsmr | 1.0.3 | ftw-core | not_assessed | 1.0.2 | — | not_recorded | — | not_assessed | no |
5252
| esphome-dsmr | 1.0.3 | blixt-l1 | not_assessed | — | — | not_recorded | — | not_assessed | no |
5353
| esphome_dsmr | 1.0.3 | ftw-core | not_assessed | — | — | not_recorded | — | not_assessed | no |

‎devices.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ manufacturers:
349349
protocols:
350350
- protocol: http
351351
driver: "easee_cloud"
352-
version: "1.1.1"
352+
version: "1.2.0"
353353
ders: [ev]
354354
control: true
355355
firmware_versions: ""

‎drivers/lua/easee_cloud.lua‎

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ DRIVER = {
2525
id = "easee-cloud",
2626
name = "Easee Cloud",
2727
manufacturer = "Easee",
28-
version = "1.0.1",
28+
version = "1.2.0",
2929
protocols = { "http" },
3030
capabilities = { "ev" },
3131
description = "Easee Home/Charge via Cloud REST API. No local protocol needed.",
@@ -181,6 +181,22 @@ local function redact_http_err(err)
181181
return tostring(err):match("^(HTTP %d+)") or "request failed"
182182
end
183183

184+
-- Wrapped transport. A host whose http_get raises, or a vendor API
185+
-- that answers with garbage, must degrade to (nil, err) — never kill
186+
-- the driver mid-poll.
187+
local function safe_http_get(url, headers)
188+
local ok, resp, err = pcall(host.http_get, url, headers)
189+
if not ok then return nil, tostring(resp) end
190+
return resp, err
191+
end
192+
193+
local function safe_json_decode(s)
194+
if s == nil then return nil end
195+
local ok, data = pcall(host.json_decode, s)
196+
if not ok then return nil end
197+
return data
198+
end
199+
184200
-- ---- Auth helpers ----
185201

186202
local function login(email, password)
@@ -190,7 +206,7 @@ local function login(email, password)
190206
host.log("error", "Easee login failed: " .. redact_http_err(err))
191207
return false
192208
end
193-
local data = host.json_decode(resp)
209+
local data = safe_json_decode(resp)
194210
if not data or not data.accessToken then
195211
host.log("error", "Easee login: no accessToken in response")
196212
return false
@@ -215,7 +231,7 @@ local function do_refresh()
215231
host.log("warn", "Easee token refresh failed: " .. redact_http_err(err))
216232
return false
217233
end
218-
local data = host.json_decode(resp)
234+
local data = safe_json_decode(resp)
219235
if not data or not data.accessToken then
220236
host.log("warn", "Easee refresh: no accessToken, will re-login")
221237
return false
@@ -246,9 +262,9 @@ end
246262
-- ---- API helpers ----
247263

248264
local function get_chargers()
249-
local resp, err = host.http_get(BASE_URL .. "/chargers", auth_headers())
265+
local resp, err = safe_http_get(BASE_URL .. "/chargers", auth_headers())
250266
if err then return nil, err end
251-
return host.json_decode(resp), nil
267+
return safe_json_decode(resp), nil
252268
end
253269

254270
-- Observation IDs (from developer.easee.com/docs/charger-observation-ids)
@@ -266,9 +282,9 @@ local OBS_IDS = "48,96,103,109,120,121,124,183,194"
266282

267283
local function get_observations(serial)
268284
local url = "https://api.easee.com/state/" .. serial .. "/observations?ids=" .. OBS_IDS
269-
local resp, err = host.http_get(url, auth_headers())
285+
local resp, err = safe_http_get(url, auth_headers())
270286
if err then return nil, err end
271-
local decoded = host.json_decode(resp)
287+
local decoded = safe_json_decode(resp)
272288
if not decoded then return nil, "decode failed" end
273289
local list = decoded.observations or decoded
274290
local obs = {}
@@ -355,9 +371,9 @@ local email, password, configured_max_a
355371
-- (compare requested phaseMode after a write) is a follow-up; this
356372
-- driver's contribution is the diagnostic logging at init.
357373
local function read_settings(serial)
358-
local resp, err = host.http_get(BASE_URL .. "/chargers/" .. serial .. "/config", auth_headers())
374+
local resp, err = safe_http_get(BASE_URL .. "/chargers/" .. serial .. "/config", auth_headers())
359375
if err then return nil, redact_http_err(err) end
360-
local decoded = host.json_decode(resp)
376+
local decoded = safe_json_decode(resp)
361377
if decoded == nil then
362378
return nil, "decode failed (non-JSON response)"
363379
end
@@ -531,10 +547,28 @@ function driver_poll()
531547
command_stalled_since_ms = 0
532548
end
533549

550+
-- request_active: false ONLY when the vehicle side has explicitly
551+
-- stopped requesting current — Easee reason 50 ("secondary unit
552+
-- not requesting current"; the vehicle is the secondary unit) or
553+
-- op_mode 4 ("completed"). Every other reason (52/53/100 = the box
554+
-- throttled it, pending authorization, schedules, fuse limits)
555+
-- keeps the default true, so a pause the box itself ordered is
556+
-- never mistaken for the car declining. The host debounces this
557+
-- for 90 s before acting on it (session-completion latch,
558+
-- manual-hold auto-release), so a brief 50 during session
559+
-- handshake is harmless. Field observation 2026-08-29: a car at
560+
-- its own charge limit held reason 50 all night while the box kept
561+
-- offering 11 kW and paged the operator twice about it.
562+
local request_active = true
563+
if connected and not charging and (reason_code == 50 or op_mode == 4) then
564+
request_active = false
565+
end
566+
534567
host.emit("ev", {
535568
w = power_w,
536569
connected = connected,
537570
charging = charging,
571+
request_active = request_active,
538572
session_wh = session_wh,
539573
op_mode = op_mode, -- 1=disc,2=awaiting,3=charging,4=completed,5=error,6=ready
540574
state_label = OP_MODE_LABELS[op_mode] or "unknown",

‎index.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,15 @@ drivers:
193193
size_bytes: 4054
194194
sha256: "4a2cd1efb4a5583468ce897ebd88a000e348917295c40210e86ecf834c0ba543"
195195
- name: "easee_cloud"
196-
version: "1.1.1"
196+
version: "1.2.0"
197197
tier: core
198198
protocol: http
199199
connectivity: cloud
200200
setup: [vendor_portal]
201201
ders: [ev]
202202
control: true
203-
size_bytes: 31312
204-
sha256: "dfe3107d6d99e03204184602fd2be973efb53b7f122d4ad1dd3cbe1d0be5ebd4"
203+
size_bytes: 32848
204+
sha256: "ea3c8b158ebef1ad2f8a3f94a82e2826438231e8fe04c5957546ee836b370ec8"
205205
- name: "esphome-dsmr"
206206
version: "1.0.3"
207207
tier: community

‎manifests/easee_cloud.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "easee_cloud"
2-
version: "1.1.1"
2+
version: "1.2.0"
33
tier: core
44
author: "Sourceful Labs AB"
55
protocol: http
@@ -16,9 +16,9 @@ tested_devices:
1616
notes: "Easee Home/Charge via Cloud REST API. No local protocol needed."
1717
min_driver_version: "1.0.1"
1818
min_host_version: "2.0.0"
19-
size_bytes: 31312
19+
size_bytes: 32848
2020
dkb_id: "easee_cloud"
21-
sha256: "dfe3107d6d99e03204184602fd2be973efb53b7f122d4ad1dd3cbe1d0be5ebd4"
21+
sha256: "ea3c8b158ebef1ad2f8a3f94a82e2826438231e8fe04c5957546ee836b370ec8"
2222
signature: ""
2323

2424
bytecode_sha256: ""

‎support-status.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@
590590
},
591591
{
592592
"catalog_source": true,
593-
"catalog_version": "1.1.1",
593+
"catalog_version": "1.2.0",
594594
"driver_id": "easee_cloud",
595595
"package_id": null,
596596
"targets": {

0 commit comments

Comments
 (0)