Skip to content

maodijim/tesla-api-go

Repository files navigation

tesla-api-go

Test

This is an unofficial Go Tesla API client based on the documentation https://github.com/timdorr/tesla-api

Installation

go get github.com/maodijim/tesla-api-go

Usage

import "github.com/maodijim/tesla-api-go"
// with credential
teslaApi := tesla.NewTeslaApi(username, password, "", true)

// with refresh token
teslaApi := tesla.NewTeslaApi("", "", "eyJ...", true)

teslaApi.Login()
vehicles, err := teslaApi.ListVehicles()

teslaApi.SetActiveVehicle(vehicles[0])

teslaApi.WakeUp()
teslaApi.DoorUnlock()
teslaApi.DoorLock()
teslaApi.ChargeDoorOpen()
teslaApi.ChargeDoorClose()
teslaApi.ChargeMaxRange()
teslaApi.SetChargeLimit(50)
teslaApi.SetClimateTemp(23.5, 23.5)
teslaApi.SetSeatHeater(tesla.SeatFrontLeft, 3)
teslaApi.ActuateTrunk(tesla.FrontTrunkType)

Implemented

  • Auth
    • username & password
    • refresh token
    • MFA
  • Vehicle
  • /api/1/vehicles
  • /api/1/vehicles/{id}
  • State
    • /api/1/vehicles/{id}/vehicle_data
    • /api/1/vehicles/{id}/data_request/charge_state
    • /api/1/vehicles/{id}/data_request/climate_state
    • /api/1/vehicles/{id}/data_request/drive_state
    • /api/1/vehicles/{id}/data_request/gui_settings
    • /api/1/vehicles/{id}/data_request/vehicle_state
    • /api/1/vehicles/{id}/data_request/vehicle_config
    • /api/1/vehicles/{id}/mobile_enabled
    • /api/1/vehicles/{id}/nearby_charging_sites
  • Commands
    • Wake
      • /api/1/vehicles/{id}/wake_up
    • Alerts
      • /api/1/vehicles/{id}/command/honk_horn
      • /api/1/vehicles/{id}/command/flash_lights
    • Remote Start
      • /api/1/vehicles/{id}/command/remote_start_drive
    • Homelink
      • /api/1/vehicles/{id}/command/trigger_homelink
    • /api/1/vehicles/{id}/command/speed_limit_set_limit
      • /api/1/vehicles/{id}/command/speed_limit_set_limit
      • /api/1/vehicles/{id}/command/speed_limit_activate
      • /api/1/vehicles/{id}/command/speed_limit_deactivate
      • /api/1/vehicles/{id}/command/speed_limit_clear_pin
    • Valet Mode
      • /api/1/vehicles/{id}/command/set_valet_mode
      • /api/1/vehicles/{id}/command/reset_valet_pin
    • Sentry Mode
      • /api/1/vehicles/{id}/command/set_sentry_mode
    • Doors
      • /api/1/vehicles/{id}/command/door_unlock
      • /api/1/vehicles/{id}/command/door_lock
    • Trunk
      • /api/1/vehicles/{id}/command/actuate_trunk
    • Windows
      • /api/1/vehicles/{id}/command/window_control
    • Sunroof
      • /api/1/vehicles/{id}/command/sun_roof_control
    • Charging
      • /api/1/vehicles/{id}/command/charge_port_door_open
      • /api/1/vehicles/{id}/command/charge_port_door_close
      • /api/1/vehicles/{id}/command/charge_start
      • /api/1/vehicles/{id}/command/charge_stop
      • /api/1/vehicles/{id}/command/charge_standard
      • /api/1/vehicles/{id}/command/charge_max_range
      • /api/1/vehicles/{id}/command/set_charge_limit
      • /api/1/vehicles/{id}/command/set_charging_amps
      • /api/1/vehicles/{id}/command/set_scheduled_charging
      • /api/1/vehicles/{id}/command/set_scheduled_departure
      • api/1/vehicles/{vehicle_id}/charge_history
      • super charger history
    • Climate
      • /api/1/vehicles/{id}/command/auto_conditioning_start
      • /api/1/vehicles/{id}/command/auto_conditioning_stop
      • /api/1/vehicles/{id}/command/set_temps
      • /api/1/vehicles/{id}/command/set_preconditioning_max
      • /api/1/vehicles/{id}/command/remote_seat_heater_request
      • /api/1/vehicles/{id}/command/remote_steering_wheel_heater_request
    • Media
      • /api/1/vehicles/{id}/command/media_toggle_playback
      • /api/1/vehicles/{id}/command/media_next_track
      • /api/1/vehicles/{id}/command/media_prev_track
      • /api/1/vehicles/{id}/command/media_next_fav
      • /api/1/vehicles/{id}/command/media_prev_fav
      • /api/1/vehicles/{id}/command/media_volume_up
      • /api/1/vehicles/{id}/command/media_volume_down
    • Sharing
      • /api/1/vehicles/{id}/command/share
    • Software Updates
      • /api/1/vehicles/{id}/command/schedule_software_update
      • /api/1/vehicles/{id}/command/cancel_software_update
    • Remote Toybox
      • /api/1/vehicles/{id}/command/remote_boombox
  • Streaming
  • Autopark/Summon
  • Solar
  • Powerwall