Skip to content

Commit f7102be

Browse files
frahlgclaude
andauthored
fix(easee_cloud): report 0 W for a charger with no car (1.5.1) (#290)
Since 1.4.2 (#183) op_mode 1 clears TotalPower, and Easee's cloud records TotalPower only when it changes, which needs a car. After every driver start with no car, the ev sample said control_power_available=false until a car was plugged in. FTW Core then marked the EV flow unknown_power and lost Home use for those hours. When a read the driver vouches for shows op_mode 1, the charger is online and has no car, so it draws nothing. The ev sample now carries 0 W as known and confirmed, with op_mode's source time as control_power_observed_at. power_observed_at stays out, as for any unchanged value. TotalPower still cannot be noted while op_mode is 1, and the ordering checks from #183 still apply once a car is connected. Closes #289 Signed-off-by: Fredrik Ahlgren <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent eeee2c4 commit f7102be

10 files changed

Lines changed: 142 additions & 17 deletions

‎CHANGELOG.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
## [Unreleased]
44

5+
### easee_cloud 1.5.1
6+
7+
A charger with no car reports 0 W as a known reading again (#289). Since
8+
1.4.2 a disconnect cleared TotalPower, and Easee's cloud records TotalPower
9+
only when it changes, which needs a car. After every driver start with no
10+
car, power stayed unknown until a car was plugged in, and FTW Core lost Home
11+
use for those hours. Now, when a read the driver vouches for shows op_mode 1,
12+
the `ev` sample carries 0 W with `control_power_available` and
13+
`control_power_confirmed` set and op_mode's source time as
14+
`control_power_observed_at`. Any TotalPower the cloud still holds from before
15+
the disconnect is ignored, as before. Once a car is connected, TotalPower and
16+
1.4.2's ordering checks apply as before.
17+
518
### foxess_h3_smart 0.11.0, konja-261-svk 0.5.0: grid state
619

720
A hybrid inverter with a backup switch keeps the house on its battery when

‎SUPPORT_STATUS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Catalog source is not proof that a target can install or run a driver.
4444
| deye-svk | 0.2.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed |
4545
| deye | 2.2.0 | ftw-core | not_assessed | — | not_recorded | not_assessed |
4646
| deye | 2.2.0 | blixt-l1 | not_assessed | — | not_recorded | not_assessed |
47-
| easee_cloud | 1.5.0 | ftw-core | not_assessed | — | not_recorded | not_assessed |
48-
| easee_cloud | 1.5.0 | blixt-l1 | not_assessed | — | not_recorded | not_assessed |
47+
| easee_cloud | 1.5.1 | ftw-core | not_assessed | — | not_recorded | not_assessed |
48+
| easee_cloud | 1.5.1 | blixt-l1 | not_assessed | — | not_recorded | not_assessed |
4949
| esphome_dsmr | 1.0.8 | ftw-core | not_assessed | — | not_recorded | not_assessed |
5050
| esphome_dsmr | 1.0.8 | blixt-l1 | not_assessed | — | not_recorded | not_assessed |
5151
| etrel | 1.1.1 | ftw-core | not_assessed | — | not_recorded | not_assessed |

‎devices.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ manufacturers:
327327
protocols:
328328
- protocol: http
329329
driver: "easee_cloud"
330-
version: "1.5.0"
330+
version: "1.5.1"
331331
ders: [ev]
332332
control: true
333333
firmware_versions: ""

‎drivers/lua/easee_cloud.lua‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ DRIVER = {
2929
id = "easee_cloud",
3030
name = "Easee Cloud",
3131
manufacturer = "Easee",
32-
version = "1.5.0",
32+
version = "1.5.1",
3333
protocols = { "http" },
3434
capabilities = { "ev" },
3535
description = "Easee Home/Charge via Cloud REST API. No local protocol needed.",
@@ -1228,6 +1228,19 @@ function driver_poll()
12281228
last_power_observed_at = power_observed_at
12291229
end
12301230

1231+
-- A charger with no car draws nothing. op_mode 1 drops TotalPower (see
1232+
-- note_observation), and the cloud records TotalPower only when it
1233+
-- changes, which needs a car: after a restart with no car none may come
1234+
-- for hours (#289). This read is vouched for and the cloud hears the
1235+
-- charger (state_problem rejects op_mode 0), so op_mode 1 is the reading:
1236+
-- 0 W since its source time. power_observed_at stays out, as for any
1237+
-- unchanged value, and Core stamps the reading when it arrives.
1238+
local idle_at = obs[OBS_OP_MODE] == 1 and source_time_key(timestamps[OBS_OP_MODE]) and
1239+
timestamps[OBS_OP_MODE] or nil
1240+
local control_at = idle_at or timestamps[OBS_TOTAL_POWER]
1241+
local power_known = idle_at ~= nil or
1242+
(obs[OBS_TOTAL_POWER] ~= nil and timestamps[OBS_TOTAL_POWER] ~= nil)
1243+
12311244
local reason_code = obs[OBS_REASON_NO_CUR]
12321245
-- ReasonForNoCurrent describes a blocked offer. An older reason is not
12331246
-- a current fault while the charger reports both charging and power.
@@ -1377,13 +1390,13 @@ function driver_poll()
13771390
power_observed_at = power_observed_at,
13781391
-- Control verification needs distinct source samples. A fresh cloud
13791392
-- reply alone does not establish a new physical power measurement.
1380-
control_power_observed_at = timestamps[OBS_TOTAL_POWER],
1381-
control_power_available = obs[OBS_TOTAL_POWER] ~= nil and timestamps[OBS_TOTAL_POWER] ~= nil,
1393+
control_power_observed_at = control_at,
1394+
control_power_available = power_known,
13821395
-- The cloud records power only on change, and the driver reports only
13831396
-- what a REST read of a charger the cloud still hears from vouches for
13841397
-- (see vouched above). An unchanged value is therefore still current,
1385-
-- so a steady charge stays measured.
1386-
control_power_confirmed = obs[OBS_TOTAL_POWER] ~= nil and timestamps[OBS_TOTAL_POWER] ~= nil,
1398+
-- so a steady charge stays measured, and so does an empty charger.
1399+
control_power_confirmed = power_known,
13871400
power_max_age_s = 180,
13881401
energy_observed_at = timestamps[OBS_SESSION_ENERGY],
13891402
state_observed_at = timestamps[OBS_OP_MODE],
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
dofile("drivers/tests/lua_harness/host_mock.lua")
2+
-- A charger with no car draws nothing. Easee records TotalPower only on
3+
-- change, so after a start with no car the cloud may hold none for hours;
4+
-- op_mode 1 from a vouched read is then the power reading: 0 W (#289).
5+
local function start()
6+
host.reset()
7+
host._millis_step = 0
8+
host._http_responses["/accounts/login"] = '{"accessToken":"test","expiresIn":3600}'
9+
host._http_responses["/config"] = '{"maxChargerCurrent":16}'
10+
host._http_responses["/sessions/ongoing"] = '{}'
11+
dofile("drivers/lua/easee_cloud.lua")
12+
driver_init({email="[email protected]",password="test",serial="TEST123"})
13+
end
14+
local function poll(mode, mode_at, w, stamp)
15+
local list = {{id=109,value=mode,timestamp=mode_at},{id=121,value=12.5,timestamp=mode_at}}
16+
if w ~= nil then table.insert(list, {id=120,value=w,timestamp=stamp}) end
17+
host._http_responses["/observations?ids="] = host.json_encode(list)
18+
host._millis_counter = host._millis_counter + 5000
19+
driver_poll()
20+
local rows=host._emitted.ev or {}
21+
return #rows, rows[#rows]
22+
end
23+
local function idle(row, at, why)
24+
assert(row.w==0 and row.connected==false and row.is_online,why..": not an empty, online charger")
25+
assert(row.control_power_available and row.control_power_confirmed,why..": 0 W not known")
26+
assert(row.control_power_observed_at==at,why..": wrong source time "..tostring(row.control_power_observed_at))
27+
assert(row.power_observed_at==nil,why..": power_observed_at "..tostring(row.power_observed_at))
28+
assert(row.power_max_age_s==180,why..": power_max_age_s changed")
29+
end
30+
31+
-- 1. A start with no car, and no TotalPower in the cloud.
32+
start()
33+
local count, row = poll(1,"2026-11-28T06:00:00Z")
34+
assert(count==1,"a disconnected charger emitted nothing")
35+
idle(row,"2026-11-28T06:00:00Z","start with no car")
36+
count, row = poll(1,"2026-11-28T06:00:00Z")
37+
assert(count==2,"a steady disconnected charger stopped emitting")
38+
idle(row,"2026-11-28T06:00:00Z","unchanged disconnect")
39+
-- An unreadable op_mode time leaves power unknown, as before.
40+
count, row = poll(1,"invalid")
41+
assert(count==3 and row.w==0,"no sample for a disconnected charger")
42+
assert(not row.control_power_available and not row.control_power_confirmed,
43+
"power known without a source time")
44+
45+
-- 2. Charging, then disconnect. A stale TotalPower from the session the
46+
-- cloud still holds does not leak through: no car, no power.
47+
start()
48+
count, row = poll(3,"2026-11-28T07:00:00Z",7.2,"2026-11-28T07:00:05Z")
49+
assert(count==1 and row.w==7200 and row.control_power_confirmed,"charging power missing")
50+
count, row = poll(1,"2026-11-28T08:00:00Z",7.2,"2026-11-28T07:00:05Z")
51+
assert(count==2,"the disconnect emitted nothing")
52+
idle(row,"2026-11-28T08:00:00Z","charging then disconnect")
53+
54+
-- 3. Reconnect and charge: TotalPower takes over again, with its own time,
55+
-- and older power is still refused while the car is connected.
56+
count, row = poll(3,"2026-11-28T09:00:00Z",6.9,"2026-11-28T09:00:10Z")
57+
assert(count==3 and row.w==6900 and row.connected and row.charging,"reconnected power missing")
58+
assert(row.control_power_observed_at=="2026-11-28T09:00:10Z" and row.control_power_confirmed,
59+
"reconnected power lost its source time")
60+
assert(row.power_observed_at=="2026-11-28T09:00:10Z","a new value lost power_observed_at")
61+
local n = poll(3,"2026-11-28T09:00:00Z",0,"2026-11-28T09:00:05Z")
62+
assert(n==count,"older power replaced newer power after a reconnect")
63+
n = poll(3,"2026-11-28T09:00:00Z",0,"2026-11-28T09:00:10Z")
64+
assert(n==count,"conflicting power at one source time was accepted")
65+
n, row = poll(3,"2026-11-28T09:00:00Z",6.9,"2026-11-28T09:00:10Z")
66+
assert(n==count+1 and row.w==6900 and row.power_observed_at==nil and row.control_power_confirmed,
67+
"unchanged power was not confirmed")
68+
count = n
69+
n, row = poll(3,"2026-11-28T09:00:00Z",5.1,"2026-11-28T09:01:00Z")
70+
assert(n==count+1 and row.w==5100,"newer power after a reconnect was refused")
71+
print("Easee idle power: passed")

‎drivers/tests/lua_harness/test_easee_cloud_stream.lua‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,11 @@ host._http_responses["/observations?ids="] = host.json_encode({
285285
poll(5000)
286286
ev = samples()
287287
assert(ev.connected == false and ev.w == 0 and ev.session_wh == 0, "an omitted id kept its old value")
288-
assert(ev.control_power_available == false and ev.control_power_confirmed == false,
289-
"an omitted power reading was confirmed")
288+
-- No car, no power: the 0 W is known from op_mode 1 and its time (#289),
289+
-- not from the omitted TotalPower.
290+
assert(ev.control_power_available and ev.control_power_confirmed and
291+
ev.control_power_observed_at == "2026-10-24T10:01:00Z",
292+
"a disconnected charger's 0 W is not known from op_mode: " .. tostring(ev.control_power_observed_at))
290293
rest(3, 7.2, "2026-10-24T13:00:00Z")
291294
poll(5000)
292295
rest(3, 0, "2026-10-24T10:05:00Z")
@@ -460,6 +463,19 @@ push(update(109, "1", "2026-10-24T10:01:42Z"),
460463
tick()
461464
assert(samples().w == 4000, "mode 1 did not reset stream power ordering")
462465

466+
-- A pushed disconnect is a known 0 W at its own time (#289). The next
467+
-- session's pushed power takes over again.
468+
push(update(109, "1", "2026-10-24T10:01:50Z"))
469+
tick()
470+
ev = samples()
471+
assert(ev.w == 0 and not ev.connected and ev.control_power_available and ev.control_power_confirmed and
472+
ev.control_power_observed_at == "2026-10-24T10:01:50Z", "a pushed disconnect left power unknown")
473+
push(update(109, "3", "2026-10-24T10:01:55Z"), update(120, "4.2", "2026-10-24T10:01:56Z"))
474+
tick()
475+
ev = samples()
476+
assert(ev.w == 4200 and ev.control_power_observed_at == "2026-10-24T10:01:56Z" and ev.control_power_confirmed,
477+
"pushed power after a reconnect did not take over")
478+
463479
-- A live stream with a lower clock recovers once its source time advances.
464480
setup(true)
465481
connect()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""A charger with no car reports 0 W as a known reading."""
2+
from pathlib import Path
3+
import subprocess
4+
5+
6+
def test_easee_cloud_reports_idle_power():
7+
root = Path(__file__).resolve().parents[2]
8+
result = subprocess.run(
9+
[str(root / "lua55"), "drivers/tests/lua_harness/test_easee_cloud_idle_power.lua"],
10+
cwd=root, text=True, capture_output=True, check=False,
11+
)
12+
assert result.returncode == 0, result.stdout + result.stderr

‎index.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ drivers:
186186
size_bytes: 29597
187187
sha256: "13bfc38dcd636ea5fda9ce0453f92e614d24e2efbd0f5d0fe3d56ebb499880ff"
188188
- name: "easee_cloud"
189-
version: "1.5.0"
189+
version: "1.5.1"
190190
tier: core
191191
protocol: http
192192
connectivity: cloud
193193
setup: [vendor_portal]
194194
ders: [ev]
195195
control: true
196-
size_bytes: 79950
197-
sha256: "7fa0a3af10b7f5f997df1975db7f5b0f68f2c00479cbf045073627856ff23f4b"
196+
size_bytes: 80686
197+
sha256: "f1b5c60b94dce1712a46a05e72ab1c7f6cdf30934f424e3bd848a7458d4161cd"
198198
- name: "esphome_dsmr"
199199
version: "1.0.8"
200200
tier: core

‎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.5.0"
2+
version: "1.5.1"
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: 79950
19+
size_bytes: 80686
2020
dkb_id: "easee_cloud"
21-
sha256: "7fa0a3af10b7f5f997df1975db7f5b0f68f2c00479cbf045073627856ff23f4b"
21+
sha256: "f1b5c60b94dce1712a46a05e72ab1c7f6cdf30934f424e3bd848a7458d4161cd"
2222
signature: ""
2323

2424
bytecode_sha256: ""

‎support-status.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@
422422
},
423423
{
424424
"catalog_source": true,
425-
"catalog_version": "1.5.0",
425+
"catalog_version": "1.5.1",
426426
"driver_id": "easee_cloud",
427427
"targets": {
428428
"blixt-l1": {

0 commit comments

Comments
 (0)