tesla_api 3.0.0 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/docs/README.md +1 -1
  3. data/docs/SUMMARY.md +35 -34
  4. data/docs/api-basics/vehicles.md +5 -6
  5. data/docs/miscellaneous/endpoints.md +29 -4
  6. data/docs/vehicle/commands/README.md +11 -3
  7. data/docs/vehicle/commands/climate.md +21 -0
  8. data/docs/vehicle/commands/homelink.md +21 -0
  9. data/docs/vehicle/commands/sharing.md +38 -0
  10. data/docs/vehicle/commands/valet.md +7 -5
  11. data/docs/vehicle/commands/wake.md +4 -1
  12. data/docs/vehicle/commands/windows.md +26 -0
  13. data/docs/vehicle/optioncodes.md +22 -6
  14. data/docs/vehicle/state/chargestate.md +1 -0
  15. data/docs/vehicle/state/climatestate.md +1 -1
  16. data/docs/vehicle/state/data.md +27 -7
  17. data/docs/vehicle/state/guisettings.md +1 -0
  18. data/docs/vehicle/state/vehiclestate.md +46 -15
  19. data/lib/tesla_api.rb +4 -2
  20. data/lib/tesla_api/autopark.rb +23 -41
  21. data/lib/tesla_api/client.rb +14 -7
  22. data/lib/tesla_api/stream.rb +40 -34
  23. data/lib/tesla_api/vehicle.rb +49 -1
  24. data/lib/tesla_api/version.rb +1 -1
  25. data/spec/cassettes/client-login_timeout.yml +83 -0
  26. data/spec/cassettes/vehicle-media_next_fav.yml +109 -0
  27. data/spec/cassettes/vehicle-media_next_track.yml +109 -0
  28. data/spec/cassettes/vehicle-media_prev_fav.yml +109 -0
  29. data/spec/cassettes/vehicle-media_prev_track.yml +109 -0
  30. data/spec/cassettes/vehicle-media_toggle_playback.yml +109 -0
  31. data/spec/cassettes/vehicle-media_volume_down.yml +109 -0
  32. data/spec/cassettes/vehicle-media_volume_up.yml +109 -0
  33. data/spec/cassettes/vehicle-vehicle_config.yml +108 -0
  34. data/spec/lib/tesla_api/client_spec.rb +30 -0
  35. data/spec/lib/tesla_api/vehicle_spec.rb +57 -0
  36. data/tesla_api.gemspec +1 -1
  37. metadata +30 -10
  38. data/docs/vehicle/commands/navigation.md +0 -36
@@ -59,6 +59,10 @@ module TeslaApi
59
59
  data_request('vehicle_state')['response']
60
60
  end
61
61
 
62
+ def vehicle_config
63
+ data_request('vehicle_config')['response']
64
+ end
65
+
62
66
  # Commands
63
67
 
64
68
  def wake_up
@@ -90,7 +94,7 @@ module TeslaApi
90
94
  end
91
95
 
92
96
  def set_charge_limit(percent)
93
- command('set_charge_limit', body: {percent: percent})['response']
97
+ command('set_charge_limit', body: {percent: percent.to_i})['response']
94
98
  end
95
99
 
96
100
  def charge_start
@@ -121,6 +125,10 @@ module TeslaApi
121
125
  command('set_temps', body: {driver_temp: driver_temp, passenger_temp: passenger_temp})['response']
122
126
  end
123
127
 
128
+ def set_preconditioning_max(on)
129
+ command('set_preconditioning_max', body: {on: on})['response']
130
+ end
131
+
124
132
  def auto_conditioning_start
125
133
  command('auto_conditioning_start')['response']
126
134
  end
@@ -137,6 +145,10 @@ module TeslaApi
137
145
  command('sun_roof_control', body: {state: 'move', percent: percent})['response']
138
146
  end
139
147
 
148
+ def window_control(command)
149
+ command('window_control', body: {command: command, lat: 0, lon: 0})['response']
150
+ end
151
+
140
152
  def remote_start_drive(password)
141
153
  command('remote_start_drive', body: {password: password})['response']
142
154
  end
@@ -174,6 +186,10 @@ module TeslaApi
174
186
  })['response']
175
187
  end
176
188
 
189
+ def share(text)
190
+ navigation_request(text)
191
+ end
192
+
177
193
  def schedule_software_update(offset_sec = 0)
178
194
  command('schedule_software_update', body: {offset_sec: offset_sec})['response']
179
195
  end
@@ -194,6 +210,38 @@ module TeslaApi
194
210
  command('set_sentry_mode', body: {on: on})['response']
