tesla_api 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +5 -5
  2. data/.gitbook.yml +4 -0
  3. data/.travis.yml +3 -4
  4. data/LICENSE +1 -1
  5. data/README.md +7 -3
  6. data/Rakefile +27 -1
  7. data/apiary.apib +21 -14
  8. data/docs/README.md +26 -0
  9. data/docs/SUMMARY.md +39 -0
  10. data/docs/api-basics/authentication.md +40 -0
  11. data/docs/api-basics/vehicles.md +77 -0
  12. data/docs/vehicle/autopark.md +4 -0
  13. data/docs/vehicle/commands/README.md +22 -0
  14. data/docs/vehicle/commands/alerts.md +5 -0
  15. data/docs/vehicle/commands/calendar.md +3 -0
  16. data/docs/vehicle/commands/charging.md +3 -0
  17. data/docs/vehicle/commands/climate.md +3 -0
  18. data/docs/vehicle/commands/doors.md +3 -0
  19. data/docs/vehicle/commands/media.md +3 -0
  20. data/docs/vehicle/commands/navigation.md +3 -0
  21. data/docs/vehicle/commands/remotestart.md +3 -0
  22. data/docs/vehicle/commands/softwareupdate.md +3 -0
  23. data/docs/vehicle/commands/speedlimit.md +3 -0
  24. data/docs/vehicle/commands/sunroof.md +3 -0
  25. data/docs/vehicle/commands/trunk.md +3 -0
  26. data/docs/vehicle/commands/valet.md +3 -0
  27. data/docs/vehicle/commands/wake.md +3 -0
  28. data/docs/vehicle/optioncodes.md +253 -0
  29. data/docs/vehicle/state/README.md +34 -0
  30. data/docs/vehicle/state/chargestate.md +56 -0
  31. data/docs/vehicle/state/climatestate.md +43 -0
  32. data/docs/vehicle/state/data.md +181 -0
  33. data/docs/vehicle/state/drivestate.md +27 -0
  34. data/docs/vehicle/state/guisettings.md +21 -0
  35. data/docs/vehicle/state/mobileenabled.md +14 -0
  36. data/docs/vehicle/state/vehiclestate.md +47 -0
  37. data/docs/vehicle/streaming.md +4 -0
  38. data/lib/tesla_api.rb +7 -6
  39. data/lib/tesla_api/autopark.rb +62 -0
  40. data/lib/tesla_api/client.rb +32 -11
  41. data/lib/tesla_api/stream.rb +11 -7
  42. data/lib/tesla_api/vehicle.rb +50 -30
  43. data/lib/tesla_api/version.rb +1 -1
  44. data/spec/cassettes/client-login.yml +1 -1
  45. data/spec/cassettes/vehicle-activate_speed_limit.yml +95 -0
  46. data/spec/cassettes/vehicle-clear_speed_limit_pin.yml +95 -0
  47. data/spec/cassettes/vehicle-deactivate_speed_limit.yml +95 -0
  48. data/spec/cassettes/vehicle-open_frunk.yml +40 -73
  49. data/spec/cassettes/vehicle-open_trunk.yml +40 -73
  50. data/spec/cassettes/vehicle-set_speed_limit.yml +95 -0
  51. data/spec/lib/tesla_api/client_spec.rb +42 -15
  52. data/spec/lib/tesla_api/vehicle_spec.rb +160 -136
  53. data/spec/spec_helper.rb +6 -18
  54. data/tesla_api.gemspec +20 -24
  55. metadata +67 -42
  56. data/circle.yml +0 -10
@@ -1,3 +1,3 @@
1
1
  module TeslaApi
2
- VERSION = "1.2.0"
2
+ VERSION = '1.3.0'
3
3
  end
@@ -42,7 +42,7 @@ http_interactions:
42
42
  - '0.416152'
43
43
  body:
44
44
  encoding: UTF-8
45
- string: '{"access_token":"1cba4845a8653d4b731440e9911d84304a179bd16a9ecbc9b649f2d8e0f6947e","token_type":"bearer","expires_in":7776000}'
45
+ string: '{"access_token":"1cba4845a8653d4b731440e9911d84304a179bd16a9ecbc9b649f2d8e0f6947e","token_type":"bearer","expires_in":7776000,"created_at":1475777133}'
46
46
  http_version:
