tesla-api 0.0.1

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.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tesla-api.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Gavin Stark
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ = TeslaAPI
2
+
3
+ == DESCRIPTION
4
+
5
+ Allows access to the Tesla REST API for reading car telemetry and controlling basic
6
+ vehicle features such as locking doors, opening the roof and controlling the AC system.
7
+
8
+ Implements the API documented here: https://github.com/timdorr/model-s-api
9
+
10
+ == Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'tesla-api'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install tesla-api
23
+
24
+ == Usage
25
+
26
+ tesla = TeslaAPI::Connection.new("user@example.com", "password")
27
+
28
+ mycar = tesla.vehicle
29
+
30
+ mycar.lock_door!
31
+
32
+ puts mycar.drive_state.speed # => 65
33
+
34
+ == Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ end
7
+
8
+ desc "Run tests"
9
+ task :default => :test
10
+
@@ -0,0 +1,134 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://portal.vn.teslamotors.com/login
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: !binary |-
9
+ foo==
10
+ headers:
11
+ Content-Type:
12
+ - application/x-www-form-urlencoded
13
+ response:
14
+ status:
15
+ code: 302
16
+ message: Found
17
+ headers:
18
+ Location:
19
+ - https://portal.vn.teslamotors.com/
20
+ Content-Type:
21
+ - text/html; charset=utf-8
22
+ X-Ua-Compatible:
23
+ - IE=Edge,chrome=1
24
+ Cache-Control:
25
+ - no-cache
26
+ Set-Cookie:
27
+ - _s_portal_session=;
28
+ path=/; secure; HttpOnly
29
+ - user_credentials=;
30
+ path=/; expires=Sat, 18-May-2013 01:17:09 GMT; secure; HttpOnly
31
+ X-Request-Id:
32
+ - 97a088fef9adf1f3c965078a83d09040
33
+ X-Runtime:
34
+ - '1.184748'
35
+ Date:
36
+ - Mon, 18 Feb 2013 01:17:09 GMT
37
+ X-Rack-Cache:
38
+ - invalidate, pass
39
+ Server:
40
+ - thin 1.4.1 codename Chromeo
41
+ Transfer-Encoding:
42
+ - chunked
43
+ body:
44
+ encoding: US-ASCII
45
+ string: <html><body>You are being <a href="https://portal.vn.teslamotors.com/">redirected</a>.</body></html>
46
+ http_version:
47
+ recorded_at: Mon, 18 Feb 2013 01:17:12 GMT
48
+ - request:
49
+ method: get
50
+ uri: https://portal.vn.teslamotors.com/vehicles?
51
+ body:
52
+ encoding: US-ASCII
53
+ string: ''
54
+ headers:
55
+ Cookie:
56
+ - user_credentials=;
57
+ _s_portal_session=
58
+ response:
59
+ status:
60
+ code: 200
61
+ message: OK
62
+ headers:
63
+ Content-Type:
64
+ - application/json; charset=utf-8
65
+ X-Ua-Compatible:
66
+ - IE=Edge,chrome=1
67
+ Etag:
68
+ - ! '"cb4c586270e47aac1f5eba1873023ecd"'
69
+ Cache-Control:
70
+ - must-revalidate, private, max-age=0
71
+ Set-Cookie:
72
+ - _s_portal_session=;
73
+ path=/; secure; HttpOnly
74
+ X-Request-Id:
75
+ - 277fc8d63edb1757eba9da7085e47295
76
+ X-Runtime:
77
+ - '0.199410'
78
+ Date:
79
+ - Mon, 18 Feb 2013 01:17:09 GMT
80
+ X-Rack-Cache:
81
+ - miss
82
+ Server:
83
+ - thin 1.4.1 codename Chromeo
84
+ Transfer-Encoding:
85
+ - chunked
86
+ body:
87
+ encoding: US-ASCII
88
+ string: ! '[{"color":null,"display_name":null,"id":13,"option_codes":"MS01,RENA","user_id":21,"vehicle_id":1408,"vin":"5YJSA","tokens":["93b0e5b65b8a991b","d26a02e14e35b683"],"state":"online"}]'
89
+ http_version:
90
+ recorded_at: Mon, 18 Feb 2013 01:17:12 GMT
91
+ - request:
92
+ method: get
93
+ uri: https://portal.vn.teslamotors.com/vehicles/13/command/charge_state?
94
+ body:
95
+ encoding: US-ASCII
96
+ string: ''
97
+ headers:
98
+ Cookie:
99
+ - user_credentials=;
100
+ _s_portal_session=
101
+ response:
102
+ status:
103
+ code: 200
104
+ message: OK
105
+ headers:
106
+ Content-Type:
107
+ - application/json; charset=utf-8
108
+ X-Ua-Compatible:
109
+ - IE=Edge,chrome=1
110
+ Etag:
111
+ - ! '"2cd2d8f0cdfd9de62d0f7d5bf2eb45ee"'
112
+ Cache-Control:
113
+ - must-revalidate, private, max-age=0
114
+ Set-Cookie:
115
+ - _s_portal_session=;
116
+ path=/; secure; HttpOnly
117
+ X-Request-Id:
118
+ - d87d2062f387a0cfd3ee346e18e3e19f
119
+ X-Runtime:
120
+ - '3.207695'
121
+ Date:
122
+ - Mon, 18 Feb 2013 01:17:13 GMT
123
+ X-Rack-Cache:
124
+ - miss
125
+ Server:
126
+ - thin 1.4.1 codename Chromeo
127
+ Transfer-Encoding:
128
+ - chunked
129
+ body:
130
+ encoding: US-ASCII
131
+ string: ! '{"charging_state":"Disconnected","charge_to_max_range":false,"max_range_charge_counter":0,"fast_charger_present":false,"battery_range":177.38,"est_battery_range":143.96,"ideal_battery_range":204.15,"battery_level":70,"battery_current":-0.2,"charge_starting_range":null,"charge_starting_soc":null,"charger_voltage":0,"charger_pilot_current":0,"charger_actual_current":0,"charger_power":0,"time_to_full_charge":null,"charge_rate":-1.0,"charge_port_door_open":false}'
132
+ http_version:
133
+ recorded_at: Mon, 18 Feb 2013 01:17:16 GMT
134
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,134 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://portal.vn.teslamotors.com/login
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: !binary |-
9
+ foo==
10
+ headers:
11
+ Content-Type:
12
+ - application/x-www-form-urlencoded
13
+ response:
14
+ status:
15
+ code: 302
16
+ message: Found
17
+ headers:
18
+ Location:
19
+ - https://portal.vn.teslamotors.com/
20
+ Content-Type:
21
+ - text/html; charset=utf-8
22
+ X-Ua-Compatible:
23
+ - IE=Edge,chrome=1
24
+ Cache-Control:
25
+ - no-cache
26
+ Set-Cookie:
27
+ - _s_portal_session=;
28
+ path=/; secure; HttpOnly
29
+ - user_credentials=;
30
+ path=/; expires=Sat, 18-May-2013 01:17:15 GMT; secure; HttpOnly
31
+ X-Request-Id:
32
+ - bf34b1c07951c7806f4c121859ff9f57
33
+ X-Runtime:
34
+ - '1.469479'
35
+ Date:
36
+ - Mon, 18 Feb 2013 01:17:15 GMT
37
+ X-Rack-Cache:
38
+ - invalidate, pass
39
+ Server:
40
+ - thin 1.4.1 codename Chromeo
41
+ Transfer-Encoding:
42
+ - chunked
43
+ body:
44
+ encoding: US-ASCII
45
+ string: <html><body>You are being <a href="https://portal.vn.teslamotors.com/">redirected</a>.</body></html>
46
+ http_version:
47
+ recorded_at: Mon, 18 Feb 2013 01:17:19 GMT
48
+ - request:
49
+ method: get
50
+ uri: https://portal.vn.teslamotors.com/vehicles?
51
+ body:
52
+ encoding: US-ASCII
53
+ string: ''
54
+ headers:
55
+ Cookie:
56
+ - user_credentials=;
57
+ _s_portal_session=
58
+ response:
59
+ status:
60
+ code: 200
61
+ message: OK
62
+ headers:
63
+ Content-Type:
64
+ - application/json; charset=utf-8
65
+ X-Ua-Compatible:
66
+ - IE=Edge,chrome=1
67
+ Etag:
68
+ - ! '"cb4c586270e47aac1f5eba1873023ecd"'
69
+ Cache-Control:
70
+ - must-revalidate, private, max-age=0
71
+ Set-Cookie:
72
+ - _s_portal_session=;
73
+ path=/; secure; HttpOnly
74
+ X-Request-Id:
75
+ - 46e174a9e901fac481690ed5a752edd8
76
+ X-Runtime:
77
+ - '0.446955'
78
+ Date:
79
+ - Mon, 18 Feb 2013 01:17:16 GMT
80
+ X-Rack-Cache:
81
+ - miss
82
+ Server:
83
+ - thin 1.4.1 codename Chromeo
84
+ Transfer-Encoding:
85
+ - chunked
86
+ body:
87
+ encoding: US-ASCII
88
+ string: ! '[{"color":null,"display_name":null,"id":13,"option_codes":"MS01,RENA","user_id":21,"vehicle_id":1408,"vin":"5YJSA","tokens":["93b0e5b65b8a991b","d26a02e14e35b683"],"state":"online"}]'
89
+ http_version:
90
+ recorded_at: Mon, 18 Feb 2013 01:17:20 GMT
91
+ - request:
92
+ method: get
93
+ uri: https://portal.vn.teslamotors.com/vehicles/13/command/climate_state?
94
+ body:
95
+ encoding: US-ASCII
96
+ string: ''
97
+ headers:
98
+ Cookie:
99
+ - user_credentials=;
100
+ _s_portal_session=
101
+ response:
102
+ status:
103
+ code: 200
104
+ message: OK
105
+ headers:
106
+ Content-Type:
107
+ - application/json; charset=utf-8
108
+ X-Ua-Compatible:
109
+ - IE=Edge,chrome=1
110
+ Etag:
111
+ - ! '"6dda732efc65f4970f160272d4edf996"'
112
+ Cache-Control:
113
+ - must-revalidate, private, max-age=0
114
+ Set-Cookie:
115
+ - _s_portal_session=;
116
+ path=/; secure; HttpOnly
117
+ X-Request-Id:
118
+ - 97573a21767d48f7d804edc4ab74c64d
119
+ X-Runtime:
120
+ - '1.661360'
121
+ Date:
122
+ - Mon, 18 Feb 2013 01:17:18 GMT
123
+ X-Rack-Cache:
124
+ - miss
125
+ Server:
126
+ - thin 1.4.1 codename Chromeo
127
+ Transfer-Encoding:
128
+ - chunked
129
+ body:
130
+ encoding: US-ASCII
131
+ string: ! '{"inside_temp":null,"outside_temp":null,"driver_temp_setting":23.1,"passenger_temp_setting":23.1,"is_auto_conditioning_on":null,"is_front_defroster_on":null,"is_rear_defroster_on":false,"fan_status":null}'
132
+ http_version:
133
+ recorded_at: Mon, 18 Feb 2013 01:17:22 GMT
134
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,91 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://portal.vn.teslamotors.com/login
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: !binary |-
9
+ foo==
10
+ headers:
11
+ Content-Type:
12
+ - application/x-www-form-urlencoded
13
+ response:
14
+ status:
15
+ code: 302
16
+ message: Found
17
+ headers:
18
+ Location:
19
+ - https://portal.vn.teslamotors.com/
20
+ Content-Type:
21
+ - text/html; charset=utf-8
22
+ X-Ua-Compatible:
23
+ - IE=Edge,chrome=1
24
+ Cache-Control:
25
+ - no-cache
26
+ Set-Cookie:
27
+ - _s_portal_session=;
28
+ path=/; secure; HttpOnly
29
+ - user_credentials=;
30
+ path=/; expires=Sat, 18-May-2013 01:20:31 GMT; secure; HttpOnly
31
+ X-Request-Id:
32
+ - 7ce8d77dcd2e10cb81c0b3c98c9d4198
33
+ X-Runtime:
34
+ - '1.361939'
35
+ Date:
36
+ - Mon, 18 Feb 2013 01:20:31 GMT
37
+ X-Rack-Cache:
38
+ - invalidate, pass
39
+ Server:
40
+ - thin 1.4.1 codename Chromeo
41
+ Transfer-Encoding:
42
+ - chunked
43
+ body:
44
+ encoding: US-ASCII
45
+ string: <html><body>You are being <a href="https://portal.vn.teslamotors.com/">redirected</a>.</body></html>
46
+ http_version:
47
+ recorded_at: Mon, 18 Feb 2013 01:20:34 GMT
48
+ - request:
49
+ method: get
50
+ uri: https://portal.vn.teslamotors.com/vehicles?
51
+ body:
52
+ encoding: US-ASCII
53
+ string: ''
54
+ headers:
55
+ Cookie:
56
+ - user_credentials=;
57
+ _s_portal_session=
58
+ response:
59
+ status:
60
+ code: 200
61
+ message: OK
62
+ headers:
63
+ Content-Type:
64
+ - application/json; charset=utf-8
65
+ X-Ua-Compatible:
66
+ - IE=Edge,chrome=1
67
+ Etag:
68
+ - ! '"cb4c586270e47aac1f5eba1873023ecd"'
69
+ Cache-Control:
70
+ - must-revalidate, private, max-age=0
71
+ Set-Cookie:
72
+ - _s_portal_session=;
73
+ path=/; secure; HttpOnly
74
+ X-Request-Id:
75
+ - 6a1e7fa356d421956dd610fbbc1e40f7
76
+ X-Runtime:
77
+ - '0.022030'
78
+ Date:
79
+ - Mon, 18 Feb 2013 01:20:31 GMT
80
+ X-Rack-Cache:
81
+ - miss
82
+ Server:
83
+ - thin 1.4.1 codename Chromeo
84
+ Transfer-Encoding:
85
+ - chunked
86
+ body:
87
+ encoding: US-ASCII
88
+ string: ! '[{"color":null,"display_name":null,"id":13,"option_codes":"MS01,RENA","user_id":21,"vehicle_id":1408,"vin":"5YJSA","tokens":["93b0e5b65b8a991b","d26a02e14e35b683"],"state":"online"}]'
89
+ http_version:
90
+ recorded_at: Mon, 18 Feb 2013 01:20:35 GMT
91
+ recorded_with: VCR 2.4.0