π Fork Overview & Enhancements
This fork extends the official Tesla reference implementation into a complete, production-ready observability stack. It transforms the raw telemetry receiver into an end-to-end analytics platform with a TimescaleDB backend, predictive diagnostics across 11 vehicle subsystems, and 16 pre-built Grafana dashboards β served behind nginx mTLS.
Key Additions:
- PostgreSQL / TimescaleDB Dispatcher: A custom Go datastore module (
datastore/postgres/) that writes incoming telemetry directly into TimescaleDB with continuous aggregates, compression, and 5-year retention.- 59 SQL Migrations (
001β058, two005files; applied indeploy/sql/migrations.txtorder, not filename order): Schema, views, unit-conversion functions, GPS-based trip sessionisation, charge session detection, and full predictive diagnostics for battery, drivetrain, heat pump, suspension, brakes, PCS, dual motor, and Cybertruck subsystems (deploy/sql/).- Predictive Health Engine: Cross-subsystem risk scoring (
predictive_health_summaryview) that weights 11 subsystems into a single 0β100 risk score with recommended actions.- 16 Grafana Dashboards (
00β15): Pre-provisioned via Docker Compose with auto-discovery β see screenshots below.- Experimental capacity-fade estimate (Packfade method): per-drive apparent pack capacity (VΓI energy Γ· share of SOC used) with a robust, temperature-adjusted trend and a bootstrap interval, computed daily by
tools/notifyand shown on the Battery Health dashboard. The method is adapted from Packfade (MIT licence) by the same author. See Experimental: capacity fade.- Experimental route-efficiency monitor: routes the car drives often are found from the data and used as a repeatable test of energy per distance (temperature, trip duration and HVAC fan adjusted), so a lasting drift points at tyres, alignment, a dragging brake or load. Shown on the Regen & Brake dashboard. The repeated-route idea comes from Packfade's approach (MIT licence), by the same author. See Experimental: route efficiency.
- Telemetry Simulator: Generates realistic 90-day synthetic history for dashboard development without a real vehicle (
tools/simulator/).- Extensive Deployment Runbook: Covers Let's Encrypt + nginx mTLS, EC keypair generation, Tesla Developer API registration, virtual key pairing, and DNS automation (
deploy/README.md).
β οΈ Experimental features: The whole Predictive Health Engine β the diagnostic and scoring views fromdeploy/sql/005β017, as reworked by025β041β and the Telemetry Simulator (tools/simulator/) are early-stage beta features. Several inputs are proxies (the 12 V score is DC-DC activity, brake wear is a mileage model, PCS "failure" compares two different current signals). Diagnostic scores and wear estimates may be inaccurate β do not rely on them for safety or maintenance decisions without independent verification.
Layer Upstream This Fork Ingest Go mTLS WebSocket server Same β no core protocol changes Persistence Kafka, Kinesis, Pub/Sub, MQTT, ZMQ + PostgreSQL / TimescaleDB Schema & Analytics None + Hypertables, PostGIS, trip views, unit-conversion SQL functions Visualisation None + 16 Grafana dashboards (Overview, Predictive Health, Energy, Alerts, etc.) Testing Basic integration tests + Synthetic telemetry simulator covering all 239 vehicle fields Deployment Helm chart reference + Docker Compose stack + full operator runbook Production Server (Ubuntu + UFW) βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β β Nginx (HTTPS / Let's Encrypt / EC Key Serving) β Owner (Browser) ββ HTTPS :443 ββΌββΊ β β β β β β Docker Compose Stack β β β βββββββββββββββββββββββββββββββββββββββββββ β β ββββββΊβ Grafana (:3003) β β β β β² β β β β β (SQL Views & Dashboards) β β β β βΌ β β β β TimescaleDB (PostgreSQL + PostGIS) β β β β β² β β β β β (Raw Telemetry Insert) β β β β β β β Tesla Vehicle ββββ mTLS :4443 ββΌβββββββββΊβ fleet-telemetry (Go) β β β βββββββββββββββββββββββββββββββββββββββββββ β β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- TimescaleDB stores every telemetry field as a single hypertable with composite PK
(ts, vin, field). PostGIS handles GPS points. Compression is enabled (7-day chunks).- PostgreSQL dispatcher is a first-class
telemetry.Producer(~550 LOC, with integration tests). It unmarshals protobuf records, handles numeric/string/geo types, and writes in batches.- SQL analytics layer lives in
deploy/sql/:
001_schema.sqlβ hypertable, indexes, PostGIS002_views.sqlβ trip detection via GPS time-gap sessionization, energy per trip (kWh, Wh/km), battery drain, speed stats; pivotable user-preference views for dynamic unit conversion003_grafana_role.sqlβ read-only DB user for Grafana004_field_catalog.sqlβ searchable field metadata- Grafana dashboards use query variables (VIN selector, time range) and call SQL helper functions (
to_dist,to_temp) so the same dashboard works for metric or imperial vehicles.- Simulator (
tools/simulator/) generates realistic driving/charging data directly into TimescaleDB, letting you develop and demo dashboards without owning a Tesla or exposing a public endpoint.
- Single hypertable, EAV-style β One
(ts, vin, field, num_value, str_value, geo_value)table instead of dozens of typed tables. This matches the streaming protobuf schema and makes adding new vehicle fields zero-downtime.- Trip detection in SQL β Rather than maintaining stateful session logic in Go, trips are derived via a SQL window function that detects >5-minute GPS gaps. This makes the definition inspectable, versioned, and easy to tune.
- Unit conversion at query time β The car reports its preferred units as telemetry fields. Grafana reads the latest preference per VIN and passes it into SQL functions. No hard-coded units in the dashboards.
- Two-domain architecture β
tesla.example.comserves the mTLS fleet endpoint;ft.example.comserves the static EC public key for Tesla partner registration. This isolates the public-key serving requirement from the telemetry port.
β οΈ Experimental. Not part of the predictive health score.
The method is adapted from Packfade (MIT licence), an e-bike battery degradation tool by the same author. Packfade infers fade from %SOC per km; the car reports pack voltage and current, so each drive gives an apparent capacity directly: energy that left the pack (trapezoidal VΓI integral, 90 s gap cap) Γ· share of SOC used. Route, wind and load cancel.
- Observations:
packfade_segments(migration057), one row per drive. Drives with charging inside, under 90 % power-sample coverage or under 5 % SOC used are rejected and the reason is recorded. - Fit: Packfade's model β
ln C = b0 β btΒ·t + Ξ³Β·temperature, weighted least squares (delta-method SOC variance plus an environmental floor), Huber IRLS (k = 1.345, MAD scale), seeded date-clustered bootstrap for the 95 % interval. Implemented in Go intools/notify/packfade(the fitting routine is a port of Packfade's browser engine; see the file header). - Running: the notify daemon recomputes it once a day;
tesla-notify --packfade-oncerecomputes on demand (--dry-runprints without storing). Results:packfade_estimate,packfade_points,packfade_curve. - Shown: Battery Health dashboard (09), row "Experimental β Packfade method".
- Limits: it relies on the BMS SOC, and an LFP pack's SOC drifts between full charges; current and voltage are
sampled every 30 s; with months of data the interval is wide, and the dashboard says so in plain words
("not yet distinguishable from no fade") until it is not. Details:
deploy/README.md.
β οΈ Experimental. Not part of the predictive health score.
Routes driven often make a repeatable test of the vehicle's efficiency (the battery is the capacity estimate's job):
on the same route at matched conditions, energy per km should be stable, so a sustained drift points at tyres and
pressures, alignment, a dragging brake or added load. The repeated-route idea comes from
Packfade's approach (MIT licence) by the same author, and the fit reuses
the packfade package's Huber-WLS and day-clustered bootstrap.
- Routes from the data: trip endpoints clustered within 300 m, the two directions separate, detours (distance more than 10 % off the median) dropped, and trips grouped by the road actually driven (GPS tracks within 300 m), so two roads between the same endpoints are two routes. A route needs at least 8 trips, 1 km and a distance CV of at most 5 %. Routes have opaque ids; coordinates stay in the database, and the dashboard names a route from the bot's saved places when both endpoints fall in one (otherwise Route A, B, ...).
- Energy: the BMS count (SOC used Γ kWh per % at the start), which on 2 km routes scatters half as much as integrating the 30 s pack-power samples.
- Model: pooled
ln(Wh/km) = route + dΒ·t + temperature + trip duration + fan level, plus per-route fits on time and temperature; drift in %/year with a 95 % interval, and "not distinguishable from no drift" while it includes zero. - Running: daily in the notify daemon;
tesla-notify --route-efficiency-once [--dry-run]on demand. - Shown: Regen & Brake dashboard (13), row "Experimental β route efficiency". Details and real-data numbers:
deploy/README.md.
A Go daemon that sends a Telegram message after every completed drive β route map image, trip stats, weather, charging status, and 30-day efficiency comparison β plus an interactive bot for querying your car's history on demand.
After each drive the bot sends a photo (route map PNG) with a caption:
π Trip complete Β· 42m
π Home β Work
π 186.3 km (115.8 mi)
β‘ 31.45 kWh
π° Est. cost: Β£7.23 (@ 23p/kWh)
π‘οΈ 168 Wh/km (270 Wh/mi)
π 5% more efficient than 30-day avg
π 81% β 47%
ποΈ Avg 68 mph Β· Max 79 mph
π€οΈ 12Β°C, partly cloudy
π Now charging Β· full by ~19:30
A real trip message, shown in a phone-style mock-up:
| Command | Description |
|---|---|
/summary7d |
Last 7 days: trips, distance, kWh used, cost, AC/DC charging |
/summary30d |
Same for 30 days |
/lastknownlocation |
Map image of car's most recent GPS position |
/nearestcharger |
3 nearest open Tesla Superchargers (from supercharge.info) |
/setunits km|miles |
Switch distance units β persisted across restarts |
/settemp c|f |
Switch temperature units β persisted across restarts |
/addplace <name> <lat> <lon> [radius_m] |
Add a named place (shown instead of street address) |
/listplaces |
List all named places |
/help |
Full command reference |
The bot also monitors the supercharge.info Atom feed and sends an alert when a new Supercharger opens within a configurable radius of your named places.
- Create a Telegram bot via @BotFather and note the token and your chat ID.
- Apply migrations
018β020indeploy/sql/. - Create
deploy/notify-config.json(seedeploy/notify-config.sample.jsonfor the template). - Build and start:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o deploy/tesla-notify-linux-amd64 ./tools/notify docker compose --profile notify up -d tesla-notify-daemon
The daemon makes outbound-only connections β no ports are exposed.
See docs/notify-user-guide.md for the full user guide and docs/notify-technical.md for architecture, config reference, and deployment details.
For the original Tesla Fleet Telemetry documentation (covering the Go ingest server architecture, Kinesis/PubSub configurations, and core protocol details), please see docs/UPSTREAM.md.
This project is licensed under the Apache License 2.0.
- The original Go ingest server is copyright Β© 2024 Tesla, Inc.
- The Predictive Health engine, PostgreSQL/TimescaleDB analytics, and Grafana dashboards are copyright Β© 2026 Piotr Godlewski.













