Skip to content

Polestar Data Portal as a data source: a Polestar read through its owner's M2M credentials #52

Closed

Description

@vcanuel

Runsten carries the Polestar variants in its model catalogue (ADR 0022), but no source reports a Polestar: the collector reads the Volvo Cars API only, and a Polestar is not reachable through it (a Polestar ID, not a Volvo ID). The documentation says so: "no data source reports one yet".

The official way in is the Polestar Data Portal (EU Data Act) and its M2M API: the owner creates API credentials in the portal and reads their own car's data. It is the same "bring your own credentials" model as the Volvo developer application, and what ADR 0003 and docs/research/polestar-data-portal.md §6 point to. The architecture is ready for a second source: a source produces readings (ADR 0035), the derivation is source-agnostic (ADR 0013), the OAuth refresher is generic (ADR 0014).

What is known (community integrations, Home Assistant and evcc, all 🟡; the OpenAPI spec is behind the portal's sign-in)

  • OAuth2 client credentials: App client ID, client secret (shown once), account ID in x-client-id; scopes chosen in the portal; an expired credential is recreated by hand.
  • Base URL https://pc-api.polestar.com/eu-north-1/data-portal/m2m; read only, GET: /v1/vehicles, and per VIN telemetry/{battery, location, odometer, health, …} and charging/{…}.
  • About 10 000 requests a day, 100 a minute.
  • EU/EEA only.
  • Freshness: a poll returns what the car last uploaded. Battery and climate a few minutes old, doors 36 h, health 58 h.

Open questions, to settle with a tester

Scope

  • An ADR for the Polestar source (amending ADR 0003 and ADR 0035's table): access, cadence, mapping, what it cannot give.
  • Schema: connections.provider accepts polestar, holding client credentials instead of a user's OAuth tokens.
  • A polestar package: token, list of vehicles, readings normalised to snapshots (ADR 0035); the collector polls it beside Volvo.
  • Vehicles recognised in the model catalogue (ADR 0022) from what the API returns.
  • Web: connect a Polestar by pasting its M2M credentials; show the age of the data when it is old.
  • Simulator: a Polestar scenario (ADR 0006), so that it is testable without a car.
  • Documentation: a guide to create the credentials in the Polestar Data Portal.
  • Verified on a real Polestar by an owner (help wanted: the maintainer has none).

Activity

  1. added
    enhancement
    help wanted
    on Oct 11, 2026
  2. vcanuel commented on Oct 20, 2026

    @vcanuel
    ContributorAuthor

    The simulator part is in #80 (runsten 7a50d9e): the Polestar Data Portal's M2M API served by runsten-simulator for scenarios of brand: polestar.

    • It covers the token, the vehicles list and the domains a logger reads (battery, odometer, location, availability, target-soc).
    • Its shapes are checked against real responses of a parked Polestar 2, published under MIT by polestar-mcp.
    • scenarios/polestar2.yaml is the demonstration car.
    • What is not known is a named assumption: a parked car uploads every 10 min, the position updates at the end of a trip only, and the 401 and 429 bodies are guesses.

    What it settles of the open questions: the token is POST /token with clientId/clientSecret (no grant_type), valid for 1 h. x-client-id carries the Account ID, not the OAuth client ID. /v1/vehicles gives VINs only, so the model must come from the VIN or from the user's choice.

    Remaining: the polestar client and normaliser, the schema and the collector by provider, the Connection page and the guide, and the check on a real Polestar.

  3. vcanuel commented on Oct 20, 2026

    @vcanuel
    ContributorAuthor

    Simulator merged in runsten 89e49c9 (#80). The issue stays open: the client, the collector, the Connection page and the check on a real Polestar remain.

  4. vcanuel commented on Oct 20, 2026

    @vcanuel
    ContributorAuthor

    Step 2 (the internal/polestar client), in progress on the branch polestar-client, not committed yet. A finding that changes a later step:

    • The Data Portal gives the VIN alone, and no real VIN of a Polestar 3, 4 or 5 tells which positions set the family apart (the WMI LPS is shared). The normalizer therefore reads the model year (10th character) and BatteryElectric, but leaves the family unknown: a wrong family would recognize a wrong variant.
    • The fallback "the user chooses the variant" does not hold as is: catalog.Chosen, catalog.Recognize and the API's choice of a variant all require a family read. Without a change, a Polestar would have no variant, no net capacity, and unknown energies.
    • Decided: when the family is unknown, the API offers the brand's variants, and the choice sets the family (catalog.Chosen and the API accept a vehicle of the brand without a family). To do in step 3 or 4.

    Other findings from the specification, applied in the client:

    • No 401 is described on /v1: any 401 there is taken for an expired token (assumption).
    • A 403 is "domain not granted" only on a domain fetch with the API's error body; AUTHZ_CLIENT_ID_MISMATCH (wrong account ID) is handled as a refused credential.
    • Enum values carry their type's prefix (CHARGING_STATUS_V2_…); the values of chargingStatusV2 missing from the decision's table are mapped (SMART_CHARGING_WILL_NOT_FINISH counted as charging, an assumption); CHARGING_TYPE_WIRELESS is left absent.
  5. vcanuel commented on Oct 20, 2026

    @vcanuel
    ContributorAuthor

    runsten 1479e7a: step 2, the internal/polestar client, in #81 (part of this issue, so it does not close it).

    • Client: token of the owner's credential, the VINs, the five domains read; one request per call, no retry.
    • Typed errors: credential refused, token expired, VIN no longer shared, domain not granted, DATA_NOT_AVAILABLE, 429 with Retry-After.
    • polestar.Normalizer for the source polestar, and the fingerprint without the upload's time and identifiers.
    • Tested against the real responses and the simulator.

    Remaining: step 3 (migration, collector by provider, derive with one normalizer per source, the brand's variants offered when the family is unknown), step 4 (API, Connection page, documentation), step 5 (a real car).

  6. vcanuel commented on Oct 20, 2026

    @vcanuel
    ContributorAuthor

    Step 2 merged in runsten 0dbb0bb (#81): the internal/polestar client, errors and normalizer. The issue stays open for steps 3 to 5.

  7. vcanuel commented on Oct 20, 2026

    @vcanuel
    ContributorAuthor

    Step 3 (schema and collector by provider), in progress on the branch polestar-collector, not committed yet. Decisions taken while working:

    • The collector's public types Snapshot.Endpoint, Call.Endpoint, Failure.Endpoint and VehicleState.Next move to a neutral collector.Endpoint type: a Polestar domain cannot honestly be a volvo.Endpoint. The Volvo tests of the collector change by type conversions only (Endpoint(volvo.Location), volvo.Endpoint(c.Endpoint).API()): no scenario, figure or assertion changed, and they pass.
    • The Polestar adapter of the collector's Source is its own package, internal/collector/polestarsource, so that the derivation's end-to-end tests run the real one; the collector itself does not import polestar.
    • A 429 and a token rejected twice pause the Polestar connection, not the account (Volvo is unchanged).

    Left for step 4: the API's enumeration of failure kinds does not know the three new ones (credential_refused, unshared, not_granted); the API's vehicle list reads a Volvo connection's columns; offering the brand's variants (offered). The catalog has no sourced net capacity for the Polestar 2 Long Range Single Motor 2024 (ps2-lr-single-2024, the demonstration car's): chosen, it gives no energies yet.

  8. vcanuel commented on Oct 20, 2026

    @vcanuel
    ContributorAuthor

    runsten ba8aa22: step 3, the schema and the collector by provider, in #82 (part of this issue, so it does not close it).

    • Migration 0023: a Polestar connection holds the owner's credential, sealed; its refusal and an unshared VIN are dated; runsten_poll_targets() gives the provider.
    • The collector reads each vehicle through its provider; the Polestar Data Portal is a Source (internal/collector/polestarsource): token kept in memory, the reactions of the decision's table, 10,000 calls a day per credential.
    • derive.Sources: one normalizer per source. A Polestar's brand stands in for its unknown family: a variant of the brand chosen sets it, and gives the energies their net capacity.
    • Tested end to end on polestar2 (three trips, a DC and an AC charge, incremental equal to rebuild) and on a fleet of a Volvo and a Polestar.

    Remaining: step 4 (API, Connection page, documentation, sim.env and the Taskfile, the API's failure kinds and vehicle list, the brand's variants offered), step 5 (a real car).

  9. vcanuel commented on Oct 20, 2026

    @vcanuel
    ContributorAuthor

    Step 3 merged in runsten f2c9dda (#82): the schema and the collector by provider. The issue stays open for steps 4 and 5.

  10. vcanuel commented on Oct 20, 2026

    @vcanuel
    ContributorAuthor

    Step 4 (API, Connection page, documentation), in progress on the branch polestar-connection, not committed yet. Decisions taken while working:

    • PUT /connection/polestar checks the credential first (a token, then the VINs). Not stored when refused (400 credential_refused), when it reads no vehicle (409 no_vehicle: the listing is the only way its vehicles come in), or when the Data Portal does not answer (502 source_unavailable). The vehicle cap counts every vehicle of the account (409 too_many_vehicles).
    • DELETE /connection/polestar erases the credential only: the connection, its vehicles and their history stay, no longer read until another credential. This needs a small migration (0024): a Polestar connection may have no credential, since deleting the row would delete its vehicles.
    • A vehicle's connection names its provider; a Polestar's has credential (set, refused, missing) and a null api_key. unshared_at comes with the vehicle; the failure kinds know credential_refused, unshared, not_granted.
    • A Polestar without a family is offered the brand's variants; the one chosen sets its family.

    Found, left for later: the Volvo ID connection counts only its own vehicles against the cap, so a Volvo can still be added to an account that already has a Polestar at the cap. The Polestar 2 Long Range Single Motor 2024 still has no sourced net capacity.

  11. vcanuel commented on Oct 20, 2026

    @vcanuel
    ContributorAuthor

    runsten 4f3b053, 0b96855, 9f6e1f0, 93d1237: step 4, in #83 (part of this issue, so it does not close it).

    • API: the Polestar credential checked (a token, its VINs) then stored, or removed with its vehicles kept (migration 0024); a vehicle's connection tells its provider and its credential's state; the brand's variants offered to a Polestar without a family; the Volvo Data Portal's files refused for a Polestar.
    • Connection page: the Polestar section (the three values, the guide, the 90 days' reminder), each vehicle's new states, the car's last measure on the vehicle page beyond 30 minutes.
    • Development: task connect-sim gives the simulator's credential (tilt up -- --scenario=commute,polestar2).
    • Documentation: the Polestar guide, in beta.

    Remaining: step 5 (a real car); the sourced net capacity of the Polestar 2 Long Range Single Motor 2024; the Volvo ID's vehicle cap counting the account's other vehicles.

  12. vcanuel commented on Oct 21, 2026

    @vcanuel
    ContributorAuthor

    runsten a124424 (in #83): vite updated to 8.3.4, whose 8.3.1 failed the CI's dependency audit (a launch-editor advisory, already on main). Nothing else changes.

  13. vcanuel commented on Oct 21, 2026

    @vcanuel
    ContributorAuthor

    Step 4 merged in runsten 0845219 (#83), with the vite fix a124424: the API and the Connection page for a Polestar credential, and the Polestar guide (beta). The issue stays open.

    Remaining:

    • step 5: the check on a real Polestar, by a tester (the decision's list: models that answer, the upload cadence while driving, an AC and a DC charge, the bodies of a 429 and a 401);
    • the sourced net capacity of the Polestar 2 Long Range Single Motor 2024;
    • the Volvo ID's vehicle cap counting the account's other vehicles.
  14. vcanuel commented on Oct 21, 2026

    @vcanuel
    ContributorAuthor

    Step 5 changes (decided 2026-10-21): no recruited tester. Polestar ships in beta, as the guide already says, and the check of the decision is made on the first users' cars, through the logs. The collector will log, with neither VIN nor credential:

    • each new upload of the car per domain: the car's time, its age when read, the gap since the previous upload, the mode (parked, driving, charging): the upload cadence while driving;
    • the fields each domain gives (keys only), when they change, with the model year;
    • a 401 on /v1 (status, code, message, the token's age), and a 429 (code, message, Retry-After, rate limit headers, the connection's calls of the last minute and day);
    • the API's error messages with any VIN masked.

    Also on the branch: the Volvo ID counts every vehicle of the account against the cap; the Polestar 2 Long Range Single Motor 2024 has its net capacity (79 kWh, two secondary sources agreeing).

  15. vcanuel commented on Oct 21, 2026

    @vcanuel
    ContributorAuthor

    runsten dc72170, 8f1b1a8, dacb15f, f66d9b5, in #85 (part of this issue, so it does not close it).

    • Go 1.27.3: govulncheck passes again.
    • The Volvo ID counts every vehicle of the account against the cap, a VIN already there once.
    • The Polestar 2 Long Range Single Motor 2024 has its net capacity: 79 kWh.
    • The collector logs the Data Portal's behavior on real cars (uploads per domain and their cadence, fields, 401, 429), without VIN nor value.

    Remaining: step 5, the check on the first users' cars in beta, by these logs.

  16. vcanuel commented on Oct 21, 2026

    @vcanuel
    ContributorAuthor

    Merged in runsten 66e29db (#85): Go 1.27.3, the vehicle cap counting every vehicle of the account, the net capacity of the Polestar 2 Long Range Single Motor 2024, and the collector's logs measuring the Data Portal on real cars.

    Remains: step 5, checking the beta on real cars through these logs. The issue stays open.

  17. vcanuel commented on Oct 22, 2026

    @vcanuel
    ContributorAuthor

    Merged in runsten 3b40c7f (#86, part of this issue, so it does not close it): d440d1a, 79fa2da, d15e8f1.

    • The Polestar credential and the API key are held back (403 not_admitted) until the account is admitted, as the Volvo sign-in already was.
    • The Polestar connection carries a Beta chip.
    • The vehicle settings choose the model first, then its variant: the variants of the car's model year first, the others folded under "Other model years". The variant options carry their family in the API.

    Remains: step 5, the beta in production and its check on real cars through the collector's logs.

  18. vcanuel commented on Oct 22, 2026

    @vcanuel
    ContributorAuthor

    runsten c7d8c21, in #87 (part of this issue, so it does not close it).

    • The docs home, the guide home and the README speak of your car and its manufacturer, and list the supported brands in one place: Volvo through the Volvo Cars API, Polestar through its Data Portal (beta).
    • The sidebar groups the Volvo and Polestar pages under "Connecting your car".
    • The installation names both brands; what is Volvo's own (the instance's Volvo application, the Volvo key, the Volvo ID, the Volvo Data Portal's files) stays so.

    Remains: step 5, the beta in production and its check on real cars through the collector's logs.

  19. vcanuel commented on Oct 22, 2026

    @vcanuel
    ContributorAuthor

    Merged in runsten f44fca3 (#87, part of this issue, so it does not close it): the documentation names no brand where it speaks of the car; the supported cars are listed in one place (the docs home and the guide home), and the sidebar has a "Connecting your car" section with Volvo and Polestar (beta).

    Remains: step 5, the beta in production and its check on real cars through the collector's logs.

  20. vcanuel commented on Oct 22, 2026

    @vcanuel
    ContributorAuthor

    #88 rewords the confirmation of a saved credential without naming the collector.

  21. vcanuel commented on Oct 22, 2026

    @vcanuel
    ContributorAuthor

    Merged in runsten bcea4c6 (#88): the confirmation of a saved credential no longer names the collector.

  22. vcanuel commented on Oct 25, 2026

    @vcanuel
    ContributorAuthor

    First report from a real Polestar 3: a self-hoster connected it through the Data Portal (built from main, before v0.9.0) and the car shows up. Not yet known: how often it sends its readings while driving, asked to them. Their feedback is in #99 to #103.

  23. vcanuel commented on Oct 25, 2026

    @vcanuel
    ContributorAuthor

    The self-hoster's Polestar 3: a first drive of 2 × 1 km came out as a reconstructed trip (no route). Too short to tell how often the car uploads while driving: a longer drive followed by a charge is to come, and they will report. They also offer the Data Portal's documentation as they copied it, which says that some calls are available to some models only.

  24. added
    brand:polestar
    on Nov 6, 2026
  25. added theissue type on Nov 6, 2026
  26. vcanuel commented on Nov 9, 2026

    @vcanuel
    ContributorAuthor

    Done, released in v0.9.0: the Polestar source read through the owner's Data Portal credentials, and checked on a self-hoster's Polestar 3 (their feedback in #99 to #103). How often the car uploads while driving, and the paces that follow from it, are followed in #152.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    brand:polestarenhancementhelp wanted

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions