package module
v1.3.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 22 Imported by: 21



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

Library Documentation


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 Telsa vehicles remotely. The project provides both a documention of the API and a Go library for accessing it.


go get github.com/bogosj/tesla


Examples can be found in the /examples project directory.

OAuth Token

One way to acquire an OAuth token is to run cmd/login.

# cd cmd/login

# go run . -o ~/tesla.token
✔ Username: email@gmail.com
✔ Password: ***
Passcode: 463932

This will output a token to the tesla.token file in your home directory.

Differences from jsgoecke/tesla

Streaming API

The implementation of the Streaming API is not working. The code was removed in this commit. If you are interested in getting this working again feel free to send a PR reverting these changes and providing a fix.


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

Thank you to jsgoecke from whom this project is forked.

Copyright (c) 2016-2021 Jason Goecke.

Copyright (c) 2021-present James Bogosian.

Released under the terms of the MIT license. See LICENSE for details.




This section is empty.


View Source
var OAuth2Config = &oauth2.Config{
	ClientID:    "ownerapi",
	RedirectURL: "https://auth.tesla.com/void/callback",
	Endpoint: oauth2.Endpoint{
		AuthURL:   "https://auth.tesla.com/en_us/oauth2/v3/authorize",
		TokenURL:  "https://auth.tesla.com/oauth2/v3/token",
		AuthStyle: oauth2.AuthStyleInParams,
	Scopes: []string{"openid", "email", "offline_access"},

OAuth2Config is the OAuth2 configuration for authenticating with the Tesla API.


This section is empty.


type AutoParkRequest

type AutoParkRequest struct {
	VehicleID uint64  `json:"vehicle_id,omitempty"`
	Lat       float64 `json:"lat"`
	Lon       float64 `json:"lon"`
	Action    string  `json:"action,omitempty"`

AutoParkRequest are the required elements to POST an Autopark/Summon request for the vehicle.

type ChargeState

type ChargeState struct {
	Timestamp                   timeMsec    `json:"timestamp"`
	ChargingState               string      `json:"charging_state"`
	ChargeLimitSoc              int         `json:"charge_limit_soc"`
	ChargeLimitSocStd           int         `json:"charge_limit_soc_std"`
	ChargeLimitSocMin           int         `json:"charge_limit_soc_min"`
	ChargeLimitSocMax           int         `json:"charge_limit_soc_max"`
	ChargeToMaxRange            bool        `json:"charge_to_max_range"`
	BatteryHeaterOn             bool        `json:"battery_heater_on"`
	NotEnoughPowerToHeat        bool        `json:"not_enough_power_to_heat"`
	MaxRangeChargeCounter       int         `json:"max_range_charge_counter"`
	FastChargerPresent          bool        `json:"fast_charger_present"`
	FastChargerType             string      `json:"fast_charger_type"`
	BatteryRange                float64     `json:"battery_range"`
	EstBatteryRange             float64     `json:"est_battery_range"`
	IdealBatteryRange           float64     `json:"ideal_battery_range"`
	BatteryLevel                int         `json:"battery_level"`
	UsableBatteryLevel          int         `json:"usable_battery_level"`
	ChargeEnergyAdded           float64     `json:"charge_energy_added"`
	ChargeMilesAddedRated       float64     `json:"charge_miles_added_rated"`
	ChargeMilesAddedIdeal       float64     `json:"charge_miles_added_ideal"`
	ChargerVoltage              int         `json:"charger_voltage"`
	ChargerPilotCurrent         int         `json:"charger_pilot_current"`
	ChargerActualCurrent        int         `json:"charger_actual_current"`
	ChargerPower                int         `json:"charger_power"`
	TimeToFullCharge            float64     `json:"time_to_full_charge"`
	TripCharging                bool        `json:"trip_charging"`
	ChargeRate                  float64     `json:"charge_rate"`
	ChargePortDoorOpen          bool        `json:"charge_port_door_open"`
	MotorizedChargePort         bool        `json:"motorized_charge_port"`
	ScheduledChargingMode       string      `json:"scheduled_charging_mode"`
	ScheduledDepatureTime       interface{} `json:"scheduled_departure_time"`
	ScheduledChargingStartTime  interface{} `json:"scheduled_charging_start_time"`
	ScheduledChargingPending    bool        `json:"scheduled_charging_pending"`
	UserChargeEnableRequest     interface{} `json:"user_charge_enable_request"`
	ChargeEnableRequest         bool        `json:"charge_enable_request"`
	EuVehicle                   bool        `json:"eu_vehicle"`
	ChargerPhases               int         `json:"charger_phases"`
	ChargePortLatch             string      `json:"charge_port_latch"`
	ChargeCurrentRequest        int         `json:"charge_current_request"`
	ChargeCurrentRequestMax     int         `json:"charge_current_request_max"`
	ChargeAmps                  int         `json:"charge_amps"`
	OffPeakChargingEnabled      bool        `json:"off_peak_charging_enabled"`
	OffPeakChargingTimes        string      `json:"off_peak_charging_times"`
	OffPeakHoursEndTime         int         `json:"off_peak_hours_end_time"`
	PreconditioningEnabled      bool        `json:"preconditioning_enabled"`
	PreconditioningTimes        string      `json:"preconditioning_times"`
	ManagedChargingActive       bool        `json:"managed_charging_active"`
	ManagedChargingUserCanceled bool        `json:"managed_charging_user_canceled"`
	ManagedChargingStartTime    interface{} `json:"managed_charging_start_time"`
	ChargePortcoldWeatherMode   bool        `json:"charge_port_cold_weather_mode"`
	ConnChargeCable             string      `json:"conn_charge_cable"`
	FastChargerBrand            string      `json:"fast_charger_brand"`
	MinutesToFullCharge         int         `json:"minutes_to_full_charge"`

ChargeState contains the current charge states that exist within the vehicle.

type Client

type Client struct {
	// contains filtered or unexported fields

Client provides the client and associated elements for interacting with the Tesla API.

func NewClient

func NewClient(ctx context.Context, options ...ClientOption) (*Client, error)

NewClient creates a new Tesla API client. You must provided one of WithToken or WithTokenFile functional options to initialize the client with an OAuth token.

func (*Client) EnergySite added in v1.2.0

func (c *Client) EnergySite(productID int64) (*EnergySite, error)

return fetches the energy site for the given product ID

func (*Client) Products added in v1.2.0

func (c *Client) Products() ([]*Product, error)

Products fetches the products associated to a Tesla account via the API.

func (Client) Token

func (c Client) Token() (*oauth2.Token, error)

Token returns the oauth token

func (*Client) Vehicle

func (c *Client) Vehicle(vehicleID int64) (*Vehicle, error)

Vehicle fetches the vehicle by ID associated to a Tesla account via the API.

func (*Client) Vehicles

func (c *Client) Vehicles() ([]*Vehicle, error)

Vehicles fetches the vehicles associated to a Tesla account via the API.

type ClientOption

type ClientOption func(c *Client) error

ClientOption can be passed when creating the client

func WithBaseURL

func WithBaseURL(url string) ClientOption

WithBaseURL provides a method to set the base URL for standard API calls to differ from the default.

func WithCaptchaHandler added in v1.0.1

func WithCaptchaHandler(handler func(context.Context, io.Reader) (string, error)) ClientOption

WithCaptchaHandler allows a consumer to provide a different configuration from the default.

func WithCredentials

func WithCredentials(username, password string) ClientOption

WithCredentials allows a consumer to provide a different configuration from the default.

func WithMFAHandler

func WithMFAHandler(handler func(context.Context, []Device) (Device, string, error)) ClientOption

WithMFAHandler allows a consumer to provide a different configuration from the default.

func WithOAuth2Config

func WithOAuth2Config(oc *oauth2.Config) ClientOption

WithOAuth2Config allows a consumer to provide a different configuration from the default.

func WithStreamingURL

func WithStreamingURL(url string) ClientOption

WithStreamingURL provides a method to set the base URL for streaming API calls to differ from the default.

func WithToken

func WithToken(t *oauth2.Token) ClientOption

WithToken provides an oauth2.Token to the client for auth.

func WithTokenFile

func WithTokenFile(path string) ClientOption

WithTokenFile reads a JSON serialized oauth2.Token struct from disk and provides it to the client for auth.

type ClimateState

type ClimateState struct {
	Timestamp                  timeMsec    `json:"timestamp"`
	InsideTemp                 float64     `json:"inside_temp"`
	OutsideTemp                float64     `json:"outside_temp"`
	DriverTempSetting          float64     `json:"driver_temp_setting"`
	PassengerTempSetting       float64     `json:"passenger_temp_setting"`
	LeftTempDirection          float64     `json:"left_temp_direction"`
	RightTempDirection         float64     `json:"right_temp_direction"`
	IsAutoConditioningOn       bool        `json:"is_auto_conditioning_on"`
	IsFrontDefrosterOn         bool        `json:"is_front_defroster_on"`
	IsRearDefrosterOn          bool        `json:"is_rear_defroster_on"`
	FanStatus                  interface{} `json:"fan_status"`
	IsClimateOn                bool        `json:"is_climate_on"`
	MinAvailTemp               float64     `json:"min_avail_temp"`
	MaxAvailTemp               float64     `json:"max_avail_temp"`
	SeatHeaterLeft             int         `json:"seat_heater_left"`
	SeatHeaterRight            int         `json:"seat_heater_right"`
	SeatHeaterRearLeft         int         `json:"seat_heater_rear_left"`
	SeatHeaterRearRight        int         `json:"seat_heater_rear_right"`
	SeatHeaterRearCenter       int         `json:"seat_heater_rear_center"`
	SeatHeaterRearRightBack    int         `json:"seat_heater_rear_right_back"`
	SeatHeaterRearLeftBack     int         `json:"seat_heater_rear_left_back"`
	SmartPreconditioning       bool        `json:"smart_preconditioning"`
	BatteryHeater              bool        `json:"battery_heater"`
	BatteryHeaterNoPower       interface{} `json:"battery_heater_no_power"`
	ClimateKeeperMode          string      `json:"climate_keeper_mode"`
	DefrostMode                int         `json:"defrost_mode"`
	IsPreconditioning          bool        `json:"is_preconditioning"`
	RemoteHeaterControlEnabled bool        `json:"remote_heater_control_enabled"`
	SideMirrorHeaters          bool        `json:"side_mirror_heaters"`
	WiperBladeHeater           bool        `json:"wiper_blade_heater"`

ClimateState contains the current climate states availale from the vehicle.

type CommandResponse

type CommandResponse struct {
	Response struct {
		Reason string `json:"reason"`
		Result bool   `json:"result"`
	} `json:"response"`

CommandResponse is the response from the Tesla API after POSTing a command.

type Device

type Device struct {
	DispatchRequired bool      `json:"dispatchRequired"`
	ID               string    `json:"id"`
	Name             string    `json:"name"`
	FactorType       string    `json:"factorType"`
	FactorProvider   string    `json:"factorProvider"`
	SecurityLevel    int       `json:"securityLevel"`
	Activated        time.Time `json:"activatedAt"`
	Updated          time.Time `json:"updatedAt"`

Device is the multi-factor device returned by the /authorize/mfa/factors endpoint

type DriveState

type DriveState struct {
	Timestamp               timeMsec    `json:"timestamp"`
	ShiftState              interface{} `json:"shift_state"`
	Speed                   float64     `json:"speed"`
	Latitude                float64     `json:"latitude"`
	Longitude               float64     `json:"longitude"`
	ActiveRouteLatitude     float64     `json:"active_route_latitude"`
	ActiveRouteLongitude    float64     `json:"active_route_longitude"`
	Heading                 int         `json:"heading"`
	GpsAsOf                 int64       `json:"gps_as_of"`
	NativeLatitude          float64     `json:"native_latitude"`
	NativeLocationSupported int         `json:"native_location_supported"`
	NativeLongitude         float64     `json:"native_longitude"`
	NativeType              string      `json:"native_type"`
	Power                   int         `json:"power"`

DriveState contains the current drive state of the vehicle.

type EnergySite added in v1.2.0

type EnergySite struct {
	ID                   string `json:"id"`
	SiteName             string `json:"site_name"`
	BackupReservePercent int64  `json:"backup_reserve_percent,omitempty"`
	DefaultRealMode      string `json:"default_real_mode,omitempty"`
	// contains filtered or unexported fields

this represents site_info endpoint

func (*EnergySite) EnergySiteHistory added in v1.2.1

func (s *EnergySite) EnergySiteHistory(period HistoryPeriod) (*EnergySiteHistory, error)

func (*EnergySite) EnergySiteStatus added in v1.2.0

func (s *EnergySite) EnergySiteStatus() (*EnergySiteStatus, error)

func (*EnergySite) SetBatteryReserve added in v1.2.0

func (s *EnergySite) SetBatteryReserve(percent uint64) error

type EnergySiteHistory added in v1.2.1

type EnergySiteHistory struct {
	SerialNumber string                        `json:"serial_number"`
	Period       string                        `json:"period"`
	TimeSeries   []EnergySiteHistoryTimeSeries `json:"time_series"`
	// contains filtered or unexported fields

type EnergySiteHistoryTimeSeries added in v1.2.1

type EnergySiteHistoryTimeSeries struct {
	Timestamp                           time.Time `json:"timestamp"`
	SolarEnergyExported                 float64   `json:"solar_energy_exported"`
	GeneratorEnergyExported             float64   `json:"generator_energy_exported"`
	GridEnergyImported                  float64   `json:"grid_energy_imported"`
	GridServicesEnergyImported          float64   `json:"grid_services_energy_imported"`
	GridServicesEnergyExported          float64   `json:"grid_services_energy_exported"`
	GridEnergyExportedFromSolar         float64   `json:"grid_energy_exported_from_solar"`
	GridEnergyExportedFromGenerator     float64   `json:"grid_energy_exported_from_generator"`
	GridEnergyExportedFromBattery       float64   `json:"grid_energy_exported_from_battery"`
	BatteryEnergyExported               float64   `json:"battery_energy_exported"`
	BatteryEnergyImportedFromGrid       float64   `json:"battery_energy_imported_from_grid"`
	BatteryEnergyImportedFromSolar      float64   `json:"battery_energy_imported_from_solar"`
	BatteryEnergyImportedFromGenerator  float64   `json:"battery_energy_imported_from_generator"`
	ConsumerEnergyImportedFromGrid      float64   `json:"consumer_energy_imported_from_grid"`
	ConsumerEnergyImportedFromSolar     float64   `json:"consumer_energy_imported_from_solar"`
	ConsumerEnergyImportedFromBattery   float64   `json:"consumer_energy_imported_from_battery"`
	ConsumerEnergyImportedFromGenerator float64   `json:"consumer_energy_imported_from_generator"`

type EnergySiteStatus added in v1.2.0

type EnergySiteStatus struct {
	ResourceType      string  `json:"resource_type"`
	SiteName          string  `json:"site_name"`
	GatewayId         string  `json:"gateway_id"`
	EnergyLeft        float64 `json:"energy_left"`
	TotalPackEnergy   uint64  `json:"total_pack_energy"`
	PercentageCharged float64 `json:"percentage_charged"`
	BatteryType       string  `json:"battery_type"`
	BackupCapable     bool    `json:"backup_capable"`
	BatteryPower      int64   `json:"battery_power"`
	// contains filtered or unexported fields

type GuiSettings

type GuiSettings struct {
	Timestamp           timeMsec `json:"timestamp"`
	GuiDistanceUnits    string   `json:"gui_distance_units"`
	GuiTemperatureUnits string   `json:"gui_temperature_units"`
	GuiChargeRateUnits  string   `json:"gui_charge_rate_units"`
	Gui24HourTime       bool     `json:"gui_24_hour_time"`
	GuiRangeDisplay     string   `json:"gui_range_display"`
	ShowRangeUnits      bool     `json:"show_range_units"`

GuiSettings contains the current GUI settings of the vehicle.

type HistoryPeriod added in v1.2.1

type HistoryPeriod string
const (
	HistoryPeriodDay   HistoryPeriod = "day"
	HistoryPeriodWeek  HistoryPeriod = "week"
	HistoryPeriodMonth HistoryPeriod = "month"
	HistoryPeriodYear  HistoryPeriod = "year"

type Identifier added in v1.3.1

type Identifier string

func (*Identifier) UnmarshalJSON added in v1.3.1

func (i *Identifier) UnmarshalJSON(data []byte) error

type MFAData added in v1.1.1

type MFAData struct {
	Id          string `json:"id"`
	ChallengeId string `json:"challengeId"`
	FactorId    string `json:"factorId"`
	PassCode    string `json:"passCode"`
	Approved    bool   `json:"approved"`
	Flagged     bool   `json:"flagged"`
	Valid       bool   `json:"valid"`
	CreatedAt   string `json:"createdAt"`
	UpdatedAt   string `json:"updatedAt"`

type MFAVerify added in v1.1.1

type MFAVerify struct {
	Data MFAData `json:"data"`

type MobileEnabledResponse

type MobileEnabledResponse struct {
	Bool bool `json:"response"`

MobileEnabledResponse is the response when a state is requested.

type NearbyChargingSitesResponse

type NearbyChargingSitesResponse struct {
	Response struct {
		CongestionSyncTimeUtcSecs timeSecs `json:"congestion_sync_time_utc_secs"`
		DestinationCharging       []struct {
			Location struct {
				Lat  float64 `json:"lat"`
				Long float64 `json:"long"`
			} `json:"location"`
			Name          string  `json:"name"`
			Type          string  `json:"type"`
			DistanceMiles float64 `json:"distance_miles"`
		} `json:"destination_charging"`
		Superchargers []struct {
			Location struct {
				Lat  float64 `json:"lat"`
				Long float64 `json:"long"`
			} `json:"location"`
			Name            string  `json:"name"`
			Type            string  `json:"type"`
			DistanceMiles   float64 `json:"distance_miles"`
			AvailableStalls int     `json:"available_stalls"`
			TotalStalls     int     `json:"total_stalls"`
			SiteClosed      bool    `json:"site_closed"`
		} `json:"superchargers"`
		Timestamp timeMsec `json:"timestamp"`
	} `json:"response"`

NearbyChargingSitesResponse represents the charging sites returned from the API.

type Product added in v1.2.0

type Product struct {
	EnergySiteId      int64      `json:"energy_site_id,omitempty"`
	ResourceType      string     `json:"resource_type"`
	ID                Identifier `json:"id"`
	AssetSiteId       string     `json:"asset_site_id,omitempty"`
	GatewayId         string     `json:"gateway_id,omitempty"`
	WarpSiteNumber    string     `json:"warp_site_number,omitempty"`
	EnergyLeft        float64    `json:"energy_left,omitempty"`
	TotalPackEnergy   uint64     `json:"total_pack_energy,omitempty"`
	PercentageCharged float64    `json:"percentage_charged,omitempty"`
	BatteryType       string     `json:"battery_type,omitempty"`
	BackupCapable     bool       `json:"backup_capable,omitempty"`
	BatteryPower      int64      `json:"battery_power,omitempty"`
	// contains filtered or unexported fields

type ProductsResponse added in v1.2.0

type ProductsResponse struct {
	Response []*Product `json:"response"`
	Count    int        `json:"count"`

ProductResponse contains the product details from the Tesla API.

type SentryData

type SentryData struct {
	Mode string `json:"on"`

SentryData shows whether Sentry is on.

type ServiceData

type ServiceData struct {
	Timestamp     timeMsec  `json:"timestamp"`
	ServiceETC    time.Time `json:"service_etc"`
	ServiceStatus string    `json:"service_status"`

ServiceData contains the service data of the vehicle.

type SiteCommandResponse added in v1.2.0

type SiteCommandResponse struct {
	Response struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"response"`

SiteCommandResponse is the response from the Tesla API after POSTing a command.

type SiteHistoryResponse added in v1.2.1

type SiteHistoryResponse struct {
	Response *EnergySiteHistory `json:"response"`

type SiteInfoResponse added in v1.2.0

type SiteInfoResponse struct {
	Response *EnergySite `json:"response"`

type SiteStatusResponse added in v1.2.1

type SiteStatusResponse struct {
	Response *EnergySiteStatus `json:"response"`

type Transport

type Transport struct {
	// contains filtered or unexported fields

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

type Vehicle

type Vehicle struct {
	Color                  interface{} `json:"color"`
	DisplayName            string      `json:"display_name"`
	ID                     int64       `json:"id"`
	OptionCodes            string      `json:"option_codes"`
	VehicleID              uint64      `json:"vehicle_id"`
	Vin                    string      `json:"vin"`
	Tokens                 []string    `json:"tokens"`
	State                  string      `json:"state"`
	IDS                    string      `json:"id_s"`
	RemoteStartEnabled     bool        `json:"remote_start_enabled"`
	CalendarEnabled        bool        `json:"calendar_enabled"`
	NotificationsEnabled   bool        `json:"notifications_enabled"`
	BackseatToken          interface{} `json:"backseat_token"`
	BackseatTokenUpdatedAt interface{} `json:"backseat_token_updated_at"`
	AccessType             string      `json:"access_type"`
	InService              bool        `json:"in_service"`
	APIVersion             int         `json:"api_version"`
	CommandSigning         string      `json:"command_signing"`
	// contains filtered or unexported fields

Vehicle represents the vehicle as returned from the Tesla API.

func (*Vehicle) AutoparkAbort

func (v *Vehicle) AutoparkAbort() error

AutoparkAbort causes the vehicle to abort the Autopark request.

func (*Vehicle) AutoparkForward

func (v *Vehicle) AutoparkForward() error

AutoparkForward causes the vehicle to pull forward.

func (*Vehicle) AutoparkReverse

func (v *Vehicle) AutoparkReverse() error

AutoparkReverse causes the vehicle to go in reverse.

func (Vehicle) Data

func (v Vehicle) Data() (*VehicleData, error)

Data : Get data of the vehicle (calling this will not permit the car to sleep)

func (*Vehicle) EnableSentry

func (v *Vehicle) EnableSentry() error

EnableSentry enables Sentry Mode

func (*Vehicle) FlashLights

func (v *Vehicle) FlashLights() error

FlashLights flashes the lights of the vehicle.

func (*Vehicle) HonkHorn

func (v *Vehicle) HonkHorn() error

HonkHorn honks the horn of the vehicle.

func (*Vehicle) LockDoors

func (v *Vehicle) LockDoors() error

LockDoors locks the doors of the vehicle.

func (*Vehicle) MobileEnabled

func (v *Vehicle) MobileEnabled() (bool, error)

MobileEnabled returns if the vehicle is mobile enabled for Tesla API control

func (*Vehicle) MovePanoRoof

func (v *Vehicle) MovePanoRoof(state string, percent int) error

MovePanoRoof sets the desired state of the panoramic roof. The approximate percent open values for each state are open = 100%, close = 0%, comfort = 80%, vent = %15, move = set %.

func (*Vehicle) NearbyChargingSites

func (v *Vehicle) NearbyChargingSites() (*NearbyChargingSitesResponse, error)

NearbyChargingSites returns the charging sites near the vehicle.

func (*Vehicle) OpenChargePort

func (v *Vehicle) OpenChargePort() error

OpenChargePort opens the charge port so you may insert your charging cable.

func (*Vehicle) OpenTrunk

func (v *Vehicle) OpenTrunk(trunk string) error

OpenTrunk opens the trunk, where values may be 'front' or 'rear'.

func (*Vehicle) ResetValetPIN

func (v *Vehicle) ResetValetPIN() error

ResetValetPIN resets the PIN set for valet mode, if set.

func (*Vehicle) SetChargeLimit

func (v *Vehicle) SetChargeLimit(percent int) error

SetChargeLimit set the charge limit to a custom percentage.

func (*Vehicle) SetChargeLimitMax

func (v *Vehicle) SetChargeLimitMax() error

SetChargeLimitMax sets the charge limit to the max limit.

func (*Vehicle) SetChargeLimitStandard

func (v *Vehicle) SetChargeLimitStandard() error

SetChargeLimitStandard sets the charge limit to the standard setting.

func (*Vehicle) SetChargingAmps added in v1.1.0

func (v *Vehicle) SetChargingAmps(amps int) error

SetChargingAmps set the charging amps to a specific value.

func (*Vehicle) SetSeatHeater

func (v *Vehicle) SetSeatHeater(heater int, level int) error

SetSeatHeater sets the specified seat's heater level.

func (*Vehicle) SetSteeringWheelHeater

func (v *Vehicle) SetSteeringWheelHeater(on bool) error

SetSteeringWheelHeater turns steering wheel heater on or off.

func (*Vehicle) SetTemperature

func (v *Vehicle) SetTemperature(driver float64, passenger float64) error

SetTemperature sets the temperature of the vehicle, where you may set the driver zone and the passenger zone to separate temperatures.

func (*Vehicle) Start

func (v *Vehicle) Start(password string) error

Start starts the car by turning it on, requires the password to be sent again.

func (*Vehicle) StartAirConditioning

func (v *Vehicle) StartAirConditioning() error

StartAirConditioning starts the air conditioning in the vehicle.

func (*Vehicle) StartCharging

func (v *Vehicle) StartCharging() error

StartCharging starts the charging of the vehicle after you have inserted the charging cable.

func (*Vehicle) StopAirConditioning

func (v *Vehicle) StopAirConditioning() error

StopAirConditioning stops the air conditioning in the vehicle.

func (*Vehicle) StopCharging

func (v *Vehicle) StopCharging() error

StopCharging stops the charging of the vehicle.

func (v *Vehicle) TriggerHomelink() error

TriggerHomelink opens and closes the configured Homelink garage door of the vehicle keep in mind this is a toggle and the garage door state is unknown a major limitation of Homelink.

func (*Vehicle) UnlockDoors

func (v *Vehicle) UnlockDoors() error

UnlockDoors unlock the vehicle's doors.

func (*Vehicle) Wakeup

func (v *Vehicle) Wakeup() (*Vehicle, error)

Wakeup wakes up the vehicle when it is powered off.

func (*Vehicle) WindowControl added in v1.0.2

func (v *Vehicle) WindowControl(command string, lat, lon float64) error

Controls the windows. Will vent or close all windows simultaneously. command can be "vent" or "close". lat and lon values must be near the current location of the car for close operation to succeed. For vent, the lat and lon values are ignored, and may both be 0 (which has been observed from the app itself).

type VehicleConfig

type VehicleConfig struct {
	CanAcceptNavigationRequests bool     `json:"can_accept_navigation_requests"`
	CanActuateTrunks            bool     `json:"can_actuate_trunks"`
	CarSpecialType              string   `json:"car_special_type"`
	CarType                     string   `json:"car_type"`
	ChargePortType              string   `json:"charge_port_type"`
	DefaultChargeToMax          bool     `json:"default_charge_to_max"`
	DriverAssist                string   `json:"driver_assist"`
	EceRestrictions             bool     `json:"ece_restrictions"`
	EfficiencyPackage           string   `json:"efficiency_package"`
	EUVehicle                   bool     `json:"eu_vehicle"`
	ExteriorColor               string   `json:"exterior_color"`
	ExteriorTrim                string   `json:"exterior_trim"`
	HasAirSuspension            bool     `json:"has_air_suspension"`
	HasLudicrousMode            bool     `json:"has_ludicrous_mode"`
	InteriorTrimType            string   `json:"interior_trim_type"`
	KeyVersion                  int      `json:"key_version"`
	MotorizedChargePort         bool     `json:"motorized_charge_port"`
	PerformancePackage          string   `json:"performance_package"`
	Plg                         bool     `json:"plg"`
	RearDriveUnit               string   `json:"rear_drive_unit"`
	RearSeatHeaters             int      `json:"rear_seat_heaters"`
	RearSeatType                int      `json:"rear_seat_type"`
	Rhd                         bool     `json:"rhd"`
	RoofColor                   string   `json:"roof_color"`
	SeatType                    int      `json:"seat_type"`
	SpoilerType                 string   `json:"spoiler_type"`
	SunRoofInstalled            int      `json:"sun_roof_installed"`
	ThirdRowSeats               string   `json:"third_row_seats"`
	Timestamp                   timeMsec `json:"timestamp"`
	TrimBadging                 string   `json:"trim_badging"`
	UseRangeBadging             bool     `json:"use_range_badging"`
	WheelType                   string   `json:"wheel_type"`

VehicleConfig represents the configuration of a vehicle.

type VehicleData added in v1.1.1

type VehicleData struct {
	Response struct {
		ChargeState   ChargeState   `json:"charge_state"`
		ClimateState  ClimateState  `json:"climate_state"`
		DriveState    DriveState    `json:"drive_state"`
		VehicleState  VehicleState  `json:"vehicle_state"`
		GuiSettings   GuiSettings   `json:"gui_settings"`
		VehicleConfig VehicleConfig `json:"vehicle_config"`
	} `json:"response"`
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`

VehicleData represents the states of the vehicle.

type VehiclePartialResponse added in v1.1.1

type VehiclePartialResponse struct {
	Color                  interface{} `json:"color"`
	DisplayName            string      `json:"display_name"`
	ID                     int64       `json:"id"`
	OptionCodes            string      `json:"option_codes"`
	VehicleID              uint64      `json:"vehicle_id"`
	Vin                    string      `json:"vin"`
	Tokens                 []string    `json:"tokens"`
	State                  string      `json:"state"`
	IDS                    string      `json:"id_s"`
	RemoteStartEnabled     bool        `json:"remote_start_enabled"`
	CalendarEnabled        bool        `json:"calendar_enabled"`
	NotificationsEnabled   bool        `json:"notifications_enabled"`
	BackseatToken          interface{} `json:"backseat_token"`
	BackseatTokenUpdatedAt interface{} `json:"backseat_token_updated_at"`
	AccessType             string      `json:"access_type"`
	InService              bool        `json:"in_service"`
	APIVersion             int         `json:"api_version"`
	CommandSigning         string      `json:"command_signing"`

VehiclePartialResponse represents the vehicle response root data as returned from the Tesla API.

type VehicleResponse

type VehicleResponse struct {
	Response *Vehicle `json:"response"`
	Count    int      `json:"count"`

VehicleResponse contains the vehicle details from the Tesla API.

type VehicleState

type VehicleState struct {
	Timestamp               timeMsec `json:"timestamp"`
	APIVersion              int      `json:"api_version"`
	AutoParkState           string   `json:"autopark_state"`
	AutoParkStateV2         string   `json:"autopark_state_v2"`
	AutoParkStateV3         string   `json:"autopark_state_v3"`
	CalendarSupported       bool     `json:"calendar_supported"`
	CarType                 string   `json:"car_type"`
	CarVersion              string   `json:"car_version"`
	CenterDisplayState      int      `json:"center_display_state"`
	DarkRims                bool     `json:"dark_rims"`
	DriverFrontDoor         int      `json:"df"`
	DriverRearDoor          int      `json:"dr"`
	ExteriorColor           string   `json:"exterior_color"`
	FrontTrunk              int      `json:"ft"`
	HasSpoiler              bool     `json:"has_spoiler"`
	Locked                  bool     `json:"locked"`
	NotificationsSupported  bool     `json:"notifications_supported"`
	Odometer                float64  `json:"odometer"`
	ParsedCalendarSupported bool     `json:"parsed_calendar_supported"`
	PerfConfig              string   `json:"perf_config"`
	PassengerFrontDoor      int      `json:"pf"`
	PassengerRearDoor       int      `json:"pr"`
	RearSeatHeaters         int      `json:"rear_seat_heaters"`
	RemoteStart             bool     `json:"remote_start"`
	RemoteStartSupported    bool     `json:"remote_start_supported"`
	RightHandDrive          bool     `json:"rhd"`
	RoofColor               string   `json:"roof_color"`
	RearTrunk               int      `json:"rt"`
	SentryMode              bool     `json:"sentry_mode"`
	SentryModeAvailable     bool     `json:"sentry_mode_available"`
	SeatType                int      `json:"seat_type"`
	SpoilerType             string   `json:"spoiler_type"`
	SunRoofInstalled        int      `json:"sun_roof_installed"`
	SunRoofPercentOpen      int      `json:"sun_roof_percent_open"`
	SunRoofState            string   `json:"sun_roof_state"`
	ThirdRowSeats           string   `json:"third_row_seats"`
	ValetMode               bool     `json:"valet_mode"`
	VehicleName             string   `json:"vehicle_name"`
	WheelType               string   `json:"wheel_type"`
	FrontDriverWindow       int      `json:"fd_window"`
	FrontPassengerWindow    int      `json:"fp_window"`
	RearDriverWindow        int      `json:"rd_window"`
	RearPassengerWindow     int      `json:"rp_window"`
	IsUserPresent           bool     `json:"is_user_present"`
	RemoteStartEnabled      bool     `json:"remote_start_enabled"`
	ValetPinNeeded          bool     `json:"valet_pin_needed"`
	MediaState              struct {
		RemoteControlEnabled bool `json:"remote_control_enabled"`
	} `json:"media_state"`
	SoftwareUpdate struct {
		DownloadPerc        int    `json:"download_perc"`
		ExpectedDurationSec int    `json:"expected_duration_sec"`
		InstallPerc         int    `json:"install_perc"`
		Status              string `json:"status"`
		Version             string `json:"version"`
	} `json:"software_update" `
	SpeedLimitMode struct {
		Active          bool    `json:"active"`
		CurrentLimitMph float64 `json:"current_limit_mph"`
		MaxLimitMph     float64 `json:"max_limit_mph"`
		MinLimitMph     float64 `json:"min_limit_mph"`
		PinCodeSet      bool    `json:"pin_code_set"`
	} `json:"speed_limit_mode"`

VehicleState contains the current state of the vehicle.

type VehiclesResponse

type VehiclesResponse struct {
	Response []*Vehicle `json:"response"`
	Count    int        `json:"count"`

VehiclesResponse contains a slice of Vehicles from the Tesla API.


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL