Repository navigation
feat(easee): driver-side improvements from 1Φ↔3Φ hardware test - #207
Merged
Merged
Conversation
Five field-tested improvements to the Easee driver, all driver-only —
no Go side changes. Derived from the 1Φ↔3Φ ramp test we ran on a
real charger:
* **Default MinPhaseHoldS 60 → 90 s.** Field-measured: a phaseMode
flip + EV ramp to steady state takes 60–90 s. A 60 s hold could
let a flap-prone wantW trigger another transition mid-ramp; 90 s
gives one full ramp cycle before another flip.
* **Optional `max_charger_current` config.** When set, driver
writes it to the charger's static maxChargerCurrent at init.
After every phaseMode change Easee resets dynamicChargerCurrent
to maxChargerCurrent — clamping that ceiling bounds the
post-transition window. Defaults unset (no-op) for backward
compat; sites with maxChargerCurrent oversized vs the per-phase
fuse should set this.
* **Firmware-settings probe at init.** Driver fetches the charger's
own settings (phaseMode, maxChargerCurrent) and logs them. We
spent 30 minutes debugging silently-rejected phaseMode=1 writes
in the field because the box was firmware-locked to phaseMode=3
and Easee's API just returns 200 OK with no effect. Logging the
firmware-side phaseMode at init makes that case immediately
obvious.
* **Forced `dynamicChargerCurrent` re-assert on next poll.** After a
successful phaseMode change, schedules one re-write of
last_amps_set ~5 s later (next driver_poll). Defends against
Easee's post-transition reset of dynamicChargerCurrent → 16 A
without waiting for the controller's 5 s tick. Idempotent if the
controller's tick beats us to it.
* **Emit `actual_amps_per_phase`.** Derived from totalPower and
per-phase voltage in the ev telemetry. Operators wanting "is the
EV actually drawing what we asked for?" can now compare
actual_amps_per_phase against max_a (which only echoes our last
write and lags ~5–10 s on the Easee cloud).
No tests added — the project has no Lua test harness yet, and these
are observability + post-transition timing tweaks best verified
against real hardware. Validated via gopher-lua syntax check + the
ramp test described in PR #206's session log.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…(POST-only) Easee's API isn't symmetric — /settings only accepts POST writes, GET there returns 405 Method Not Allowed. The static config (phaseMode, maxChargerCurrent, …) is exposed at /config for reads. Caught at init the first time the driver-improvements PR ran on hardware: 'Easee: could not read firmware settings: HTTP 405'. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Easee Cloud Lua driver (drivers/easee_cloud.lua) with operational improvements discovered during live 1Φ↔3Φ ramp testing, focused on stabilizing phase switching behavior and improving operator diagnostics.
Changes:
- Increase the default minimum phase-hold hysteresis from 60s to 90s to reduce mid-ramp flapping.
- Add firmware settings probing at init plus an optional
max_charger_currentclamp (via settings API) to bound the post-phase-change reset window. - Add a one-shot “re-assert dynamicChargerCurrent” behavior after phase changes and emit a new diagnostic telemetry field (
actual_amps_per_phase).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+312
to
+315
| -- maxChargerCurrent, etc.) so the driver can detect a firmware lock | ||
| -- that would silently ignore our phaseMode writes. Easee's API uses | ||
| -- `/config` for reads and `/settings` for writes — they're not | ||
| -- symmetric. Returns the decoded table or nil + err string. |
Comment on lines
+455
to
+457
| local actual_amps_per_phase = 0 | ||
| local v_obs = obs[OBS_VOLTAGE] | ||
| if power_w > 0 and phases > 0 then |
Comment on lines
+489
to
+493
| else | ||
| host.log("warn", "Easee: dynamicChargerCurrent re-assert failed: " .. | ||
| redact_http_err(werr)) | ||
| end | ||
| pending_amp_resend = false |
Comment on lines
548
to
574
| @@ -445,6 +553,7 @@ function driver_command(action, power_w, cmd) | |||
| phases = requested_phases | |||
| last_sent_phases = requested_phases | |||
| last_phase_change_ms = now_ms | |||
| phase_changed = true | |||
| host.log("info", "Easee: phaseMode → " .. tostring(requested_phases)) | |||
| else | |||
| host.log("warn", "Easee: phaseMode write failed; skipping current write to avoid overcurrent on stale phase: " .. | |||
| @@ -463,6 +572,18 @@ function driver_command(action, power_w, cmd) | |||
| local _, err = host.http_post( | |||
| BASE_URL .. "/chargers/" .. charger_serial .. "/settings", | |||
| body, auth_headers()) | |||
Comment on lines
472
to
+475
| cable_locked = cable_locked, | ||
| max_a = dyn_current, -- current dynamic limit (A) | ||
| phases = phases, -- from config.phases; default 3 | ||
| max_a = dyn_current, -- last-set dynamic limit (echoes our write, may lag) | ||
| actual_amps_per_phase = actual_amps_per_phase, -- live per-phase A derived from totalPower | ||
| phases = phases, -- our committed phase count (1 or 3) |
| local function read_settings(serial) | ||
| local resp, err = host.http_get(BASE_URL .. "/chargers/" .. serial .. "/config", auth_headers()) | ||
| if err then return nil, redact_http_err(err) end | ||
| return host.json_decode(resp), nil |
Six findings, all valid:
* easee_cloud.lua:315 — read_settings doc claimed "detect a
firmware lock" but the implementation only logs settings. Active
detection (compare requested phaseMode after a write / periodic
re-read) is a follow-up; reword the comment to match what the
driver actually does (diagnostic logging at init).
* easee_cloud.lua:319 — host.json_decode failure was treated as
"no error", silently skipping the settings log. Now returns
`nil, "decode failed (non-JSON response)"` so init logs a clear
warning distinct from HTTP errors.
* easee_cloud.lua:457 — actual_amps_per_phase used the global
`phases` which can be 2 when config.phases=2 is misconfigured,
or before the first successful phaseMode write. Dividing by 2
yields a non-physical "per-phase" value. Now emitted only when
phases ∈ {1, 3}; otherwise nil so the field is omitted from the
payload rather than misleading.
* easee_cloud.lua:493 — pending_amp_resend was cleared
unconditionally even on POST failure, so a transient network
error left the charger pinned at maxChargerCurrent. Now cleared
only on successful re-write; failures retain the flag and
retry on the next poll.
* easee_cloud.lua:574 — driver_command's two raw http_post calls
to /settings now route through the existing write_setting()
helper for consistent encoding/auth/error handling.
* api.go:383 — actual_amps_per_phase from the ev emit is now
surfaced through /api/status as ev_actual_amps_per_phase. PR
description said this would appear without Go changes; that
was wrong. Added the field to the EV-status decode struct so
the operator can compare requested vs actual amps directly.
Build green; gopher-lua syntax check OK; full test suite green
incl. test/e2e.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Collaborator
Author
2 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Five driver-only improvements to
drivers/easee_cloud.luaderived from the live ramp test we ran in PR #206's session. No Go-side changes; the Lua file is hot-reloadable on a running Pi.What we observed
The hardware test (1Φ × 6/7/8/9 A, then 3Φ × 6/7/8/9/10 A, 60 s observation each) revealed:
phaseModePOST → cloud acceptsphaseModePOST → observation API reflectsdynamicChargerCurrentreset tomaxChargerCurrentafter phaseMode changephaseModewrites when firmware is lockedFive fixes
MinPhaseHoldS60 → 90 s. A 60 s hold could let a flap-pronewantWtrigger another transition mid-ramp.max_charger_currentconfig field. Clamps the charger's staticmaxChargerCurrentat init via the settings API, bounding the post-phaseMode-reset window.phaseModeandmaxChargerCurrentas the charger itself has them committed. Saves 30 minutes of "why is my phaseMode write being ignored?" debugging next time.dynamicChargerCurrentre-assert on nextdriver_poll. After a successful phaseMode change, schedules a re-write ~5 s later to overcome Easee's post-transition reset without waiting for the controller's 5 s tick.actual_amps_per_phasein the ev telemetry. Derived fromtotalPower / per-phase voltage / phases. Operators can now compare "what we asked for" (max_a, which echoes our last write with ~5-10 s lag) against "what the EV is actually drawing" (actual_amps_per_phase, live).What is NOT in this PR
Test plan
go test ./...green (no Go changes, no regressions).Easee: firmware settings — phaseMode=…, maxChargerCurrent=…appears at init.Easee: re-asserted dynamicChargerCurrent=N A after phaseMode resetappears within ~5 s of thephaseMode → 3log line.actual_amps_per_phasein /api/status drivers easee-cloud matches the requested amps within charger losses.🤖 Generated with Claude Code