tesla_api 3.0.1 → 3.0.6

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 +13 -6
  22. data/lib/tesla_api/stream.rb +44 -38
  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
@@ -73,4 +73,34 @@ RSpec.describe TeslaApi::Client do
73
73
  expect(tesla_api.vehicles).to include(TeslaApi::Vehicle)
74
74
  end
75
75
  end
76
+
77
+ describe 'retry options', vcr: { cassette_name: 'client-login_timeout' } do
78
+ subject(:tesla_api) { TeslaApi::Client.new(
79
+ access_token: ENV['TESLA_ACCESS_TOKEN'],
80
+ retry_options: retry_options
81
+ ) }
82
+
83
+ let(:retry_options) {{
84
+ max: 2,
85
+ methods: [:post],
86
+ retry_statuses: [408]
87
+ }}
88
+
89
+ context 'with retry' do
90
+ it 'obtains a Bearer token after retry' do
91
+ tesla_api.login!(ENV['TESLA_PASS'])
92
+ expect(tesla_api.access_token).to be
93
+ end
94
+ end
95
+
96
+ context 'without retry' do
97
+ let(:retry_options) { nil }
98
+
99
+ it 'raises an error' do
100
+ expect {
101
+ tesla_api.login!(ENV['TESLA_PASS'])
102
+ }.to raise_error(Faraday::ClientError)
103
+ end
104
+ end
105
+ end
76
106
  end
@@ -28,6 +28,7 @@ RSpec.describe TeslaApi::Vehicle do
28
28
  it { should include('display_name') }
29
29
  it { should include('drive_state') }
30
30
  it { should include('vehicle_state') }
31
+ it { should include('vehicle_config') }
31
32
  it { should include('charge_state') }
32
33
  end
33
34
  end
@@ -104,6 +105,18 @@ RSpec.describe TeslaApi::Vehicle do
104
105
  end
105
106
  end
106
107
 
108
+ describe '#vehicle_config', vcr: {cassette_name: 'vehicle-vehicle_config'} do
109
+ context 'data about the vehicle\'s overall state' do
110
+ subject { vehicle.vehicle_config }
111
+
112
+ it { should include('exterior_color') }
113
+ it { should include('wheel_type') }
114
+ it { should include('has_air_suspension') }
115
+ it { should include('car_type') }
116
+ it { should include('timestamp') }
117
+ end
118
+ end
119
+
107
120
  describe '#wake_up', vcr: {cassette_name: 'vehicle-wake_up'} do
108
121
  it 'wakes up the car from sleep mode' do
109
122
  vehicle.wake_up
@@ -331,4 +344,48 @@ RSpec.describe TeslaApi::Vehicle do
331
344
  expect(vehicle.set_sentry_mode(false)['result']).to eq(true)
332
345
  end
333
346
  end
347
+
348
+ context '#media' do
349
+ describe '#media_toggle_playback', vcr: {cassette_name: 'vehicle-media_toggle_playback'} do
350
+ it 'toggles media from playing and paused' do
351
+ expect(vehicle.media_toggle_playback['result']).to eq(true)
352
+ end
353
+ end
354
+
355
+ describe '#media_next_track', vcr: {cassette_name: 'vehicle-media_next_track'} do
356
+ it 'plays the next track in playlist' do
357
+ expect(vehicle.media_next_track['result']).to eq(true)
358
+ end
359
+ end
360
+
361
+ describe '#media_prev_track', vcr: {cassette_name: 'vehicle-media_prev_track'} do
362
+ it 'plays the previous track in playlist' do
363
+ expect(vehicle.media_prev_track['result']).to eq(true)
364
+ end
365
+ end
366
+
367
+ describe '#media_next_fav', vcr: {cassette_name: 'vehicle-media_next_fav'} do
368
+ it 'plays the next favourite track' do
369
+ expect(vehicle.media_next_fav['result']).to eq(true)
370
+ end
371
+ end
372
+
373
+ describe '#media_prev_fav', vcr: {cassette_name: 'vehicle-media_prev_fav'} do
374
+ it 'plays the previous favourite track' do
375
+ expect(vehicle.media_prev_fav['result']).to eq(true)
376
+ end
377
+ end
378
+
379
+ describe '#media_volume_up', vcr: {cassette_name: 'vehicle-media_volume_up'} do
380
+ it 'increases volume of media' do
381
+ expect(vehicle.media_volume_up['result']).to eq(true)
382
+ end
383
+ end
384
+
385
+ describe '#media_volume_down', vcr: {cassette_name: 'vehicle-media_volume_down'} do
386
+ it 'decreases volume of media' do
387
+ expect(vehicle.media_volume_down['result']).to eq(true)
388
+ end
389
+ end
390
+ end
334
391
  end