47
47
  recorded_at: Mon, 15 Dec 2014 03:09:22 GMT
48
48
  recorded_with: VCR 2.9.3
@@ -0,0 +1,95 @@
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
+ Authorization:
11
+ - Bearer <TESLA_API_TOKEN>
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Wed, 18 Jul 2018 23:51:08 GMT
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Content-Length:
24
+ - '623'
25
+ Connection:
26
+ - keep-alive
27
+ X-Frame-Options:
28
+ - SAMEORIGIN
29
+ - SAMEORIGIN
30
+ X-Xss-Protection:
31
+ - 1; mode=block
32
+ X-Content-Type-Options:
33
+ - nosniff
34
+ X-Txid:
35
+ - 847e4b8523b39310a4586d423f030546
36
+ Etag:
37
+ - W/"6958697e3e1e010f56068d8c7fa2f93d"
38
+ Cache-Control:
39
+ - max-age=0, private, must-revalidate
40
+ X-Request-Id:
41
+ - 435b45f8-45d1-4c08-b436-4d403d369d8d
42
+ X-Runtime:
43
+ - '0.046828'
44
+ body:
45
+ encoding: UTF-8
46
+ string: '{"response":[{"color":null,"display_name":"Nikola","id":1514029006966957156,"option_codes":"MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013,COUS","vehicle_id":490215852,"vin":"5YJSA1CN5CFP01657","tokens":["a1f3fab6393d3a6a","91a139ce322eed65"],"state":"online","remote_start_enabled":true,"calendar_enabled":true,"notifications_enabled":true}],"count":1}'
47
+ http_version:
48
+ recorded_at: Wed, 18 Jul 2018 23:51:08 GMT
49
+ - request:
50
+ method: post
51
+ uri: https://owner-api.teslamotors.com/api/1/vehicles/1514029006966957156/command/speed_limit_activate
52
+ body:
53
+ encoding: UTF-8
54
+ string: pin=1234
55
+ headers:
56
+ Authorization:
57
+ - Bearer <TESLA_API_TOKEN>
58
+ response:
59
+ status:
60
+ code: 200
61
+ message: OK
62
+ headers:
63
+ Server:
64
+ - nginx
65
+ Date:
66
+ - Wed, 18 Jul 2018 23:51:09 GMT
67
+ Content-Type:
68
+ - application/json; charset=utf-8
69
+ Content-Length:
70
+ - '40'
71
+ Connection:
72
+ - keep-alive
73
+ X-Frame-Options:
74
+ - SAMEORIGIN
75
+ - SAMEORIGIN
76
+ X-Xss-Protection:
77
+ - 1; mode=block
78
+ X-Content-Type-Options:
79
+ - nosniff
80
+ X-Txid:
81
+ - be21a3dafb36eb974f6bbdc8c93a20f2
82
+ Etag:
83
+ - W/"f67eec105dd6522783a1f1bacc52723a"
84
+ Cache-Control:
85
+ - max-age=0, private, must-revalidate
86
+ X-Request-Id:
87
+ - 6595159d-7cd5-4838-9d08-e4bebeb98944
88
+ X-Runtime:
89
+ - '0.113766'
90
+ body:
91
+ encoding: UTF-8
92
+ string: '{"response":{"reason":"","result":true}}'
93
+ http_version:
94
+ recorded_at: Wed, 18 Jul 2018 23:51:09 GMT
95
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,95 @@
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
+ Authorization:
11
+ - Bearer <TESLA_API_TOKEN>
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Wed, 18 Jul 2018 23:51:23 GMT
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Content-Length:
24
+ - '623'
25
+ Connection:
26
+ - keep-alive
27
+ X-Frame-Options:
28
+ - SAMEORIGIN
29
+ - SAMEORIGIN
30
+ X-Xss-Protection:
31
+ - 1; mode=block
32
+ X-Content-Type-Options:
33
+ - nosniff
34
+ X-Txid:
35
+ - bc80be5384634b6dc8c0a299b989d27d
36
+ Etag:
37
+ - W/"6958697e3e1e010f56068d8c7fa2f93d"
38
+ Cache-Control:
39
+ - max-age=0, private, must-revalidate
40
+ X-Request-Id:
41
+ - fa8c5085-118f-43f1-888c-5a809d611db3
42
+ X-Runtime:
43
+ - '0.022783'
44
+ body:
45
+ encoding: UTF-8
46
+ string: '{"response":[{"color":null,"display_name":"Nikola","id":1514029006966957156,"option_codes":"MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013,COUS","vehicle_id":490215852,"vin":"5YJSA1CN5CFP01657","tokens":["a1f3fab6393d3a6a","91a139ce322eed65"],"state":"online","remote_start_enabled":true,"calendar_enabled":true,"notifications_enabled":true}],"count":1}'
47
+ http_version:
48
+ recorded_at: Wed, 18 Jul 2018 23:51:23 GMT
49
+ - request:
50
+ method: post
51
+ uri: https://owner-api.teslamotors.com/api/1/vehicles/1514029006966957156/command/speed_limit_clear_pin
52
+ body:
53
+ encoding: UTF-8
54
+ string: pin=1234
55
+ headers:
56
+ Authorization:
57
+ - Bearer <TESLA_API_TOKEN>
58
+ response:
59
+ status:
60
+ code: 200
61
+ message: OK
62
+ headers:
63
+ Server:
64
+ - nginx
65
+ Date:
66
+ - Wed, 18 Jul 2018 23:51:23 GMT
67
+ Content-Type:
68
+ - application/json; charset=utf-8
69
+ Content-Length:
70
+ - '40'
71
+ Connection:
72
+ - keep-alive
73
+ X-Frame-Options:
74
+ - SAMEORIGIN
75
+ - SAMEORIGIN
76
+ X-Xss-Protection:
77
+ - 1; mode=block
78
+ X-Content-Type-Options:
79
+ - nosniff
80
+ X-Txid:
81
+ - 0d08fce559d8e65c3f2af0f17c81cdc5
82
+ Etag:
83
+ - W/"f67eec105dd6522783a1f1bacc52723a"
84
+ Cache-Control:
85
+ - max-age=0, private, must-revalidate
86
+ X-Request-Id:
87
+ - c3ef68ab-513e-4d42-8db6-c16bdb953a04
88
+ X-Runtime:
89
+ - '0.114087'
90
+ body:
91
+ encoding: UTF-8
92
+ string: '{"response":{"reason":"","result":true}}'
93
+ http_version:
94
+ recorded_at: Wed, 18 Jul 2018 23:51:23 GMT
95
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,95 @@
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
+ Authorization:
11
+ - Bearer <TESLA_API_TOKEN>
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Wed, 18 Jul 2018 23:51:14 GMT
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Content-Length:
24
+ - '623'
25
+ Connection:
26
+ - keep-alive
27
+ X-Frame-Options:
28
+ - SAMEORIGIN
29
+ - SAMEORIGIN
30
+ X-Xss-Protection:
31
+ - 1; mode=block
32
+ X-Content-Type-Options:
33
+ - nosniff
34
+ X-Txid:
35
+ - 05b9838c6520dc434f4ff30372560b1b
36
+ Etag:
37
+ - W/"6958697e3e1e010f56068d8c7fa2f93d"
38
+ Cache-Control:
39
+ - max-age=0, private, must-revalidate
40
+ X-Request-Id:
41
+ - f09cc4df-b6df-42f2-9363-2c20fb970f9d
42
+ X-Runtime:
43
+ - '0.017357'
44
+ body:
45
+ encoding: UTF-8
46
+ string: '{"response":[{"color":null,"display_name":"Nikola","id":1514029006966957156,"option_codes":"MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013,COUS","vehicle_id":490215852,"vin":"5YJSA1CN5CFP01657","tokens":["a1f3fab6393d3a6a","91a139ce322eed65"],"state":"online","remote_start_enabled":true,"calendar_enabled":true,"notifications_enabled":true}],"count":1}'
47
+ http_version:
48
+ recorded_at: Wed, 18 Jul 2018 23:51:14 GMT
49
+ - request:
50
+ method: post
51
+ uri: https://owner-api.teslamotors.com/api/1/vehicles/1514029006966957156/command/speed_limit_deactivate
52
+ body:
53
+ encoding: UTF-8
54
+ string: pin=1234
55
+ headers:
56
+ Authorization:
57
+ - Bearer <TESLA_API_TOKEN>
58
+ response:
59
+ status:
60
+ code: 200
61
+ message: OK
62
+ headers:
63
+ Server:
64
+ - nginx
65
+ Date:
66
+ - Wed, 18 Jul 2018 23:51:14 GMT
67
+ Content-Type:
68
+ - application/json; charset=utf-8
69
+ Content-Length:
70
+ - '40'
71
+ Connection:
72
+ - keep-alive
73
+ X-Frame-Options:
74
+ - SAMEORIGIN
75
+ - SAMEORIGIN
76
+ X-Xss-Protection:
77
+ - 1; mode=block
78
+ X-Content-Type-Options:
79
+ - nosniff
80
+ X-Txid:
81
+ - d97b96421307d17836b61e70f9ff33e6
82
+ Etag:
83
+ - W/"f67eec105dd6522783a1f1bacc52723a"
84
+ Cache-Control:
85
+ - max-age=0, private, must-revalidate
86
+ X-Request-Id:
87
+ - bd64baaf-2dd9-414e-b3ca-46db9f5eaddd
88
+ X-Runtime:
89
+ - '0.145679'
90
+ body:
91
+ encoding: UTF-8
92
+ string: '{"response":{"reason":"","result":true}}'
93
+ http_version:
94
+ recorded_at: Wed, 18 Jul 2018 23:51:14 GMT
95
+ recorded_with: VCR 3.0.3
@@ -1,50 +1,5 @@
1
1
  ---
