Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ tesla Public
forked from jsgoecke/tesla

Provides a wrapper around the API to easily query and command a Telsa Model S

License

Notifications You must be signed in to change notification settings

kabaka/tesla

 
 

Repository files navigation

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
	vehicle.AutoparkForward()
	vehicle.AutoparkReverse()

	// Stream vehicle events
	eventChan, err := vehicle.Stream()
	if err != nil {
		for {
		event := <-eventChan
		if event != nil {
			eventJSON, _ := json.Marshal(event)
			fmt.Println(string(eventJSON))
		} else {
			fmt.Println("Done!")
			break
		}
	}
}

Examples

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 Jason Goecke. Released under the terms of the MIT license. See LICENSE for details.

About

Provides a wrapper around the API to easily query and command a Telsa Model S

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%