@@ -14,9 +14,9 @@ Gem::Specification.new do |spec|
14
14
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
15
  spec.require_paths = ['lib']
16
16
 
17
+ spec.add_dependency 'async-websocket'
17
18
  spec.add_dependency 'faraday'
18
19
  spec.add_dependency 'faraday_middleware'
19
- spec.add_dependency 'faye-websocket'
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 2.0'
22
22
  spec.add_development_dependency 'rake', '~> 12.0'
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tesla_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Dorr
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-25 00:00:00.000000000 Z
11
+ date: 2020-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: faraday
14
+ name: async-websocket
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: faraday_middleware
28
+ name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: faye-websocket
42
+ name: faraday_middleware
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -167,16 +167,18 @@ files:
167
167
  - docs/vehicle/commands/charging.md
168
168
  - docs/vehicle/commands/climate.md
169
169
  - docs/vehicle/commands/doors.md
170
+ - docs/vehicle/commands/homelink.md
170
171
  - docs/vehicle/commands/media.md
171
- - docs/vehicle/commands/navigation.md
172
172
  - docs/vehicle/commands/remotestart.md
173
173
  - docs/vehicle/commands/sentrymode.md
174
+ - docs/vehicle/commands/sharing.md
174
175
  - docs/vehicle/commands/softwareupdate.md
175
176
  - docs/vehicle/commands/speedlimit.md
176
177
  - docs/vehicle/commands/sunroof.md
177
178
  - docs/vehicle/commands/trunk.md
178
179
  - docs/vehicle/commands/valet.md
179
180
  - docs/vehicle/commands/wake.md
181
+ - docs/vehicle/commands/windows.md
180
182
  - docs/vehicle/optioncodes.md
181
183
  - docs/vehicle/state/README.md
182
184
  - docs/vehicle/state/chargestate.md
@@ -196,6 +198,7 @@ files:
196
198
  - lib/tesla_api/vehicle.rb
197
199
  - lib/tesla_api/version.rb
198
200
  - spec/cassettes/client-login.yml
201
+ - spec/cassettes/client-login_timeout.yml
199
202
  - spec/cassettes/client-refresh.yml
200
203
  - spec/cassettes/client-vehicles.yml
201
204
  - spec/cassettes/vehicle-activate_speed_limit.yml
@@ -221,6 +224,13 @@ files:
221
224
  - spec/cassettes/vehicle-flash_lights.yml
222
225
  - spec/cassettes/vehicle-gui_settings.yml
223
226
  - spec/cassettes/vehicle-honk_horn.yml
227
+ - spec/cassettes/vehicle-media_next_fav.yml
228
+ - spec/cassettes/vehicle-media_next_track.yml
229
+ - spec/cassettes/vehicle-media_prev_fav.yml
230
+ - spec/cassettes/vehicle-media_prev_track.yml
231
+ - spec/cassettes/vehicle-media_toggle_playback.yml
232
+ - spec/cassettes/vehicle-media_volume_down.yml
233
+ - spec/cassettes/vehicle-media_volume_up.yml
224
234
  - spec/cassettes/vehicle-mobile_enabled.yml
225
235
  - spec/cassettes/vehicle-navigation_request.yml
226
236
  - spec/cassettes/vehicle-nearby_charging_sites.yml
@@ -242,6 +252,7 @@ files:
242
252
  - spec/cassettes/vehicle-steering_wheel_heater_request.yml
243
253
  - spec/cassettes/vehicle-sun_roof_control-close.yml
244
254
  - spec/cassettes/vehicle-sun_roof_control-vent.yml
