Skip to content

bogosj/go-tesla-go

Repository files navigation

go-tesla-go

A golang binary + docker image to make API calls to a Tesla vehicle.

Usage

The binary can be run from the docker image ghcr.io/bogosj/go-tesla-go.

docker run --rm ghcr.io/bogosj/go-tesla-go --spew

The binary expects two environment variables to be set:

GTG_OAUTHTOKENPATH
GTG_VIN

These can be passed in the docker command with either the -e/--env flag or --env-file.

The OAUTH variable must point to a file that consists of a single JSON dictionary generated by https://github.com/bogosj/tesla/tree/main/cmd/login. See the instructions for running this binary at https://github.com/bogosj/tesla#oauth-token.

You can also install a local copy with go get github.com/bogosj/go-tesla-go.

Flags

The flags that start "if" verify conditions before taking actions.

  -h    display this message
  -help
        display this message
  -if_battery_above int
        set to test the battery level
  -if_battery_below int
        set to test the battery level
  -if_blocked_dates string
        dates (YYYY-MM-DD) comma separated to not execute on
  -if_in_geofence
        set to test car position. must set lat/lon/miles
  -if_inside_temp_over float
        set to test the inside temp, in F
  -if_inside_temp_under float
        set to test the inside temp, in F
  -if_outside_temp_over float
        set to test the outside temp, in F
  -if_outside_temp_under float
        set to test the outside temp, in F
  -if_plugged_in
        execute commands only if the car is plugged in (default true)
  -if_speed_above float
        set to test the speed of the car
  -if_speed_below float
        set to test the speed of the car
  -lat float
        latitude of the center of the geofence
  -lon float
        longitude of the center of the geofence
  -miles float
        distance in miles of the radius of the geofence
  -set_charge_limit int
        set to an integer for the percent SOC desired
  -set_temp float
        sets the interior temperature (driver and passenger), in F
  -spew
        emit the data retrieved from the API. emits regardless of conditions
  -start_ac
        turns the A/C on
  -stop_ac
        turns the A/C off