• Stars
    star
    323
  • Rank 130,051 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Provides a wrapper around the API to easily query and command a Telsa car. As of now this has been used with a Model S, a Model X, and a Model 3.

tesla

wercker status

This library provides a wrapper around the API to easily query and command the a Tesla Model S remotely in Go.

Library Documentation

https://godoc.org/github.com/jsgoecke/tesla

API Documentation

View Tesla JSON API Documentation

This is unofficial documentation of the Tesla JSON API used by the iOS and Android apps. The API provides functionality to monitor and control the Model S (and future Tesla vehicles) remotely. The project provides both a documention of the API and a Go library for accessing it.

Installation

go get github.com/jsgoecke/tesla

Tokens

You may get your tokens to use as client_id and client_secret here.

Usage

Here's an example (more in the /examples project directory):

func main() {
	client, err := tesla.NewClient(
		&tesla.Auth{
			ClientID:     os.Getenv("TESLA_CLIENT_ID"),
			ClientSecret: os.Getenv("TESLA_CLIENT_SECRET"),
			Email:        os.Getenv("TESLA_USERNAME"),
			Password:     os.Getenv("TESLA_PASSWORD"),
		})
	if err != nil {
		panic(err)
	}

	vehicles, err := client.Vehicles()
	if err != nil {
		panic(err)
	}

	vehicle := vehicles[0]
	status, err := vehicle.MobileEnabled()
	if err != nil {
		panic(err)
	}

	fmt.Println(status)
	fmt.Println(vehicle.HonkHorn())

	// Autopark
	// Use with care, as this will move your car
	vehicle.AutoparkForward()
	vehicle.AutoparkReverse()
	// Use with care, as this will move your car

	// Stream vehicle events
	eventChan, errChan, err := vehicle.Stream()
	if err != nil {
		fmt.Println(err)
		return
	} else {
		for {
			select {
			case event := <-eventChan:
				eventJSON, _ := json.Marshal(event)
				fmt.Println(string(eventJSON))
			case err = <-errChan:
				fmt.Println(err)
				if err.Error() == "HTTP stream closed" {
					fmt.Println("Reconnecting!")
					eventChan, errChan, err := vehicle.Stream()
					if err != nil {
						fmt.Println(err)
						return
					}
				}
			}
		}
	}
}

Examples

Pull Requests

I appreciate all the pull requests to date, and have merged them when I can. I would kindly ask going forward if you do send a PR, please ensure it has the corresponding unit test, or unit test change, that passes. I have tried to write tests after the fact, but that is not best practice. Thank you!

Credits

Thank you to Tim Dorr who did the heavy lifting to document the Tesla API and also created the model-s-api Ruby Gem.

Copyright & License

Copyright (c) 2016-Present Jason Goecke. Released under the terms of the MIT license. See LICENSE for details.

More Repositories

1

go-wit

Go library for the Wit.ai API for Natural Language Processing
Go
41
star
2

nest

A Go library for the Nest API for Nest devices.
Go
24
star
3

lambda-go

A working example for developing Alexa Skills Kit for your Amazon Echo with AWS Lambda.
Go
18
star
4

telephony-system-tests

A test suite based on Cucumber and Cucumber-Nagios for testing and monitoring telephony systems
16
star
5

skype_utils

Adhearsion component for the Skype for Asterisk Channel
JavaScript
14
star
6

attspeech

Golang library for the AT&T Speech API
Go
14
star
7

whitepages

Ruby Library for the Whitepages API - http://www.whitepages.com
Ruby
14
star
8

skypeapi

Ruby library for using the Skype Client API
Ruby
12
star
9

event_logger

Example component for Adhearsion showing how to log events using the event subsystem 'events.rb'
Ruby
12
star
10

call-tester

Adhearsion component to generate a flood of test calls to another telephony system for testing
Ruby
12
star
11

handbrake-converter

Ruby script to process a directory of media files with a series of presets as options
Ruby
10
star
12

adhearsion-hammer

Adhearsion / Asterisk application that generates test and load calls.
Ruby
10
star
13

call_launcher

Simple scripts to launch and kill calls with Adhearsion over DRb
Ruby
9
star
14

surveys

An example Adhearsion component for creating post call surveys
JavaScript
9
star
15

annarbor_parking

An example Adhearsion component inspired by http://www.voiptechchat.com/voip/218/use-asterisk-cepstral-and-perl-to-get-parking-and-weather-updates/comment-page-1/
Ruby
9
star
16

m2x-go

Go library for AT&T's M2X API
Go
8
star
17

tvshows

Fork of TVShows project @ Sourceforge
8
star
18

asterisk-chef

Chef recipes for boostrapping Asterisk
Ruby
7
star
19

voxbone

Ruby gem for consuming the Voxbone SOAP API.
Ruby
7
star
20

ahn-xmpp-pop

Adhearsion example app showing how to build your first component
Ruby
6
star
21

sandbox_sys_scripts

System scripts for the Adhearsion Sandbox on Getting Started
6
star
22

call_branding

An Adhearsion component to perform call by call CLI branding
6
star
23

echi_files

A library that allows one to take an ASCII or Binary file from an Avaya CMS External Call History Interface (ECHI) and convert it into a Ruby hash for further processing.
Ruby
6
star
24

echi-converter

Utility for the Avaya Enhanced Call History Interface file processing - Binary decoding and insertion to a database
Ruby
5
star
25

tropo-sinatra

A Sinatra app for Tropo on JRuby / Google AppEngine
Ruby
4
star
26

rxgrid

Ruby lib for pushing jobs to an Xgrid cluster
Ruby
4
star
27

twinners_sys_scripts

System scripts for the Twinners project
Ruby
4
star
28

fonolo

Ruby Library for consuming the Fonolo web services for deep dialing
Ruby
4
star
29

Simulscribe-API

Example for consuming the Simulscribe transcription API and handling the web callback
Ruby
4
star
30

echi-file-eval

Small utility to parse a binary ECHI file from an Avaya CMS & related to the ECHI-Converter
Ruby
4
star
31

nugramserver-ruby

Ruby gem for using the NuEcho Grammar Server
Ruby
3
star
32

twinners_ivr_menu

Database driven menu system for Twinners
JavaScript
3
star
33

billwise4r

Ruby library for the Billwise SOAP/XML API
Ruby
3
star
34

bandwidth

Ruby gem for consuming the Bandwidth REST API
Ruby
3
star
35

tripit

Adhearsion Component for determing user's timezone and GMT offset based on their Tripit badge
Ruby
2
star
36

jsgoecke.github.com

My Github Page
2
star
37

node-wit

Node.js library for the Wit.ai API for Natural Language Processing
CoffeeScript
2
star
38

manincure

Ruby script used to generate all the preset info off of the Mac presets .plist for Handbrake video conversion
2
star
39

adhearsion_csharp_example

Example in C#/.Net submitted by David Laval for accessing Adhearsion's RESTful RPC API via C#
C#
1
star
40

tropo-examples

Tropo examples in Ruby
Ruby
1
star