2
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: 200
19
- message: OK
20
- headers:
21
- Server:
22
- - nginx
23
- Date:
24
- - Wed, 17 Dec 2014 02:01:59 GMT
25
- Content-Type:
26
- - application/json; charset=utf-8
27
- Transfer-Encoding:
28
- - chunked
29
- Connection:
30
- - keep-alive
31
- Status:
32
- - 200 OK
33
- Cache-Control:
34
- - no-store
35
- Pragma:
36
- - no-cache
37
- X-Ua-Compatible:
38
- - IE=Edge,chrome=1
39
- X-Request-Id:
40
- - 67e09975b14c0b397198660437868653
41
- X-Runtime:
42
- - '0.520108'
43
- body:
44
- encoding: UTF-8
45
- string: '{"access_token":"a3bce92ff51163fa6072f435e88b4e9de61c79bafdfbae5867fb1157b00a64c5","token_type":"bearer","expires_in":7776000}'
46
- http_version:
47
- recorded_at: Wed, 17 Dec 2014 02:02:01 GMT
48
3
  - request:
49
4
  method: get
50
5
  uri: https://owner-api.teslamotors.com/api/1/vehicles
@@ -53,7 +8,7 @@ http_interactions:
53
8
  string: ''
54
9
  headers:
55
10
  Authorization:
