Skip to content
/ tesla Public
forked from themonomers/tesla

Utility tools leveraging the unofficial Tesla API's.

Notifications You must be signed in to change notification settings

aitmills/tesla

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

/google
These scripts are based on Google Apps Script (https://script.google.com/home), which is free!  There are 5 components to this project:

1.  Telemetry.gs - logs data from your vehicle for analysis, e.g. miles, efficiency, battery capacity, etc.
2.  SmartCharger.gs - sends an email if you forget to plug in your vehicle and calculates then sets the optimal charge start time.
3.  SmartClimate.gs - customized scheduling of pre-heating/cooling of cabin and seat heating by day of the week.
4.  Logging.gs - logs error messages in the try/catch blocks.
5.  Email.gs - keeps email sent folder from growing too large.
Additional component:  GoogleSheetScriptEditor.gs - cut/paste contents into a Google Sheet script editor as simple way to get API data.

Google Sheet example:  https://docs.google.com/spreadsheets/d/1662a1ma0Z2cdnkKvn2JWClFGsu-T-QS6NNCyyuyEweA/edit?usp=sharing
The first 3 tabs of the Google Sheet corresponds to the first 3 scripts above.

I created several in-depth videos walking through the functionality and code:  https://www.youtube.com/watch?v=l1pqhlGSuVg&list=PLgiPnlzk2O712gwiTIquUzdfVlzIMyS2M


/python
Ported Tesla Google Apps Scripts to python for more control over functionality and as a backup. Additional scripts for Tesla Energy products that run on local machines as they are writing to InfluxDB and I don't want to open that to the internet. 

1.  Core functions:
      TeslaEnergyAPI.py - API calls for Tesla Energy products
      TeslaVehicleAPI.py - API calls for Tesla Vehicles
      TeslaToken.py - API call for the Tesla authentication flow to retrieve new access and refresh tokens
      TeslaRefreshToken.py - API call to refresh new access and refresh tokens
      GoogleAPI.py - API calls for Google products and services
      Influxdb.py - Access to InfluxDB

2.  Utility functions:
      Utilities.py - Commonly used and helpful tools
      SendEmail.py - Service to send emails
      Logger.py - Central logging service 
      Crypto.py - Encryption and decryption functions for sensitve files
      CheckTokenExpiration.py - Retrieves new Tesla tokens based on expiration date/time
      RemoveTeslaCron.py - Cleans up crontabs that are meant to exist for each specific day
      TruncateEmail.py - Helper function to keep email sent folder from growing
      TruncateLog.py - Helper function to keep central logging from growing

3.  Energy functions:
      EnergyImport.py - Imports data manually when automated processes fail
      EnergyTelemetry.py - Writes all energy data from previous day for Grafana
      EnergyLiveTelemetry.py - Option to write real time energy data for Grafana using Tesla API
      EnergyLocalLiveTelemetry.py - Option to write real time energy data using Tesla Gateway API
      EnergyMode.py - Customizes energy site behavior based on weather

4.  Vehicle functions:
      PreconditionM3Start.py - Triggers car HVAC based on preferences stored in a Google Sheet
      PreconditionM3Stop.py - Halts car HVAC
      PreconditionMXStart.py
      PreconditionMXStop.py
      VehicleTelemetry.py - Write all vehicle data from previous day in Google Sheet
      SmartCharger.py - Calculates and sets charging times to complete at a departure time for 2 EV's
      SmartClimate.py - Sets up crontab for starting the car HVAC based on references stored in a Google Sheet

Here are the packages needed:
  python3-pip
  teslapy
  google-api-python-client
  google-auth-httplib2
  google-auth-oauthlib
  python-crontab
  pytz
  influxdb

About

Utility tools leveraging the unofficial Tesla API's.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 66.2%
  • JavaScript 33.8%