Sign inSign up

fetzu/teslamate-abrp

By fetzu

•Updated about 15 hours ago

A slightly convoluted way of getting your vehicle data from TeslaMate to A Better Route Planner.

Image
Monitoring & observability
6

100K+

fetzu/teslamate-abrp repository overview

⁠TeslaMate: MQTT to ABRP

codecov Test and Build Test and Build Test and Build GitHub release Docker Image Size Docker Pulls GitHub license

A bridge to send your Tesla vehicle data from TeslaMate⁠ to A Better Route Planner (ABRP)⁠.

⁠Features

  • Automatically sends MQTT TeslaMate data to A Better Route Planner
  • Variable (and configurable) update rates based on vehicle state (driving, charging, parked)
  • Secure MQTT options for authentication and (MQTT)TLS encryption
  • Support for Docker secrets management
  • Optional location anonymization
  • Alpha (bleeding-edge) image is available at fetzu/teslamate-abrp:alpha
  • Beta (pre-release) image is available at fetzu/teslamate-abrp:beta

⁠Setup Guide

⁠Prerequisites
  • A working TeslaMate instance with MQTT enabled
  • An ABRP user token
  • Docker (recommended) or Python 3.x environment
⁠Getting an ABRP User Token
  1. Log in to the ABRP web app or mobile app
  2. Navigate to Settings (burger menu)
  3. Under "Plan settings" tap/click the cog wheel of your car
  4. Select "Edit connection"
  5. Select "Link" in the "Generic" box under In-car live data
  6. Token will be displayed
  7. Save this token securely - you'll need it to configure teslamate-abrp

Add the teslamate-abrp service to your existing TeslaMate docker-compose.yml:

ABRP:
  container_name: TeslaMate_ABRP
  image: fetzu/teslamate-abrp:latest
  restart: always
  environment:
    - MQTT_SERVER=mosquitto
    - USER_TOKEN=your-abrp-user-token
    - CAR_NUMBER=1
    # Optional parameters (see Configuration section)
    # - CAR_MODEL=tesla:m3:20:bt37:heatpump
    # - MQTT_USERNAME=username
    # - MQTT_PASSWORD=password
    # - MQTT_PORT=1883
    # - MQTT_TLS=True
    # - STATUS_TOPIC=teslamate-abrp
    # - SKIP_LOCATION=True
    # - TM2ABRP_DEBUG=True
    # - REFRESH_RATE_DRIVING=2.5
    # - REFRESH_RATE_CHARGING=6
    # - REFRESH_RATE_PARKED=30

Deploy the service:

docker-compose pull ABRP
docker-compose up -d ABRP
⁠Option 2: Using Docker with Secrets (More Secure)

For improved security, use Docker secrets to manage sensitive information:

version: '3'
services:
  ABRP:
    container_name: TeslaMate_ABRP
    image: fetzu/teslamate-abrp:latest
    restart: always
    environment:
      - MQTT_SERVER=mosquitto
      - CAR_NUMBER=1
      - MQTT_USERNAME=username
      - MQTT_TLS=True
      - MQTT_PORT=8883
    secrets:
      - USER_TOKEN
      - MQTT_PASSWORD

secrets:
  USER_TOKEN:
    file: ./path/to/abrp-token.txt
  MQTT_PASSWORD:
    file: ./path/to/mqtt-password.txt
⁠Option 3: Running as a Python Script
  1. Clone the repository:

    git clone https://github.com/fetzu/teslamate-abrp.git
    cd teslamate-abrp
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Run the script:

    python teslamate_mqtt2abrp.py USER_TOKEN 1 mqtt-server-address
    

⁠Configuration

⁠Essential Parameters
ParameterDescriptionDefaultRequired
USER_TOKENYour ABRP user token-Yes
CAR_NUMBERTeslaMate car number1No
MQTT_SERVERMQTT server address-Yes
⁠Optional Parameters
ParameterDescriptionDefaultRequired
CAR_MODELABRP car model identifierAuto-detectedNo
MQTT_PORTMQTT server port1883No
MQTT_USERNAMEMQTT username-No
MQTT_PASSWORDMQTT password-No
MQTT_TLSUse TLS for MQTT connectionFalseNo
MQTT_VERIFY_CERTVerify the broker's TLS certificate (only applies with MQTT_TLS). CLI: --verify-cert/--no-verify-cert. Invalid values fall back to enabledTrueNo
STATUS_TOPICTopic to publish status messages-No
SKIP_LOCATIONDon't send location data to ABRPFalseNo
TM2ABRP_DEBUGEnable debug loggingFalseNo
REFRESH_RATE_DRIVINGUpdate interval (seconds) while driving; fractional values allowed, min 12.5No
REFRESH_RATE_CHARGINGUpdate interval (seconds) while charging6No
REFRESH_RATE_PARKEDUpdate interval (seconds) while parked/asleep30No
ABRP_API_KEYOverride the shared ABRP application key (env var or Docker secret). Not a per-user secretBuilt-inNo
⁠Car Model Identification

For optimal route planning, it's recommended to manually specify your car model using the CAR_MODEL parameter. Get the correct identifier from:

https://api.iternio.com/1/tlm/get_carmodels_list

Examples:

  • Tesla Model 3 Long Range with Heat Pump: tesla:m3:20:bt37:heatpump
  • Tesla Model Y Performance: tesla:my:19:bt37:perf
  • Tesla Model S 100D: s100d

⁠Troubleshooting

  1. Check logs for connection issues:

    docker-compose logs ABRP
    
  2. Verify MQTT connectivity:

    docker-compose exec ABRP python -c "import paho.mqtt.client as mqtt; client = mqtt.Client(); client.connect('mosquitto', 1883); print('Connected successfully')"
    
  3. Common issues:

    • MQTT server not reachable
    • Incorrect MQTT credentials
    • Invalid ABRP token
    • Wrong TeslaMate car number

⁠Advanced Usage

⁠Customizing Update Frequencies

The application uses different update rates (in seconds) based on car state, with these defaults:

  • Driving: every 2.5 seconds (REFRESH_RATE_DRIVING)
  • Charging: every 6 seconds (REFRESH_RATE_CHARGING)
  • Parked/Asleep: every 30 seconds (REFRESH_RATE_PARKED)

ABRP recommends a telemetry point roughly every 5 seconds and advises against intervals longer than 30 seconds, so the defaults stay within that window. Faster driving updates (e.g. REFRESH_RATE_DRIVING=1) are supported but, per ABRP, don't materially improve its predictions. Rates may be fractional (e.g. 2.5) but must be at least 1 second; out-of-range or invalid values fall back to the default.

These can be customized via environment variables or the equivalent CLI options (--refresh-driving, --refresh-charging, --refresh-parked). Any value left unset falls back to the default above. Values must be whole positive seconds; invalid values are ignored (with a warning) and the default is used instead.

For example, to make driving updates less aggressive:

environment:
  - REFRESH_RATE_DRIVING=5

⁠Credits

Based on letienne's original code⁠, with improvements by various contributors (see commit history⁠).

⁠License

Licensed under the MIT license⁠.

Tag summary

Content type

Image

Digest

sha256:ba5714305…

Size

21.5 MB

Last updated

6 days ago

docker pull fetzu/teslamate-abrp