Connect a TeslaMate instance to Home Assistant, using MQTT

Related tags

Hardwareteslabuddy
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).

A Python program that makes it easy to manage modules on a CircuitPython device!

CircuitPython-Bundle-Manager-v2 A Python program that makes it easy to manage modules on a CircuitPython device! The CircuitPython Bundle Manager v2 i

Ckyiu 1 Dec 18, 2021
This Home Assistant custom component adding support for controlling Midea dehumidifiers on local network.

This custom component for Home Assistant adds support for Midea air conditioner and dehumidifier appliances via the local area network. homeassistant-

Nenad Bogojevic 92 Dec 31, 2022
Port of Uxn to digital hardware in the Logisim simulator

Uxn-Logisim Implements the Uxn instruction set in digital hardware. Very WIP. Contents cpu.circ - The Logisim file microcode.mc - Microcode source fil

DeltaF1 11 Mar 27, 2022
CPU benchmark by calculating Pi, powered by Python3

cpu-benchmark Info: CPU benchmark by calculating Pi, powered by Python 3. Algorithm The program calculates pi with an accuracy of 10,000 decimal place

Alex Dedyura 20 Jan 03, 2023
Real-time Coastal Monitoring at the University of Hawaii at Manoa

Coastal Monitoring at the University of Manoa Source code for Beaglebone/RPi-based data loggers, shore internet gateways, and web server. Software dev

Stanley Lio 7 Dec 07, 2021
Hook and simulate global keyboard events on Windows and Linux.

keyboard Take full control of your keyboard with this small Python library. Hook global events, register hotkeys, simulate key presses and much more.

BoppreH 3.2k Dec 30, 2022
Micropython-wifimanager-esp8266 - Simple Wifi Manager for ESP8266 using MicroPython

micropython-wifimanager-esp8266 Simple Wifi Manager for ESP8266 using MicroPytho

Abhinuv Nitin Pitale 1 Jan 04, 2022
a weather application for the raspberry pi and the Pimorioni Inky pHAT.

raspi-weather a weather application for the raspberry pi and the Inky pHAT

Derek Caelin 59 Oct 24, 2022
FHEM Connector for FHT Heating devices

home-assistant-fht from: https://github.com/Rsclub22 FHEM Connector for FHT Heating devices (connected via FHEM) Requires FHEM to work You can find FH

5 Dec 01, 2022
Shotgrid Toolkit Engine for Gaffer

Shotgun toolkit engine for Gaffer Contact : Diego Garcia Huerta Overview Implementation of a shotgun engine for Gaffer. It supports the classic bootst

Diego Garcia Huerta 12 May 21, 2022
Custom component for interacting with Octopus Energy

Home Assistant Octopus Energy ** WARNING: This component is currently a work in progress ** Custom component built from the ground up to bring your Oc

David Kendall 116 Jan 02, 2023
LED effects plugin for klipper

This plugin allows Klipper to run effects and animations on addressable LEDs, such as Neopixels, WS2812 or SK6812.

Julian Schill 238 Jan 04, 2023
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
Python Wrapper for Homeassistant's REST API

HomeassistantAPI Python Wrapper for Homeassistant's REST API Please ⭐️ the repo if you find this project useful or cool! Here is a quick example. from

Nate 29 Dec 31, 2022
Modi2-firmware-updater - MODI+ Firmware Updater With Python

MODI+ Firmware Updater 실행 준비 python3(파이썬3.9 혹은 그 이상의 버전)를 컴퓨터에 설치 python3 -m pip

LUXROBO 1 Feb 04, 2022
A refreshed Python toolbox for building complex digital hardware

A refreshed Python toolbox for building complex digital hardware

nMigen 1k Jan 05, 2023
🏡 My Home Assistant Configs. Be sure to 🌟 my repo to follow the updates!

Home Assistant Configuration Here's my Home Assistant configuration. I have installed HA on a Lenovo ThinkCentre M93P Tiny with an Intel Dual-Core i5-

iLyas Bakouch 25 Dec 30, 2022
Custom component for MPC-HC for home-assistant

mpc_hc The current mpchc integration in homeassistant violates ADR0004, so it will be deleted from core. This is just the existing integration copied

3 Dec 15, 2022
Create (templateable) cameras that display qr codes in homeassistant

QRCam This custom component creates cameras displaying qrcodes. The QRCodes can be static or generated from templates. If you use a template as conten

Jannes Müller 5 Oct 06, 2022
A small Python app to converse between MQTT messages and 433MHz RF signals.

mqtt-rf-bridge A small Python app to converse between MQTT messages and 433MHz RF signals. This acts as a bridge between Paho MQTT and rpi-rf. Require

David Swarbrick 3 Jan 27, 2022