Repository navigation
Read each vehicle through its connection's provider - #82
Merged
Merged
Conversation
The collector read the Volvo Cars API only. A connection now names its provider, and the collector reads each vehicle through it: the Volvo API as before, or a Source the binary adds, the Polestar Data Portal first, read with the owner's credential. Migration 0023: connections.provider accepts polestar, one per account beside the Volvo ID. Its credential (client ID, secret and account ID) is one JSON value sealed bound to the account and to its column; in plaintext only its last four characters and when it was set. The Portal's refusal of it is dated (credential_refused_at), and so is a vehicle no longer shared with it (vehicles.unshared_at), which listing it again clears. runsten_poll_targets gives the provider; api_calls and collector_status take the Portal's API and its kinds of failure. The export leaves the credential out. The collector describes every source the same way: its name, its endpoints with their pace in each mode and the API each call counts on, those read at once when a trip or a charge ends. The endpoints of its public types become a neutral collector.Endpoint, so the Volvo tests change by type conversions only. A Source's access token is asked for at the first call due, kept in memory until it expires, asked again once on a 401. A refused credential marks the connection, an unshared VIN the vehicle; a domain not granted is left out a day and told, one the car does not give an hour; a 429 pauses the connection. The Portal's 10,000 calls a day count per credential. internal/collector/polestarsource adapts the Polestar client, so that the collector imports neither it nor its formats. derive.Sources gives the derivation one normalizer per source, chosen by the kind's source. A Polestar's family is unknown: the normalizer tells its brand, and the catalog matches and accepts a choice among the brand's variants, which sets the family, so that the energies rest on the net capacity of the variant chosen. Tested end to end on the polestar2 scenario (three trips, a DC and an AC charge, the incremental derivation equal to a rebuild) and on a fleet of a Volvo and a Polestar; the store's credential, its checks and its isolation against PostgreSQL. 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.
Part of #52 (step 3: schema and collector by provider). It does not close the issue: the API, the Connection page and a check on a real car remain.
What changes
providerpolestar, one per account beside the Volvo ID) holds the owner's Data Portal credential, one sealed JSON value bound to the account and its column; in plaintext its last four characters and when it was set.credential_refused_at,vehicles.unshared_at, the new failure kinds (credential_refused,unshared,not_granted), thepolestarAPI inapi_calls;runsten_poll_targets()gives the provider. The export omits the credential.Source(AddSource) reads the others. For the Polestar Data Portal (internal/collector/polestarsource, the client adapted): token asked at the first call, kept until it expires, asked again once on a 401; the reactions of ADR 0038 §3; 10,000 calls a day per credential. The collector imports neitherpolestarnor its formats (depguard, archtest).Snapshot,Call,FailureandVehicleStateusecollector.Endpoint. The Volvo tests of the collector change by type conversions only: no scenario, figure or assertion changed.derive.Sources: one normalizer per source, chosen bycore.Kind.Source, inrunsten-collectorandrunsten-api.catalog.MatchBrand,RecognizeandChosenaccept the brand's variants when the family is unknown, and the choice sets it. The derivation's net capacity follows. The API (offered) is left for the next step.RUNSTEN_POLESTAR_BASE_URLinrunsten-collector.Tests
polestar2: three trips, a DC and an AC charge, the incremental derivation equal to a rebuild; a fleet of a Volvo and a Polestar under one account.task unit-goandtask integrationpass locally.Left for the next step
The API's enumeration of failure kinds, its vehicle list (which reads a Volvo connection's columns), offering the brand's variants,
sim.envand the Taskfile. The catalog has no sourced net capacity forps2-lr-single-2024, the demonstration car's variant.🤖 Generated with Claude Code