Connected cars: update the odometer automatically

The provider tab gets an "Update odometer automatically" switch and an
interval (30 minutes to a week, daily by default). The API Server does
the updating on the scheduler's ticker, so it carries on with no page
open: every five minutes it takes the provider's odometer for each due
car and stores it when it is ahead, never backwards, the same as the
Update odometer button.

The setting belongs to the car. Readings are fetched under the account
of whoever switched it on, and stop if that user can no longer edit the
car. Each attempt and its error, if any, are stored on the car and shown
under the switch. The switch also shows when the provider can't be
reached, so updates that are failing can still be switched off.

New car fields odometer_auto_sync, odometer_sync_minutes,
odometer_sync_by, odometer_synced_at and odometer_sync_error; new route
PUT /api/cars/{id}/provider/auto-sync. Unlinking leaves the setting as
it is; the sweep only looks at linked cars.

launch.json gains api-server-8081 / web-app-8081 for when 8080 is taken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-11-18 12:07:02 +01:00
1 parent 914aeeee23
commit 3db12dba63
14 files changed
+512 -11

No files matched your search

+9
View File
@@ -41,6 +41,15 @@ var collectionsSchema = map[string][]fieldDef{
// internal/api/vehicleproviders.go. Blank for a hand-entered car.
fText("provider", false),
fText("provider_vehicle_id", false),
// Automatic odometer updates from that service: on/off, how often (in
// minutes), whose account the reading is fetched under (the user who
// switched it on — provider calls always run as a person), and the last
// attempt with its error, if any. See internal/api/odometersync.go.
fBool("odometer_auto_sync"),
fNumber("odometer_sync_minutes"),
fText("odometer_sync_by", false),
fText("odometer_synced_at", false),
fText("odometer_sync_error", false),
// What this car's page shows: the tabs switched off (["fuel"] on an EV)
// and the Information fields switched off (["differentialOil"] on a car
// without one). Properties of the car, so everyone it is shared with sees