255
+ - spec/cassettes/vehicle-vehicle_config.yml
245
256
  - spec/cassettes/vehicle-vehicle_state.yml
246
257
  - spec/cassettes/vehicle-wake_up.yml
247
258
  - spec/cassettes/vehicle.yml
@@ -253,7 +264,7 @@ homepage: https://github.com/timdorr/tesla-api
253
264
  licenses:
254
265
  - MIT
255
266
  metadata: {}
256
- post_install_message:
267
+ post_install_message:
257
268
  rdoc_options: []
258
269
  require_paths:
259
270
  - lib
@@ -268,12 +279,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
279
  - !ruby/object:Gem::Version
269
280
  version: '0'
270
281
  requirements: []
271
- rubygems_version: 3.0.6
272
- signing_key:
282
+ rubygems_version: 3.0.3
283
+ signing_key:
273
284
  specification_version: 4
274
285
  summary: A wrapper for the Tesla JSON API
275
286
  test_files:
276
287
  - spec/cassettes/client-login.yml
288
+ - spec/cassettes/client-login_timeout.yml
277
289
  - spec/cassettes/client-refresh.yml
278
290
  - spec/cassettes/client-vehicles.yml
279
291
  - spec/cassettes/vehicle-activate_speed_limit.yml
@@ -299,6 +311,13 @@ test_files:
299
311
  - spec/cassettes/vehicle-flash_lights.yml
300
312
  - spec/cassettes/vehicle-gui_settings.yml
301
313
  - spec/cassettes/vehicle-honk_horn.yml
314
+ - spec/cassettes/vehicle-media_next_fav.yml
315
+ - spec/cassettes/vehicle-media_next_track.yml
316
+ - spec/cassettes/vehicle-media_prev_fav.yml
317
+ - spec/cassettes/vehicle-media_prev_track.yml
318
+ - spec/cassettes/vehicle-media_toggle_playback.yml
319
+ - spec/cassettes/vehicle-media_volume_down.yml
320
+ - spec/cassettes/vehicle-media_volume_up.yml
302
321
  - spec/cassettes/vehicle-mobile_enabled.yml
303
322
  - spec/cassettes/vehicle-navigation_request.yml
304
323
  - spec/cassettes/vehicle-nearby_charging_sites.yml
@@ -320,6 +339,7 @@ test_files:
320
339
  - spec/cassettes/vehicle-steering_wheel_heater_request.yml
321
340
  - spec/cassettes/vehicle-sun_roof_control-close.yml
322
341
  - spec/cassettes/vehicle-sun_roof_control-vent.yml
342
+ - spec/cassettes/vehicle-vehicle_config.yml
323
343
  - spec/cassettes/vehicle-vehicle_state.yml
324
344
  - spec/cassettes/vehicle-wake_up.yml
325
345
  - spec/cassettes/vehicle.yml
@@ -1,36 +0,0 @@
1
- # Navigation
2
-
3
- ## POST `/api/1/vehicles/{id}/command/navigation_request`
4
-
5
- Sends a location for the car to start navigation.
6
-
7
- These docs take from the Android app, which sends the data in JSON form. However, a urlencoded POST body will work as well. The basic format to a request looks like this:
8
-
9
- ```json
10
- {
11
- "type": "share_ext_content_raw",
12
- "value": {
13
- "android.intent.extra.TEXT": "123 Main St, City, ST 12345\n\nhttps://goo.gl/maps/X"
14
- },
15
- "locale": "en-US",
16
- "timestamp_ms": "1539465730"
17
- }
18
- ```
19
-
20
- ### Parameters
21
-
22
- | Parameter | Example | Description |
23
- | :------------------------------- | :-------------------------- | :------------------------------------------------ |
24
- | type | share_ext_content_raw | Must be `share_ext_content_raw`. |
25
- | locale | en-US | The locale for the navigation request. |
26
- | timestamp_ms | 1539465730 | The current UNIX timestamp. |
27
- | value[android.intent.extra.TEXT] | 123 Main St, City, ST 12345 | The address to set as the navigation destination. |
28
-
29
- ### Response
30
-
31
- ```json
32
- {
33
- "reason": "",
34
- "result": true
35
- }
36
- ```