56
- - Bearer a3bce92ff51163fa6072f435e88b4e9de61c79bafdfbae5867fb1157b00a64c5
11
+ - Bearer <TESLA_API_TOKEN>
57
12
  response:
58
13
  status:
59
14
  code: 200
@@ -62,67 +17,79 @@ http_interactions:
62
17
  Server:
63
18
  - nginx
64
19
  Date:
65
- - Wed, 17 Dec 2014 02:02:00 GMT
20
+ - Sun, 05 Aug 2018 17:04:59 GMT
66
21
  Content-Type:
67
22
  - application/json; charset=utf-8
68
23
  Content-Length:
69
- - '446'
24
+ - '623'
70
25
  Connection:
71
26
  - keep-alive
72
- Status:
73
- - 200 OK
74
- X-Ua-Compatible:
75
- - IE=Edge,chrome=1
27
+ X-Frame-Options:
28
+ - SAMEORIGIN
29
+ - SAMEORIGIN
30
+ X-Xss-Protection:
31
+ - 1; mode=block
32
+ X-Content-Type-Options:
33
+ - nosniff
34
+ X-Txid:
35
+ - 951bcecdd2d7f67c62ad15c00c7ce012
76
36
  Etag:
77
- - '"f75b5f2e5ddca5f7c1bf938da14972f4"'
37
+ - W/"a78143581fd077eaa11b6ca4674b0d08"
78
38
  Cache-Control:
