Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="core/loadpoint_vehicle.go" line_range="261-264" />
<code_context>
+ }
+
+ if vehicle, ok := api.Cap[api.Resurrector](lp.GetVehicle()); ok {
+ lp.socWakeUpDone = true
+
+ lp.log.DEBUG.Println("soc unknown: waking up vehicle")
+ if err := vehicle.WakeUp(); err != nil {
+ lp.log.ERROR.Printf("wake-up vehicle: %v", err)
+ }
</code_context>
<issue_to_address>
**Wake failures suppress retries**
When `vehicle.WakeUp()` returns an error, `wakeUpVehicleForSoc` sets `socWakeUpDone` before calling `WakeUp`, so later asleep reads skip another attempt and the SoC remains unavailable until reconnect.
Set `socWakeUpDone` only after `WakeUp` succeeds, or clear it when the call fails.
</issue_to_address>
### Comment 2
<location path="core/loadpoint.go" line_range="2398" />
<code_context>
- if !errors.Is(socErr, api.ErrMustRetry) {
+ // arrives, instead of waiting for the next interval. Same for sleeping
+ // vehicles while the SoC is unknown, e.g. after a restart.
+ asleepSocUnknown := errors.Is(socErr, api.ErrAsleep) && lp.vehicleSoc == 0
+ if asleepSocUnknown {
+ lp.wakeUpVehicleForSoc()
</code_context>
<issue_to_address>
**Estimated SOC stops the retry**
When a sampled estimator has a zero baseline and charged energy increases while the vehicle API returns `ErrAsleep`, a sampled estimator can raise `lp.vehicleSoc` above zero after the asleep read fails; on the next poll, `asleepSocUnknown` is false and `socUpdated` is set despite no successful vehicle read, so charging-only polling stops before the actual SOC arrives.
Keep the retry state tied to a successful API SoC read rather than the estimator-adjusted `lp.vehicleSoc`.
</issue_to_address>
### Comment 3
<location path="core/loadpoint_vehicle.go" line_range="260-261" />
<code_context>
+ return
+ }
+
+ if vehicle, ok := api.Cap[api.Resurrector](lp.GetVehicle()); ok {
+ lp.socWakeUpDone = true
+
+ lp.log.DEBUG.Println("soc unknown: waking up vehicle")
</code_context>
<issue_to_address>
**Charger-only wake-up is skipped**
When the vehicle has no `api.Resurrector` capability but its charger can wake it, `wakeUpVehicleForSoc` only checks the active vehicle for `api.Resurrector`, so vehicles that can be woken through a charger’s CP interrupt are not woken and their unknown SoC remains unavailable until another event causes a read.
Try the charger’s `api.Resurrector` as a fallback when the vehicle itself cannot wake the car.
</issue_to_address>
### Comment 4
<location path="core/loadpoint.go" line_range="2401" />
<code_context>
+ asleepSocUnknown := errors.Is(socErr, api.ErrAsleep) && lp.vehicleSoc == 0
+ if asleepSocUnknown {
+ lp.wakeUpVehicleForSoc()
+ }
+ if !errors.Is(socErr, api.ErrMustRetry) && !asleepSocUnknown {
lp.socUpdated = lp.clock.Now()
</code_context>
<issue_to_address>
**Gate wake-up on plan**
The issue asks to wake only when a SoC-based plan is set, and not to wake without one so a plan added later can trigger the wake. This call wakes whenever the SoC is unknown and the vehicle reports ErrAsleep, regardless of plan state, and can consume the per-connection wake-up before a plan is added.
</issue_to_address>
### Comment 5
<location path="core/loadpoint.go" line_range="189" />
<code_context>
pvTimer time.Time // PV enabled/disable timer
phaseTimer time.Time // 1p3p switch timer
wakeUpTimer *Timer // Vehicle wake-up timeout
+ socWakeUpDone bool // Vehicle was woken up once to read an unknown soc
// charge progress
</code_context>
<issue_to_address>
**SoC terminology is lowercase**
The new field comment, function comment, and debug log spell the acronym as `soc`, contrary to the repository's required `SoC` capitalization.
Use `SoC` in the added comments and debug log.
Also at `core/loadpoint_vehicle.go:254`, `core/loadpoint_vehicle.go:263`.
</issue_to_address>Linked issues
#35770 Wake the vehicle once to read the SoC when it is unknown and a plan is set · 5 of 6 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Wake once per connection only when the SoC is unknown, the vehicle is asleep, and a SoC-based plan is set; do not wake without a plan, so a plan added later triggers a wake on the next failed read. | 🟡 Partly met | The change handles unknown SoC and ErrAsleep and limits wake-ups per connection, but calls the wake helper without checking for a plan; an early wake without a plan can also consume the per-connection flag before a plan is added. |
| 2 | Do not wake vehicles with api.WakeUpDisabled. | ✅ Met | The wake helper returns when the vehicle has this feature. |
| 3 | Keep socUpdated at zero on ErrAsleep while vehicleSoc is zero, and continue polling until a SoC arrives. | ✅ Met | The ErrAsleep/unknown-SoC case is excluded from the socUpdated assignment. |
| 4 | Do not change behavior when the SoC is known. | ✅ Met | The special handling applies only when vehicleSoc is zero. |
| 5 | Stop polling at the first successful SoC read. | ✅ Met | A successful read updates socUpdated, after which vehicleSocPollAllowed no longer allows connected-mode polling. |
| 6 | If wake-up fails, continue reads without further wake-ups. | ✅ Met | The helper sets socWakeUpDone before calling WakeUp, while the ErrAsleep/unknown-SoC case keeps polling enabled. |
rakete1
force-pushed
the
fix/soc-retry-asleep
branch
from
November 4, 2026 18:51
96dc973 to
33308d3
Compare
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.
Fixes #35770
Wakes a sleeping vehicle once per connection if its SoC is unknown, so that the SoC is available again after a restart and SoC-based plans no longer start from 0%. As agreed in the issue, this applies on every start, not only with a plan.
ErrMustRetryapi.WakeUpDisabledVerified on a Tesla with go-e on top of 0.318.2: with no plan set, evcc woke the car from offline on restart and read the SoC 30 s later.
🤖 Generated with Claude Code