forked from bogosj/tesla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_car.go
63 lines (56 loc) · 1.7 KB
/
manage_car.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"context"
"fmt"
"os"
"github.com/bogosj/tesla"
)
func main() {
ctx := context.Background()
client, err := tesla.NewClient(ctx, tesla.WithTokenFile("/file/path/to/token.json"))
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.ChargeState())
fmt.Println(vehicle.ClimateState())
fmt.Println(vehicle.DriveState())
fmt.Println(vehicle.GuiSettings())
fmt.Println(vehicle.VehicleState())
fmt.Println(vehicle.HonkHorn())
fmt.Println(vehicle.FlashLights())
fmt.Println(vehicle.Wakeup())
fmt.Println(vehicle.OpenChargePort())
fmt.Println(vehicle.ResetValetPIN())
fmt.Println(vehicle.SetChargeLimitStandard())
fmt.Println(vehicle.SetChargeLimit(50))
fmt.Println(vehicle.StartCharging())
fmt.Println(vehicle.StopCharging())
fmt.Println(vehicle.SetChargeLimitMax())
fmt.Println(vehicle.StartAirConditioning())
fmt.Println(vehicle.StopAirConditioning())
fmt.Println(vehicle.UnlockDoors())
fmt.Println(vehicle.LockDoors())
fmt.Println(vehicle.SetTemperature(72.0, 72.0))
fmt.Println(vehicle.Start(os.Getenv("TESLA_PASSWORD")))
fmt.Println(vehicle.OpenTrunk("rear"))
fmt.Println(vehicle.OpenTrunk("front"))
fmt.Println(vehicle.MovePanoRoof("vent", 0))
fmt.Println(vehicle.MovePanoRoof("open", 0))
fmt.Println(vehicle.MovePanoRoof("move", 50))
fmt.Println(vehicle.MovePanoRoof("close", 0))
fmt.Println(vehicle.TriggerHomelink())
// // Take care with these, as the car will move
fmt.Println(vehicle.AutoparkForward())
fmt.Println(vehicle.AutoparkReverse())
// Take care with these, as the car will move
}