Skip to content

A telegram bot which sends a message if you are Home/LowBatt/NotPluggedIn (use TeslaMate MQTT)

License

Notifications You must be signed in to change notification settings

josefwells/TeslaMate_Telegram_Bot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TeslaMate Telegram Bot

This is a telegram bot written in Python to:

Send Telegram message every TIMEOUT seconds (default 3600 == 60 minutes)

  • In the "Home" geofence
  • Not Plugged in
  • Under some BATTERY_ALERT level (default 50%).

It uses the MQTT topic which TeslaMate offers.

Table of contents

Requirements

Installation

Make sure you fulfill the Requirements.

It is recommended to backup your data first.

This document provides the necessary steps for installation of TeslaMate Telegram Bot on a any system that runs Docker.

This setup is recommended only if you are running TeslaMate Telegram Bot on your home network, as otherwise your telegram API tokens might be at risk.

  1. Create a file called docker-compose.yml with the following content (adopt with your own values):

       version: "3"
    
       services:
         teslamatetelegrambot:
           restart: unless-stopped
           environment:
             - BATTERY_ALERT=50 #optional, default 50
             - TIMEOUT=3600     #optional, default 60 minutes (in seconds)
             - MQTT_BROKER_HOST=IP_Adress
             - MQTT_BROKER_PORT=1883 #optional, default 1883
             - MQTT_BROKER_USERNAME=username #optional, only needed when broker has authentication enabled
             - MQTT_BROKER_PASSWORD=password #optional, only needed when broker has authentication enabled
             - TELEGRAM_BOT_API_KEY=secret_api_key
             - TELEGRAM_BOT_CHAT_ID=secret_chat_id
           ports:
             - 1883
           build:
             context: .
             dockerfile: Dockerfile
  2. Build and start the docker container with docker-compose up --build. To run the containers in the background add the -d flag:

    docker-compose up --build -d

Update

Restart the stack with docker-compose up --build. To run the containers in the background add the -d flag:

docker-compose up --build -d

Test

A makefile with pylint and hadolint is provided to ensure consistentency and stability.

make test

Testing utilizes docker and the actual built container which will update your docker-cache layers along the way.

Contributing

All contributions are welcome and greatly appreciated!

Disclaimer

Please note that the use of the Tesla API in general and this software in particular is not endorsed by Tesla. Use at your own risk.

About

A telegram bot which sends a message if you are Home/LowBatt/NotPluggedIn (use TeslaMate MQTT)

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Python 74.9%
  • Dockerfile 16.9%
  • Makefile 8.2%