Repository navigation
Simulate the Polestar Data Portal's M2M API - #80
Merged
Merged
Conversation
A Polestar does not go through the Volvo Cars API: its owner reads it through the Polestar Data Portal (EU Data Act), with a credential created in the portal. Nothing in Runsten can be built or tested against it without a car, so the simulator now serves it, as it serves Volvo's. A scenario of brand polestar is served under the real base path (/eu-north-1/data-portal/m2m/): POST /token with the credential's client ID and secret, then /v1/vehicles and the domains a logger reads (battery, odometer, location, availability, target-soc), with the account in the x-client-id header. The other domains answer DATA_NOT_AVAILABLE, as for a car that does not upload them. Tokens live an hour; calls are limited per credential (10,000 a day, 100 a minute); the credential's 90 days can be switched on. The shapes follow real responses of a parked Polestar 2, published under the MIT licence by polestar-mcp and copied into testdata/polestar-data-portal, which the tests compare against. What is unknown is a named assumption: a parked car uploads its battery and availability every 10 minutes and reports itself ABANDONED after an hour; the position is the one of the end of the last trip. scenarios/polestar2.yaml is the demonstration car: a Polestar 2 of 2024, a commute, a DC charge and an AC charge. It runs alone or beside Volvo scenarios, each brand on its own API. No part of Runsten reads it yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closed
8 tasks done
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.
A Polestar is read through the Polestar Data Portal (EU Data Act), with a credential its owner creates in the portal, not through the Volvo Cars API. This adds that API to the simulator, so the Polestar source can be built and tested without a car. Nothing in Runsten reads it yet: the client, the collector and the Connection page come next.
What it does
internal/simulator/polestarapi: the M2M API under its real base path,/eu-north-1/data-portal/m2m/.POST /tokentakesclientIdandclientSecret, as JSON or a form, withoutgrant_type, and returns a token valid for one hour.GET /v1/vehiclesand the domains a logger reads:battery,odometer,location,availabilityandtarget-soc. The other domains answerDATA_NOT_AVAILABLE./v1call needs thex-client-idheader. The errors are the ones observed:VALIDATION_INVALID_PARAMETER,AUTHZ_CLIENT_ID_MISMATCHandAUTHZ_VIN_UNAUTHORIZED.brand: polestar. Each brand is served on its own API, so a Volvo and a Polestar can run together.scenarios/polestar2.yamlis the demonstration car: a Polestar 2 of 2024, with a commute, a DC charge and an AC charge.testdata/polestar-data-portal/holds real responses of a parked Polestar 2, published under the MIT licence by polestar-mcp. The tests compare the simulated shapes against them.Assumptions
What the published responses don't show is a named, configurable assumption:
SIM_POLESTAR_PARKED_UPLOAD). It reportsABANDONEDone hour after its last trip or charge./v1and of a 429 are guesses. Neither has been published.Checks
task unit-gopasses: format, lint, the tests without PostgreSQL, govulncheck and the build.commuteandpolestar2together at ×600 and read the Polestar's domains over a simulated day. Odometer, SoC and usage mode change as the scenario says.🤖 Generated with Claude Code