Connect a TeslaMate instance to Home Assistant, using MQTT

Related tags

Hardware teslabuddy
Overview

TeslaBuddy

Connect a TeslaMate instance to Home Assistant, using MQTT. It allows basic control of your Tesla vehicle via Home Assistant (currently, just starting and stopping charging, and changing the charge limit). GPS/location information is also shown in Home Assistant.

All devices are auto-discovered via Home Assistant using MQTT Auto-Discovery - no manual configuration is required.

This is designed to be run in Docker (like TeslaMate), but can be run standalone if desired using command line arguments.

Configuraiton

Configuration can be given via the OS environment (or via the command line).

The full list of options can always be viewed by running the script with -h. To set an option via the OS environment, convert the command line long option to uppercase, and replace "-" with "_", for example, the "--database-host" option would be:

DATABASE_HOST=postgres.local

Example docker-compose.yml

This example assumes you have built TeslaBuddy as follows:

docker build -t teslabuddy .

This is a snippet from a docker-compose.yml file, this would typically be along side the TeslaMate configuration, and assuming you are running Home Assistant in the same file. Note that the DATABASE_* values can match identically the same values used for TeslaMate (you can also create a dedicated user in Postgres with read-only access).

  teslabuddy:
    image: teslabuddy
    depends_on:
      - homeassistant
      - teslamate
      - postgres
      - mqtt
    restart: always
    environment:
      - DATABASE_USER=teslamate
      - DATABASE_PASS=securepassword
      - DATABASE_NAME=teslamate
      - DATABASE_HOST=postgres
      - MQTT_HOST=mqtt
      # - DEBUG=true
    volumes:
      - "/etc/localtime:/etc/localtime:ro"

If you are not running TeslaMate as part of the same docker-compose or swarm or have a different name for it, you will also need to include the TESLAMATE_URL to match your configuration, eg:

      - TESLAMATE_URL=https://teslamate.my.domain/

If your TeslaMate configuration also has several vehicles associated with it, you will also need to include the VIN of the desired vehicle, eg:

      - VIN=5Y123456789123456

Home Assistant "Device Tracker"

