Skip to content

Read a Polestar's availability as soon as the car wakes up - #380

Merged
vcanuel merged 3 commits into
mainfrom
polestar-paces
Nov 12, 2026
Merged

vcanuel merged 3 commits into
mainfrom
polestar-paces

Conversation

@vcanuel

@vcanuel vcanuel commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

A Polestar's drive is now seen within a minute or two of the car waking up, instead of up to a parked interval (10 minutes) later. A drive shorter than that interval was missed, its trip only reconstructed from the odometer.

The Data Portal's car uploads about every minute while it drives or charges, which the 1-minute pace already matches, and parked only while it is awake. The availability, the only domain that tells a drive, was read every parked interval, while the battery is read every minute parked (#373): a new battery upload is the car waking up, perhaps to drive.

Changes

  • Collector: EndpointSpec.Wakes. Parked, a new upload of an endpoint brings the endpoints it wakes forward, read in the same pass when the budget allows. Not for the first upload read after a start, nor for an account the read policy keeps at a pace of its own.
  • Polestar: the battery wakes the availability, a call for each new upload of a parked car, far fewer than reading the availability every minute (about 1,300 calls a day per car). When calls run short, the battery falls back to the parked pace, and the availability with it.
  • Docs: AGENTS.md and the Polestar guide describe the new pace.

Screenshots

None: the collector only, nothing changes on screen.

Tests

  • task unit-go (with TestSourceWakes, which fails without the change) and task lint: pass.
  • The web unit tests and the e2e did not run: no front-end change.

Closes #152

🤖 Generated with Claude Code

Parked, the availability, the only domain that tells a drive, was read every
10 minutes: a drive's start was known within 7 minutes (median), and drives
shorter than that were missed. Measured on real cars, the car uploads every
60 s while driving or charging, and only while awake when parked (about 15
uploads a day). A new battery upload, parked, now brings the availability
forward to the same pass (EndpointSpec.Wakes), for about 15 calls a day.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The collector now advances configured endpoint reads when a watched endpoint reports a newer upload, subject to parked state and account pacing. Polestar configures battery uploads to wake availability reads. Tests and documentation cover the parked polling behavior.

Changes: Polestar parked wake scheduling

Layer / File(s) Summary
Wake contract and Polestar configuration
internal/collector/source.go, internal/collector/polestarsource/source.go
EndpointSpec adds Wakes. Polestar configures battery uploads to wake availability reads and documents observed polling behavior.
Advance reads after new uploads
internal/collector/collector.go
When a watched endpoint reports a newer upload and Every is zero, the collector advances the declared wake endpoints’ read times to now if the vehicle is parked.
Test and describe parked polling
internal/collector/source_test.go, AGENTS.md, documentation/guide/polestar.md
The test checks availability polling before and after a new battery upload. The documentation describes the immediate read while parked.

Possibly related PRs

  • runsten-app/runsten#373: It changes the parked read pace for the same Polestar battery endpoint, while this PR keeps the parked pace and uses battery uploads to wake availability reads.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to f500f

This change reads Polestar availability as soon as the car wakes, so drives become visible sooner while staying within the call budget. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title describes the main change: while parked, the Polestar availability endpoint is read as soon as the car wakes, via the new wake-up path where a battery upload brings availability forward. The…
Linked Issues check Passed Issue #152 has one open coding criterion: shorten the read paces within the 10,000 calls/day limit. The parked delay was up to 10 minutes before a drive start was seen. The PR adds a wake path. In int…
Out of Scope Changes check Passed All changes relate to the linked issue #152 objective. The collector change (internal/collector/collector.go, internal/collector/source.go) adds the Wakes field and the wake path. The Polestar source …
Description check Passed The description covers the change and its reason. It explains the problem: a Polestar drive is seen up to a 10-minute parked interval late, and short drives are missed. It lists the changes across the…
Full details: Title check

Explanation

The title describes the main change: while parked, the Polestar availability endpoint is read as soon as the car wakes, via the new wake-up path where a battery upload brings availability forward. The title is specific to the change and matches the PR objectives. It is not in the imperative form the title requirements ask for, since it begins with "Read" and uses a possessive "Polestar's". The wording is still clear and on topic.

Full details: Linked Issues check

Explanation

Issue #152 has one open coding criterion: shorten the read paces within the 10,000 calls/day limit. The parked delay was up to 10 minutes before a drive start was seen. The PR adds a wake path. In internal/collector/collector.go, Collector.read calls vehicleState.wake when a new upload of an endpoint is seen. wake advances the next read of each endpoint listed in EndpointSpec.Wakes to now, but only while the vehicle is parked and the account has no own pace (Every == 0). In internal/collector/polestarsource/source.go, the Polestar battery endpoint wakes availability. A battery upload therefore brings the availability read forward, so a drive start is seen about one to two minutes after the car wakes. The PR author reports about 15 extra calls per car per day. TestSourceWakes in internal/collector/source_test.go checks that the first post-wake availability read occurs within one minute. The driving pace is already 1 minute, as #152 states. The measurement criterion in #152 is already checked. Limitation: the configured parked pace for availability is still 10 minutes. The reduction comes from the wake path, not from a changed pace value. The call-budget figures are the author's estimates. This assessment did not re-measure them.

Full details: Out of Scope Changes check

Explanation

All changes relate to the linked issue #152 objective. The collector change (internal/collector/collector.go, internal/collector/source.go) adds the Wakes field and the wake path. The Polestar source change (internal/collector/polestarsource/source.go) configures battery to wake availability and removes the Watch setting from the shared telemetry helper. The test change (internal/collector/source_test.go) adds TestSourceWakes and a fakeSource wakes setting that support the wake behavior. The documentation changes (AGENTS.md, documentation/guide/polestar.md) describe the new read pace. No unrelated files or behavior changes appear in the reviewed summary.

Full details: Description check

Explanation

The description covers the change and its reason. It explains the problem: a Polestar drive is seen up to a 10-minute parked interval late, and short drives are missed. It lists the changes across the collector, the Polestar source, and the docs. It gives the call budget impact (about 15 extra availability calls per car per day versus about 1,300 for per-minute reads). It reports test runs (task unit-go with TestSourceWakes, and task lint) and explains why the web tests and e2e did not run. It states that no screenshots apply. It closes issue #152. The template asks for a checklist, and the description does not tick or address the API diff, the multi-language text, or the fixture-privacy items. Those items are mostly not applicable here, but the author does not state that. The description is mostly complete, so the check passes.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f036fca and f500fe7.

Files selected for processing: 6

  • AGENTS.md
  • documentation/guide/polestar.md
  • internal/collector/collector.go
  • internal/collector/polestarsource/source.go
  • internal/collector/source.go
  • internal/collector/source_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@vcanuel
vcanuel merged commit 1395528 into main Nov 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Polestar trips: end a drive on fresh readings, and read more often

1 participant