79
39
  - max-age=0, private, must-revalidate
80
40
  X-Request-Id:
81
- - 111bf3a7502b70e8416a6deea81f8ceb
41
+ - e9f132ac-784d-4191-87f5-a9db6c20a68b
82
42
  X-Runtime:
83
- - '0.078300'
43
+ - '0.075622'
84
44
  body:
85
45
  encoding: UTF-8
86
46
  string: '{"response":[{"color":null,"display_name":"Nikola","id":1514029006966957156,"option_codes":"MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013,COUS","vehicle_id":490215852,"vin":"5YJSA1CN5CFP01657","tokens":["13e0ae629c708af6","156102684b1be0dd"],"state":"online","remote_start_enabled":true,"calendar_enabled":true,"notifications_enabled":true}],"count":1}'
87
47
  http_version:
88
- recorded_at: Wed, 17 Dec 2014 02:02:02 GMT
48
+ recorded_at: Sun, 05 Aug 2018 17:04:59 GMT
89
49
  - request:
90
50
  method: post
91
- uri: https://owner-api.teslamotors.com/api/1/vehicles/1514029006966957156/command/trunk_open
51
+ uri: https://owner-api.teslamotors.com/api/1/vehicles/1514029006966957156/command/actuate_trunk
92
52
  body:
93
53
  encoding: UTF-8
94
- string: which_trunk=rear
54
+ string: which_trunk=front
95
55
  headers:
96
56
  Authorization:
97
- - Bearer a3bce92ff51163fa6072f435e88b4e9de61c79bafdfbae5867fb1157b00a64c5
57
+ - Bearer <TESLA_API_TOKEN>
98
58
  response:
99
59
  status:
100
- code: 400
101
- message: Bad Request
60
+ code: 200
61
+ message: OK
102
62
  headers:
103
63
  Server:
104
64
  - nginx
105
65
  Date:
106
- - Wed, 17 Dec 2014 02:02:00 GMT
66
+ - Sun, 05 Aug 2018 17:04:59 GMT
107
67
  Content-Type:
108
68
  - application/json; charset=utf-8
109
69
  Content-Length:
110
- - '66'
70
+ - '40'
111
71
  Connection:
112
72
  - keep-alive
113
- Status:
114
- - 400 Bad Request
115
- X-Ua-Compatible:
116
- - IE=Edge,chrome=1
73
+ X-Frame-Options:
74
+ - SAMEORIGIN
75
+ - SAMEORIGIN
76
+ X-Xss-Protection:
77
+ - 1; mode=block
78
+ X-Content-Type-Options:
79
+ - nosniff
80
+ X-Txid:
81
+ - 442bc3f4fb49eabadd5ec4ab5af8d7d6
82
+ Etag:
83
+ - W/"f67eec105dd6522783a1f1bacc52723a"
117
84
  Cache-Control:
118
- - no-cache
85
+ - max-age=0, private, must-revalidate
119
86
  X-Request-Id:
120
- - 61620ab4282664be50850b5f455d85e4
87
+ - 0549c8ca-3e1b-40b9-bd90-430015b6ddde
121
88
  X-Runtime:
122
- - '0.011449'
89
+ - '0.083773'
123
90
  body:
124
91
  encoding: UTF-8
125
- string: '{"response":null,"error":"invalid_command","error_description":""}'
92
+ string: '{"response":{"reason":"","result":true}}'
126
93
  http_version:
127
- recorded_at: Wed, 17 Dec 2014 02:02:02 GMT
128
- recorded_with: VCR 2.9.3
94
+ recorded_at: Sun, 05 Aug 2018 17:04:59 GMT
95
+ recorded_with: VCR 3.0.3