An important component of a Home Assistant Device Tracker (I have figured out from trial and error as the docs don't cover this), is the state component should always be either home or not_home. To configure the home location, in TeslaMate create a Geo-Fence (configured via the web interface), and name it "Home". When the vehicle enters this area, it will set the state attribute to home. If not set, the vehicle will always be not home. Home Assistant does not use it's configured home location to set this for device trackers via MQTT (I'm not sure about other devices).

ToDo

Currently this only supports charging actions, and is very much focused on that. However if you are interested in supporting more actions, please raise an issue and I can include it. I will likely add further controls about what options are exposed via MQTT if going down this path.

Additionally, not all items from TeslaMate are surfaced in Home Assistant, please raise an issue if you want more to come through as well.

Finally, the configuration is fairly limited, so if something is not supported that you need (eg: MQTT over TLS), please also raise an issue.

If this becomes at all popular, I'll also look to deploy it to Docker Hub (so you don't have to build it yourself).

Implementation Notes

This implementation uses the vehicle VIN as as identifier for everything to make sure it remains unique. This means that should a vehicle be move to/from another account, things should remain the same in Home Assistant, even if TeslaMate needs updating.

I use this to manage when my car will charge, to make the most of home solar generation and cheap grid prices (adjusting how much the vehicle will charge based on the current value).

You might also like...
Home Assistant custom integration for e-distribución
Home Assistant custom integration for e-distribución

e-Distribución is an energy distribution company that covers most of South Spain area. If you live in this area, you probably are able to register into their website to get some information about your power demand, energy consumption, or even cycle billing (in terms of consumptions).

Home Assistant custom integration for Yi cameras: yi-hack-MStar, yi-hack-Allwinner and yi-hack-Allwinner-v2
Home Assistant custom integration for Yi cameras: yi-hack-MStar, yi-hack-Allwinner and yi-hack-Allwinner-v2

yi-hack Home Assistant integration Overview yi-hack Home Assistant is a custom integration for Yi cameras (or Sonoff camera) with one of the following

Интеграция Home Assistant с ЛК
Интеграция Home Assistant с ЛК "Интер РАО"

ЕЛК ЖКХ «Интер РАО» для Home Assistant Предоставление информации о текущем состоянии ваших аккаунтов в ЕЛК ЖКХ. Введение @ TODO @ Установка Посредство

Provide Unifi device info via api to Home Assistant that will give ap sensors
Provide Unifi device info via api to Home Assistant that will give ap sensors

Unifi AP Device info Provide Unifi device info via api to Home Assistant that will give ap sensors

Switch predictor for Home Assistant with AppDeamon

Home Assistant AppDeamon - Event predictor WORK IN PROGRESS - CURRENTLY NOT COMPLETE AND NOT WORK This is an idea under development (when I have free

Uses the Duke Energy Gateway to import near real time energy usage into Home Assistant
Uses the Duke Energy Gateway to import near real time energy usage into Home Assistant

Duke Energy Gateway This is a custom integration for Home Assistant. It pulls near-real-time energy usage from Duke Energy via the Duke Energy Gateway

Custom component for Home Assistant that integrates Candy/Haier Wi-Fi washing machines (also known as Simply-Fi).

Candy Home Assistant component Custom component for Home Assistant that integrates Candy/Haier Wi-Fi washing machines (also known as Simply-Fi). This

emhass: Energy Management for Home Assistant
emhass: Energy Management for Home Assistant

emhass EMHASS: Energy Management for Home Assistant Context This module was conceived as an energy management optimization tool for residential electr

Electrolux Pure i9 robot vacuum integration for Home Assistant.

Home Assistant Pure i9 This repository integrates your Electrolux Pure i9 robot vacuum with the smart home platform Home Assistant. The integration co

Owner
null
Home-Assistant MQTT bridge for Panasonic Comfort Cloud

Panasonic Comfort Cloud MQTT Bridge Home-Assistant MQTT bridge for Panasonic Comfort Cloud. Note: Currently this brige is a one evening prototype proj

Santtu Järvi 2 Jan 4, 2023
Iec62056-21-mqtt - Publish DSMR P1 telegrams acquired over IEC62056-21 to MQTT

IEC 62056-21 Publish DSMR P1 telegrams acquired over IEC62056-21 to MQTT. -21 is

Marijn Suijten 1 Jun 5, 2022
Smart EQ connect - Custom Integration for Home Assistant

Smart EQ Connect platform as a Custom Component for Home Assistant.

Rene Nulsch 2 Jan 4, 2022
Home Assistant integration for energy consumption data from UK SMETS (Smart) meters using the Hildebrand Glow API.

Hildebrand Glow (DCC) Integration Home Assistant integration for energy consumption data from UK SMETS (Smart) meters using the Hildebrand Glow API. T

Aniket 153 Dec 30, 2022
Authentication provider using Synology DSM users for Home Assistant

Authentication provider using Synology DSM users for Home Assistant The Synology authentication provider lets you authenticate using the users in your

Sam Debruyn 5 Oct 6, 2022
Resmed_myair_sensors - This is a Home Assistant custom component to pull daily CPAP data from ResMed's myAir service using an undocumented API

resmed_myair This component will set up the following platforms. Platform Description sensor Show info from the myAir API. Installation Using the tool

Preston Tamkin 17 Dec 29, 2022
Alternative firmware for ESP8266 with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at

Alternative firmware for ESP8266/ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability

Theo Arends 59 Dec 26, 2022
Universal Xiaomi MIoT integration for Home Assistant

Xiaomi MIoT Raw 简体中文 | English MIoT 协议是小米智能家居从 2018 年起推行的智能设备通信协议规范,此后凡是可接入米家的设备均通过此协议进行通信。此插件按照 MIoT 协议规范与设备通信,实现对设备的状态读取及控制。

null 1.9k Jan 2, 2023
Volkswagen ID component for Home Assistant

Volkswagen ID component for Home Assistant This folder contains both a generic Python 3 library for the Volkswagen ID API and a component for Home Ass

null 55 Jan 7, 2023
Sensor of Temperature Feels Like for Home Assistant.

Please ⭐ this repo if you find it useful Sensor of Temperature Feels Like for Home Assistant Installation Install from HACS (recommended) Have HACS in

Andrey 60 Dec 25, 2022