TeslaMate: Elixir-based self-hosted Tesla data logger with visualization
TeslaMate is a self-hosted Elixir Tesla data logger storing telemetry in Postgres and visualized with Grafana, aimed at advanced users and home deployments requiring in-depth energy and trip analysis.
GitHub teslamate-org/teslamate Updated 2026-06-16 Branch main Stars 8.2K Forks 946
Elixir Postgres Grafana MQTT Vehicle telemetry Self-hosted Energy & trip analysis

💡 Deep Analysis

4
Why choose the Elixir + Postgres + Grafana + MQTT stack? What are the architectural advantages?

Core Analysis

Architectural Positioning: TeslaMate’s choice of Elixir + Postgres + Grafana + MQTT is a purpose-built stack for long-term vehicle telemetry collection and local integration, prioritizing reliability, scalability, and interoperability.

Technical Advantages

  • Elixir / Erlang VM: Excellent for concurrency, long-lived connections, and fault tolerance. Fits Tesla API session/token management and concurrent vehicle tracking via OTP processes.
  • Postgres (persistence): Strong consistency and powerful temporal/spatial query capabilities (indexes, partitioning, backup tools), suitable for multi-year driving/charging histories.
  • Grafana (visualization): Focused on dashboards, supports multiple data sources and custom queries; bundled dashboards lower analysis friction.
  • MQTT (realtime/integration): Lightweight pub/sub protocol ideal for integration with Home Assistant and Node-RED, decoupling core collection from automation logic.

Practical Benefits

  1. Separation of concerns: Each component does one job, easing upgrades/replacements (e.g., swap DB for a TSDB if needed).
  2. Maintainability: Elixir supervision trees plus Postgres ecosystem reduce operational complexity.
  3. Low-coupling integration: MQTT enables flexible subscription patterns for downstream automation and alerts.

Practical Tips

  • Implement Postgres partitioning/retention to control disk growth;
  • Configure Elixir supervisors and container health checks for robust restarts;
  • Protect Grafana/MQTT endpoints with reverse proxy and TLS.

Note: For very large fleets (hundreds of vehicles with high-frequency collection) anticipate extra architecture work (sharding, archiving).

Summary: This stack provides clear advantages for reliability, long timeseries management, and home-automation interoperability.

88.0%
In practice, how do you ensure the vehicle returns to sleep quickly and avoid additional vampire drain?

Core Analysis

Key Concern: Avoiding additional vampire drain depends on collection strategy and session behavior with the vehicle. TeslaMate is designed to minimize wake-ups, but correct configuration and operation are crucial.

Technical Analysis

  • Prefer event-driven collection: Triggering on events or state changes (e.g., charge start/stop) is far more efficient than continuous high-frequency polling.
  • Long sessions and token management: Maintain valid API sessions and optimize token refresh logic to avoid frequent re-authentication that can wake the car.
  • Polling intervals and backoff: Configure reasonable default polling intervals (longer for non-real-time needs). Temporarily increase sampling when the vehicle is active, then quickly revert to low-frequency mode.

Practical Recommendations

  1. Use recommended defaults: On first deployment, follow the docs’ recommended collection intervals and token strategies; avoid making polling intervals too short.
  2. High-frequency only when needed: Increase sampling during drives or charging; otherwise stay in low-frequency/event mode.
  3. Monitor sleep state: Use Grafana States dashboards or custom queries to detect changes in sleep/online time; investigate anomalies for misconfigurations or external queries.

Note: Public exposure or misconfigured credentials that allow external services to poll the car frequently can prevent sleep—limit credentials and network access.

Summary: By prioritizing event-driven collection, sensible polling and optimized session handling, and monitoring sleep state, you can minimize vampire drain while maintaining useful telemetry.

86.0%
If I want to use TeslaMate for a small fleet or research, how should I scale and manage long-term historical data?

Core Analysis

Key Issue: For small fleets or research, the main challenge is retaining sufficient data resolution while controlling storage costs and query performance.

