fix(easee): retain session identity across pauses and preserve source times - #116
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e8b48f604
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if type(mode) ~= "number" or mode < 0 or mode > 6 or mode % 1 ~= 0 then | ||
| return nil, "missing charger state" | ||
| end | ||
| if mode == 0 then return nil, "charger offline; connection unknown" end |
There was a problem hiding this comment.
Invalidate session proof while suppressing offline samples
When session A has already been validated and the charger goes offline, this early return prevents current_session_id(0) from clearing that proof. If A is unplugged or replaced during the outage and Easee initially reconnects in mode 2/6 while observation 223 still contains historical A—as the surrounding logic explicitly allows—validated_session_id == identity emits A without revalidation, causing Core to restore the previous vehicle's battery estimate. Suppress the offline telemetry, but invalidate the cached proof before returning so reconnect cannot present stale session identity as current.
AGENTS.md reference: AGENTS.md:L77-L77
Useful? React with 👍 / 👎.
| -- A pause is still an open session. Ask the ongoing-session endpoint | ||
| -- before restoring its identity; observation 223 alone may be historical. |
There was a problem hiding this comment.
Preserve lookup quota until charging can verify the session
Because modes 2, 4, and 6 now enter this lookup path unconditionally, a driver that boots while paused with temporarily mismatched observation and /sessions/ongoing data retries once per minute and consumes all ten hourly requests in about nine minutes. If charging then starts after the tenth attempt, the existing #recent >= 10 guard prevents session verification for roughly another 50 minutes, so Core receives no session identity for most or all of that charge. Spread retries across the hour or reserve an attempt for a transition to active charging.
Useful? React with 👍 / 👎.
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
8e8b48f to
2086b64
Compare
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Easee keeps the same plugged-in session while FTW or the car pauses charging, even when its ongoing-session response contains sessionEnd. Treating that field as an unplug erased the battery estimate after restart. Keep the canonical session ID when the observation and ongoing session agree, and reject the old ID after an observed unplug.
Carry the vendor timestamps for power and session energy. Declare a bounded 180-second power reporting window so Core can estimate progress between source updates without refreshing their timestamps. Keep the independent driver watchdog unchanged.
Paired Core integration: srcfl/ftw#1240 (pins this driver commit). Addresses srcfl/ftw#1235 and srcfl/ftw#1236.
Validation: make check passed (4,404 passed, 1,069 skipped), including session-proof, paused-session, stale-data and unplug cases. A physical Easee charge ran at about 7.1 kW, reached the configured target estimate and stopped at measured 0 W. The same verified session retained its estimate across Core restarts. This is a local candidate; the signed channel has not been released.
Review follow-up: invalidate cached proof across offline or unreadable observations, then verify it again after reconnect. Spread failed lookups across the hour so paused retries leave capacity for charging. New regressions cover both cases; full make check and Core integration tests pass. Tracked in srcfl/ftw#1241 and srcfl/ftw#1242.