195
211
  end
196
212
 
213
+ def trigger_homelink(lat, lon)
214
+ command('trigger_homelink', body: {lat: lat, lon: lon})['response']
215
+ end
216
+
217
+ def media_toggle_playback
218
+ command('media_toggle_playback')['response']
219
+ end
220
+
221
+ def media_next_track
222
+ command('media_next_track')['response']
223
+ end
224
+
225
+ def media_prev_track
226
+ command('media_prev_track')['response']
227
+ end
228
+
229
+ def media_next_fav
230
+ command('media_next_fav')['response']
231
+ end
232
+
233
+ def media_prev_fav
234
+ command('media_prev_fav')['response']
235
+ end
236
+
237
+ def media_volume_up
238
+ command('media_volume_up')['response']
239
+ end
240
+
241
+ def media_volume_down
242
+ command('media_volume_down')['response']
243
+ end
244
+
197
245
  private
198
246
 
199
247
  def data_request(name)
@@ -1,3 +1,3 @@
1
1
  module TeslaApi
2
- VERSION = '3.0.0'
2
+ VERSION = '3.0.5'
3
3
  end
@@ -0,0 +1,83 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://owner-api.teslamotors.com/oauth/token
6
+ body:
7
+ encoding: UTF-8
8
+ string: grant_type=password&client_id=<TESLA_CLIENT_ID>&client_secret=<TESLA_CLIENT_SECRET>&email=<TESLA_EMAIL>&password=<TESLA_PASS>
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 408
19
+ message: Request Timeout
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Mon, 15 Dec 2014 03:09:22 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Status:
32
+ - 408 Request Timeout
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{}'
36
+ http_version:
37
+ recorded_at: Mon, 15 Dec 2014 03:09:22 GMT
38
+ - request:
39
+ method: post
40
+ uri: https://owner-api.teslamotors.com/oauth/token
41
+ body:
42
+ encoding: UTF-8
43
+ string: grant_type=password&client_id=<TESLA_CLIENT_ID>&client_secret=<TESLA_CLIENT_SECRET>&email=<TESLA_EMAIL>&password=<TESLA_PASS>
44
+ headers:
45
+ Accept-Encoding:
46
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
47
+ Accept:
48
+ - "*/*"
49
+ User-Agent:
50
+ - Ruby
51
+ response:
52
+ status:
53
+ code: 200
54
+ message: OK
55
+ headers:
56
+ Server:
57
+ - nginx
58
+ Date:
59
+ - Mon, 15 Dec 2014 03:09:22 GMT
60
+ Content-Type:
61
+ - application/json; charset=utf-8
62
+ Transfer-Encoding:
63
+ - chunked
64
+ Connection:
65
+ - keep-alive
66
+ Status:
67
+ - 200 OK
68
+ Cache-Control:
69
+ - no-store
70
+ Pragma:
71
+ - no-cache
72
+ X-Ua-Compatible:
73
+ - IE=Edge,chrome=1
74
+ X-Request-Id:
75
+ - 349d563d345a9694c610770b743d3006
76
+ X-Runtime:
77
+ - '0.416152'
78
+ body:
79
+ encoding: UTF-8
80
+ string: '{"access_token":"1cba4845a8653d4b731440e9911d84304a179bd16a9ecbc9b649f2d8e0f6947e","token_type":"bearer","expires_in":7776000,"refresh_token":"fea03b395fa4e72ebc399d9cda6163dcf438c248f744ebdd5bfcda571f5f317f","created_at":1475777133}'
81
+ http_version:
82
+ recorded_at: Mon, 15 Dec 2014 03:09:22 GMT
83
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,109 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://owner-api.teslamotors.com/api/1/vehicles
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - github.com/timdorr/tesla-api v:3.0.1
12
+ Authorization:
13
+ - Bearer <TESLA_ACCESS_TOKEN>
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Thu, 03 Oct 2019 12:07:15 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Content-Length:
30
+ - '569'
31
+ Connection:
32
+ - keep-alive
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ - SAMEORIGIN
36
+ X-Xss-Protection:
37
+ - 1; mode=block
38
+ X-Content-Type-Options:
39
+ - nosniff
40
+ X-Txid:
41
+ - 14bff6e11faacd74f2e45e00ce3a22ca
42
+ Etag:
43
+ - W/"fee0c127f31e354aae63ac0325c6cce4"
44
+ Cache-Control:
45
+ - max-age=0, private, must-revalidate
46
+ X-Request-Id:
47
+ - 1c00cd57-2b52-43f1-b179-4569cbe3cc9d
48
+ X-Runtime:
49
+ - '0.037398'
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"response":[{"id":1,"vehicle_id":1,"vin":"1","display_name":"tm3","option_codes":"AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0","color":null,"tokens":["1","1"],"state":"online","in_service":false,"id_s":"1","calendar_enabled":true,"api_version":6,"backseat_token":null,"backseat_token_updated_at":null}],"count":1}'
53
+ http_version:
54
+ recorded_at: Thu, 03 Oct 2019 12:07:15 GMT
55
+ - request:
56
+ method: post
57
+ uri: https://owner-api.teslamotors.com/api/1/vehicles/1/command/media_next_fav
58
+ body:
59
+ encoding: UTF-8
60
+ string: ''
61
+ headers:
62
+ User-Agent:
63
+ - github.com/timdorr/tesla-api v:3.0.1
64
+ Authorization:
65
+ - Bearer <TESLA_ACCESS_TOKEN>
66
+ Content-Length:
67
+ - '0'
68
+ Accept-Encoding:
69
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
70
+ Accept:
71
+ - "*/*"
72
+ response:
73
+ status:
74
+ code: 200
75
+ message: OK
76
+ headers:
77
+ Server:
78
+ - nginx
79
+ Date:
80
+ - Thu, 03 Oct 2019 12:07:16 GMT
81
+ Content-Type:
82
+ - application/json; charset=utf-8
83
+ Content-Length:
84
+ - '40'
85
+ Connection:
86
+ - keep-alive
87
+ X-Frame-Options:
88
+ - SAMEORIGIN
89
+ - SAMEORIGIN
90
+ X-Xss-Protection:
91
+ - 1; mode=block
92
+ X-Content-Type-Options:
93
+ - nosniff
94
+ X-Txid:
95
+ - 8071c728da780d613a3b5af7e219c080
96
+ Etag:
97
+ - W/"f67eec105dd6522783a1f1bacc52723a"
98
+ Cache-Control:
99
+ - max-age=0, private, must-revalidate
100
+ X-Request-Id:
101
+ - 23e04dbb-c730-4d64-949d-1f6fb5723cc8
102
+ X-Runtime:
103
+ - '0.535570'
104
+ body:
105
+ encoding: UTF-8
106
+ string: '{"response":{"reason":"","result":true}}'
107
+ http_version:
108
+ recorded_at: Thu, 03 Oct 2019 12:07:16 GMT
109
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,109 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://owner-api.teslamotors.com/api/1/vehicles
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - github.com/timdorr/tesla-api v:3.0.1
12
+ Authorization:
13
+ - Bearer <TESLA_ACCESS_TOKEN>
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Thu, 03 Oct 2019 12:07:10 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Content-Length:
30
+ - '569'
31
+ Connection:
32
+ - keep-alive
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ - SAMEORIGIN
36
+ X-Xss-Protection:
37
+ - 1; mode=block
38
+ X-Content-Type-Options:
39
+ - nosniff
40
+ X-Txid:
41
+ - 53507e4ddb533acdca04c85e956d5d0b
42
+ Etag:
43
+ - W/"fee0c127f31e354aae63ac0325c6cce4"
44
+ Cache-Control:
45
+ - max-age=0, private, must-revalidate
46
+ X-Request-Id:
47
+ - e0c1920f-ebca-44d5-818e-419632e19b30
48
+ X-Runtime:
49
+ - '0.034419'
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"response":[{"id":1,"vehicle_id":1,"vin":"1","display_name":"tm3","option_codes":"AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0","color":null,"tokens":["1","1"],"state":"online","in_service":false,"id_s":"1","calendar_enabled":true,"api_version":6,"backseat_token":null,"backseat_token_updated_at":null}],"count":1}'
53
+ http_version:
54
+ recorded_at: Thu, 03 Oct 2019 12:07:10 GMT
55
+ - request:
56
+ method: post
57
+ uri: https://owner-api.teslamotors.com/api/1/vehicles/1/command/media_next_track
58
+ body:
59
+ encoding: UTF-8
60
+ string: ''
61
+ headers:
62
+ User-Agent:
63
+ - github.com/timdorr/tesla-api v:3.0.1
64
+ Authorization:
65
+ - Bearer <TESLA_ACCESS_TOKEN>
66
+ Content-Length:
67
+ - '0'
68
+ Accept-Encoding:
69
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
70
+ Accept:
71
+ - "*/*"
72
+ response:
73
+ status:
74
+ code: 200
75
+ message: OK
76
+ headers:
77
+ Server:
78
+ - nginx
79
+ Date:
80
+ - Thu, 03 Oct 2019 12:07:11 GMT
81
+ Content-Type:
82
+ - application/json; charset=utf-8
83
+ Content-Length:
84
+ - '40'
85
+ Connection:
86
+ - keep-alive
87
+ X-Frame-Options:
88
+ - SAMEORIGIN
89
+ - SAMEORIGIN
90
+ X-Xss-Protection:
91
+ - 1; mode=block
92
+ X-Content-Type-Options:
93
+ - nosniff
94
+ X-Txid:
95
+ - 3378733fc84bfc9a0d8ca8829f3e061e
96
+ Etag:
97
+ - W/"f67eec105dd6522783a1f1bacc52723a"
98
+ Cache-Control:
99
+ - max-age=0, private, must-revalidate
100
+ X-Request-Id:
101
+ - 7d4d8512-ede6-47f7-bec0-0d8827369cce
102
+ X-Runtime:
103
+ - '0.233400'
104
+ body:
105
+ encoding: UTF-8
106
+ string: '{"response":{"reason":"","result":true}}'
107
+ http_version:
108
+ recorded_at: Thu, 03 Oct 2019 12:07:11 GMT
109
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,109 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://owner-api.teslamotors.com/api/1/vehicles
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - github.com/timdorr/tesla-api v:3.0.1
12
+ Authorization:
13
+ - Bearer <TESLA_ACCESS_TOKEN>
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Thu, 03 Oct 2019 12:07:13 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Content-Length:
30
+ - '569'
31
+ Connection:
32
+ - keep-alive
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ - SAMEORIGIN
36
+ X-Xss-Protection:
37
+ - 1; mode=block
38
+ X-Content-Type-Options:
39
+ - nosniff
40
+ X-Txid:
41
+ - ebdbffdab2c2775c54baa8da990d85bf
42
+ Etag:
43
+ - W/"fee0c127f31e354aae63ac0325c6cce4"
44
+ Cache-Control:
45
+ - max-age=0, private, must-revalidate
46
+ X-Request-Id:
47
+ - c88974d9-c7d5-4082-a197-6b0106a1272b
48
+ X-Runtime:
49
+ - '0.043550'
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"response":[{"id":1,"vehicle_id":1,"vin":"1","display_name":"tm3","option_codes":"AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0","color":null,"tokens":["1","1"],"state":"online","in_service":false,"id_s":"1","calendar_enabled":true,"api_version":6,"backseat_token":null,"backseat_token_updated_at":null}],"count":1}'
53
+ http_version:
54
+ recorded_at: Thu, 03 Oct 2019 12:07:13 GMT
55
+ - request:
56
+ method: post
57
+ uri: https://owner-api.teslamotors.com/api/1/vehicles/1/command/media_prev_fav
58
+ body:
59
+ encoding: UTF-8
60
+ string: ''
61
+ headers:
62
+ User-Agent:
63
+ - github.com/timdorr/tesla-api v:3.0.1
64
+ Authorization:
65
+ - Bearer <TESLA_ACCESS_TOKEN>
66
+ Content-Length:
67
+ - '0'
68
+ Accept-Encoding:
69
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
70
+ Accept:
71
+ - "*/*"
72
+ response:
73
+ status:
74
+ code: 200
75
+ message: OK
76
+ headers:
77
+ Server:
78
+ - nginx
79
+ Date:
80
+ - Thu, 03 Oct 2019 12:07:14 GMT
81
+ Content-Type:
82
+ - application/json; charset=utf-8
83
+ Content-Length:
84
+ - '40'
85
+ Connection:
86
+ - keep-alive
87
+ X-Frame-Options:
88
+ - SAMEORIGIN
89
+ - SAMEORIGIN
90
+ X-Xss-Protection:
91
+ - 1; mode=block
92
+ X-Content-Type-Options:
93
+ - nosniff
94
+ X-Txid:
95
+ - 6a65e94c22f4feabfcacfe9695305d8b
96
+ Etag:
97
+ - W/"f67eec105dd6522783a1f1bacc52723a"
98
+ Cache-Control:
99
+ - max-age=0, private, must-revalidate
100
+ X-Request-Id:
101
+ - 8e593817-2ce5-4ce7-89e2-9543421af7a3
102
+ X-Runtime:
103
+ - '0.438129'
104
+ body:
105
+ encoding: UTF-8
106
+ string: '{"response":{"reason":"","result":true}}'
107
+ http_version:
108
+ recorded_at: Thu, 03 Oct 2019 12:07:14 GMT
109
+ recorded_with: VCR 4.0.0