Skip to content

Latest commit

 

History

History
143 lines (129 loc) · 5.61 KB

INSTALL.md

File metadata and controls

143 lines (129 loc) · 5.61 KB

Installation procedure

Prerequisites

Hardware

  • A Linux based computer which could be the same machine that runs Home Assistant (HA), or a seperate device located remotely from the HA machine, but close to where the car is located. We'll call this device the Host Device (HD). A Raspberry Pi makes an ideal HD
  • Bluetooth Low Energy (BLE) capabilities. This could be a plug in USB device or built-in to the HD. A strong BLE signal is required for reliable operation, so the HD should be located close to where the car is normally parked
  • An existing Linux OS installation which is already installed and operational on the HD. For a RPi this could be DietPi or Raspberry Pi OS. You will need to check that BLE (not just standard Bluetooth without BLE) is operational before proceeding

Software

On the Host Device

In Home Assistant

  • Mosquitto Add-on
  • MQTT Integration

Installation

1 - Deploy the Container

There are various methods to deploy the container, see the main ones below:

Deploy using Command Line

i. Create a tesla_ble_mqtt_docker folder in your user directory and change directory into it:

cd ~
mkdir tesla_ble_mqtt_docker
cd tesla_ble_mqtt_docker

ii. Download docker-compose.yml and stack.env from the github repository:

curl -O https://raw.githubusercontent.com/tesla-local-control/tesla_ble_mqtt_docker/main/docker-compose.yml
curl -O https://raw.githubusercontent.com/tesla-local-control/tesla_ble_mqtt_docker/main/stack.env

iii. Check docker-compose.yml contents are suitable for your needs. It will be ok as is for most people

iv. Update the environment variables in stack.env according to your needs. As a minimum enter the VIN of your car, and the connection details for your MQTT server:

# Mandatory; if multiple VINs separate with |
#
VIN_LIST=
# Mandatory; Hostname or IP address
#
MQTT_SERVER=
# Service port # or name
#
MQTT_PORT=1883
# If no username provided, anonymous mode.
#
MQTT_USERNAME=
# If you have special characters, wrap with ' at both ends; escape ' if needed
#
MQTT_PASSWORD=
# Default 5 (seconds)
#
BLE_CMD_RETRY_DELAY=
# Default 120 (seconds)
#
PRESENCE_DETECTION_LOOP_DELAY=
# Default 240 (seconds)
#
PRESENCE_DETECTION_TTL=
# Your timezone
# Ref: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
#
TZ='Europe/London'
### Default false
#
TEMPERATURE_UNIT_FAHRENHEIT=
### Default 48
#
MAX_CURRENT=32
### Default false
#
DEBUG=
#
# WARNING; If you run Home Assistant, keep this true unless you know what you're doing
#
ENABLE_HA_FEATURES=true

v. Create the Docker volume: docker volume create tesla_ble_mqtt

vi. Create a symbolic link to the environment file: ln -s stack.env env

vii. Start the container: docker compose up -d

vii. Check the logs docker logs -f tesla_ble_mqtt. Typical logs after start up look like this (when DEBUG=false):

Configuration Options are:
  BLE_CMD_RETRY_DELAY=5
  DEBUG=false
  MQTT_SERVER=192.168.1.5
  MQTT_PORT=1883
  MQTT_PASSWORD=Not Shown
  MQTT_USERNAME=XXXXXX
  PRESENCE_DETECTION_LOOP_DELAY=120
  PRESENCE_DETECTION_TTL=240
  TEMPERATURE_UNIT_FAHRENHEIT=false
  VIN_LIST=LRWXXXXXXXXXXX403
  MAX_CURRENT=32
  ENABLE_HA_FEATURES=true
Removing single buttons to be replaced by switches & covers:
windows, charger, cherge-port, climate, trunk
delete_legacies_singles; deleting legacy single MQTT entities topics  Setting up MQTT clients with authentication
setupHADiscoveryAllVINsMain; Discarding any unread MQTT messages for topic:tesla_ble/LRW3F7FS5RC036403/config
Listening for Home Assistant Start (in background)
Entering main loop...
main loop; Lauching background listen_to_mqtt_loop...
main loop; launch BLE scanning for car presence every 120 seconds
Entering Listen to MQTT loop...
Launching listen_to_mqtt
Listening to MQTT

Deploy using Dockerfile

See instructions here: INSTALLwDockerfile.md

Deploy using Portainer

See instructions here: INSTALLwPortainer.md

2 - Activate the Key via Home Assistant

  • Go to the Integrations page in Home Assistant and click on the MQTT box
  • One new device per vehicle should appear in the list: Tesla_BLE_LRWXXXXXXXXXXX403
  • Access the list of entities linked to the device by clicking on it
  • Press the button Generate Keys
  • It is useful to monitor the logs during this process

3 - Add the Key to the Vehicle

Important

The Host Device must be near the vehicle

  • Get a vehicle key card
  • Sit in the driver’s seat with your phone open to the Home Assistant page for the MQTT device. The vehicle screen should be active
  • Press Deploy Key from the HA interface on your phone
  • Immediately place the key card on the central console as if to start the vehicle. A confirmation dialog will popup ask you to validate adding the key
  • Rename the newly added Unknown Key to a recognizable name, e.g. BLE Key
  • NOTE: You may have to try this process several times before the confirmation dialog will appear

4 - Test Sending Commands with the BLE Key

  • From the Home Assistant interface, test the available commands