Repository navigation
Let a Tesla Fleet API connection exist, read by an extension's source - #248
Conversation
A Tesla read through the Fleet API, with an application the instance's operator registered at Tesla, is a provider of its own, tesla_fleet: the Owner API source refreshes its tokens with the Owner API's client, which would refuse them. The core reads none of its vehicles itself; a source an extension registers does (collector.AddSource). Its refresh token is kept as the Owner API's (connections.credential, sealed), one per account beside it, through SetTeslaFleetToken and its siblings, which share the Owner API's code. A car moves from one connection to the other with its history. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both binaries build the derivation's normalizers before registering their extensions: a source an extension adds to the collector could not be derived. extensionNormalizers, beside registerExtensions, adds none in the public build; a downstream build's twin adds its own. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The API's provider enum gains tesla_fleet, read with its credential as the Owner API's, and the TeslaMate import takes its cars. The connection page shows them in the Tesla tab, their state and notices worded for a sign-in with Tesla rather than a refresh token, in the three languages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With source.tesla off, the Tesla tab told every Tesla it was no longer read, those of the Fleet API too, which another source reads whatever the flag. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
The rebuild command recomputed every vehicle's events: one of a provider only an extension reads, rebuilt by a build without it, would have lost its trips and charges, its readings left unread. It is now skipped, and logged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The flag source.tesla stops the Owner API only: a Tesla of another source is still read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A downstream build adds its normalizers: the test that no extension's provider is read holds for the public build only (!premium). Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Tesla read through Tesla's Fleet API, with an application the instance's operator registered at Tesla, becomes a connection of its own:
tesla_fleet, beside the Owner API'stesla. The core reads none of its vehicles itself; a source an extension registers does (collector.AddSource, already exposed). The core only lets such a connection exist, shows its cars, and derives their readings.Changes
0035_tesla_fleet.sqladdstesla_fleetto the checks ofconnectionsandapi_calls.SetTeslaFleetToken,TeslaFleetToken,RotateTeslaFleetToken,TeslaFleetConnectionandDeleteTeslaFleetTokenkeep its refresh token sealed, as the Owner API's, with which they share their code. A car that moves from ateslaconnection to atesla_fleetone keeps its history (AddVehicle).tesla.FleetSourcenames the provider.extensionNormalizers, besideregisterExtensionsin both binaries, adds an extension's normalizers to the derivation.derive.Sourceswas built before the extensions were registered, so an extension's source could not be derived. It adds none in the public build. Described inAGENTS.md.tesla_fleetin theproviderenum (OpenAPI regenerated), read with its own credential, whose state the API tells. The TeslaMate import, from the API or the command line, takes a Fleet API's Tesla.source.teslaoff, only the Owner API's Teslas are told that Tesla is not offered.Screenshots
The Tesla tab of an account whose Tesla has a
tesla_fleetconnection and no sign-in. Before: the car shows in no tab. After: it shows under Tesla, with its state.Tests
task unit(Go lint, Go and web unit tests, web build), the Go tests with PostgreSQL (go test ./...),task lint-api(Redocly): pass.TestOpenAPIFilepasses); aNOT VALIDconstraint followed byVALIDATE(0025 and 0032 change the same checks directly, andapi_callsis small); a Fleet sign-in button on the Connection page (no such flow exists in the core: an extension provides it).Closes #246
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes