fix(mpc): preserve charging periods across replans - #1344
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: 80c4cb1d90
ℹ️ 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 changed { | ||
| lp.chargingPeriodSince = time.Time{} | ||
| } | ||
| observeChargingPeriod(lp, sample, m.now()) |
There was a problem hiding this comment.
Clear charging history when connection proof is lost
When Controller.tickOne receives ConnectionUnknown, it calls observeConnectionProof and returns before reaching this observation, but that path never clears chargingPeriodSince, powerAt, or the cached power. A replan during the remaining power-freshness window therefore reports InitialCharging=true, and a fresh sample after a brief reconnect can continue the pre-gap duration, even though the socket gap means uninterrupted charging was not observed. Clear the charging-period evidence when connection proof becomes unknown or changes.
AGENTS.md reference: AGENTS.md:L22-L23
Useful? React with 👍 / 👎.
Charging plans need to preserve an ongoing charge across replans and use useful periods at the charger's allowed current steps. Core now passes fresh observed charging duration to workers that advertise
charging_periods. An observation gap, missing power or disconnect clears that history. Older workers receive the existing request.The default favors periods of at least five minutes after departure energy and physical reserves, with a five-ore preference cost for an extra start. A final top-up may be shorter, and a time-limited plan may retain a short period when needed. The preference does not enter the electricity bill or override safety, manual control or the energy budget.
This pins compiled Energyplan 0.4.8 workers from private source commit
c544d89277fc6a4e013a0b09867582e39b6115c0. Only compiled workers, their existing licenses and public integration metadata are included. Paired private change: srcfl/energyplan#40, stacked on its existing pre-beta fixes.Validation:
make verifypassed on macOS with Bash 5, including bundled-worker, forecast, timeout, invalid-plan and fallback tests. One run hitSQLITE_BUSYin the existing archive-resume test; three focused reruns and the full rerun passed.main.gohas file overlap with #1003. This PR changes only loadpoint-spec creation; #1003 changes Modbus startup. Preserve those changes and recheck the base when either lands. No reviewers were requested. No merge or beta release is included.