Technical Assessment

  • Postgres scalability: Suitable for initial and small-to-medium deployments, supports time partitioning, index tuning, and materialized views to speed historical queries.
  • Retention and sampling strategy: Separate raw high-frequency telemetry from aggregated data: keep raw data for a shorter period (e.g., 3–12 months) and retain hourly/daily aggregates long-term.
  • Archiving and cold storage: Periodically export older data to object storage (S3 or NAS) and restore on demand to reduce Postgres footprint.
  • Horizontal scaling: At higher scales, consider read/write splitting, sharding, or introducing a time-series DB (e.g., TimescaleDB, InfluxDB, ClickHouse).

Practical Steps

  1. Enable time partitioning: Partition drive/charge tables monthly/daily and run automatic cleanup jobs.
  2. Define retention: Example: raw telemetry 6 months, hourly/daily aggregates 5 years.
  3. Archive process: Implement scheduled archive jobs (export, compress, upload) and maintain metadata for restores.
  4. Monitor and optimize: Track slow queries, maintain indexes, and create materialized views for frequent analyses.
  5. Evaluate alternative stores: If data grows significantly, move to TimescaleDB or a dedicated TSDB for hot/cold layering.

Note: Always run backup and restore drills before migrations/archival to ensure historical data remains readable.

Summary: With partitioning, retention/downsamping, and archiving, TeslaMate can support small fleet and research long-term needs; for much larger scales, plan for sharding or dedicated TSDB layers.

86.0%
For non-technical users, what are the main deployment and operational challenges? What are best practices?

Core Analysis

Key Issue: For non-technical users, the main hurdles are infrastructure and operational aspects of self-hosting—container deployment, database maintenance, credential handling, and network/TLS configuration.

Technical Assessment (Common Challenges)

  • Container and host setup: You need familiarity with Docker/docker-compose or Helm, persistent volumes, environment variables, and resource limits.
  • Credentials and Tesla API: Correct handling of login, 2FA/token refresh and protecting credentials (avoid storing account info in plaintext on uncontrolled hosts).
  • Postgres maintenance: Set up backups, monitor disk usage and retention policies to prevent unbounded growth.
  • Network security: Protect Grafana, MQTT, and admin endpoints behind a reverse proxy + TLS or keep them on an internal network only.

Practical Recommendations (Best Practices)

  1. Use official deployment templates: Start with official docker-compose or Helm charts and follow the docs step-by-step.
  2. Secure credentials: Use secret management (Docker secrets, Vault) and restrict network access.
  3. DB strategy: Implement regular backups (pg_dump or physical backups) and retention/partitioning for raw telemetry.
  4. Staged upgrades: Test upgrades in a staging environment and backup DB before applying migrations.
  5. Leverage docs & dashboards: Official docs and bundled Grafana dashboards reduce onboarding time.

Note: Monitor vehicle sleep/online states after deployment to ensure no misconfiguration or external polling prevents sleep.

Summary: Non-technical users can make self-hosting manageable by using official container templates, strict credential and backup policies, and incremental testing.

84.0%

✨ Highlights

  • High-precision vehicle telemetry recording with time-series storage for long-term analysis
  • Easy integration with Grafana, MQTT and Home Assistant ecosystems
  • Users must obtain releases only from official sources to avoid malicious forks or altered builds
  • AGPLv3 license imposes strong reciprocity requirements affecting closed-source distribution and SaaS

🔧 Engineering

  • Self-hosted recording of Tesla vehicle telemetry with Postgres storage and Grafana visualization
  • Publishes vehicle data via MQTT for easy integration with Home Assistant, Node-Red, and Telegram

⚠️ Risks

  • Docs warn about malicious forks; installing from unofficial sources risks credential and data exposure
  • AGPLv3 requires source disclosure for modifications and networked services; restricts commercial/closed-source use
  • Provided metadata shows no contributors/releases which may indicate risks to long-term maintenance and community support

👥 For who?

  • Suitable for advanced users, home-server deployers, and vehicle-data enthusiasts
  • Useful for teams or individuals requiring local data control and open-source compliance