tesla_api 3.0.4 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc39a9565be19773d6cb2e07f625fc6f6d1a7472ba4dbc7d77da49b01d8daff7
4
- data.tar.gz: 2cb34e0686652e67aa6ed566714723206c184f330be632dd484300b618d51e52
3
+ metadata.gz: 321a3deb2934f51a38bc1f3d427ceb123ebe2b8af3f5c7bba6453d66aedf40ab
4
+ data.tar.gz: a751ba87102749678d1ceb57e711050a19556344399c8da01adb06342c421802
5
5
  SHA512:
6
- metadata.gz: ff4c6fe5947a94979fba783e275870fe8fe4e55aa8525f4d8b1e8cd841bc7c4012be098b3bef66152103122fcb1c11ef7556ad0409e5183fa7dd5a07854647b3
7
- data.tar.gz: ab9903e449f7bcdfc8afca85fa6bfba69fccdb5b27e3a10c16ceae08633ed5c799df8ab04af7b4b99f0969ba81d2d7cd1e67a81787d3f9bb0c3244fda1c0e70c
6
+ metadata.gz: 134fc9efde3baf7d3d9b07d1bfe94f984a5c74799cd1c391f4df6bef6f718494da715b72a465d8e767dc04d15e5b49f659f4ecbb347bc52bebca69963b29d809
7
+ data.tar.gz: 2422bbf4044c8887d89f3d30a79cebf8e01eff9f0c9e544e87ac07bb1f9edd84b69b2f8b0916963347460436db8064a99dfe9299e259856b221b68fde3e100e4
@@ -1,6 +1,6 @@
1
1
  # Introduction
2
2
 
3
- This is unofficial documentation of the Tesla JSON API used by their iOS and Android apps. It features functionality to monitor and control their vehicle (Model S, Model X, and Model 3) and power (Powerwall) products. We currently have documentation for their vehicles, but always accept [pull requests](https://github.com/timdorr/tesla-api/pulls) for improvements and additions.
3
+ This is unofficial documentation of the Tesla JSON API used by their iOS and Android apps. It features functionality to monitor and control their vehicle (Models S, 3, X, Y) and power (Powerwall) products. We currently have documentation for their vehicles, but always accept [pull requests](https://github.com/timdorr/tesla-api/pulls) for improvements and additions.
4
4
 
5
5
  ## Before You Begin
6
6
 
@@ -35,7 +35,7 @@ Retrieve a list of your owned vehicles (includes vehicles not yet shipped!)
35
35
  "in_service": false,
36
36
  "id_s": "12345678901234567",
37
37
  "calendar_enabled": true,
38
- "api_version": 4,
38
+ "api_version": 7,
39
39
  "backseat_token": null,
40
40
  "backseat_token_updated_at": null
41
41
  }
@@ -50,9 +50,9 @@ These resources are read-only and determine the state of the vehicle's various s
50
50
 
51
51
  ### URL parameters
52
52
 
53
- | Field | Example | Description |
54
- | :--- | :--- | :--- |
55
- | `id` | `12345678901234567` | The `id` of the car. (Not the `vehicle_id`!) |
53
+ | Field | Example | Description |
54
+ | :---- | :------------------ | :------------------------------------------- |
55
+ | `id` | `12345678901234567` | The `id` of the car. (Not the `vehicle_id`!) |
56
56
 
57
57
  ### Response
58
58
 
@@ -70,10 +70,9 @@ These resources are read-only and determine the state of the vehicle's various s
70
70
  "in_service": false,
71
71
  "id_s": "12345678901234567",
72
72
  "calendar_enabled": true,
73
- "api_version": 4,
73
+ "api_version": 7,
74
74
  "backseat_token": null,
75
75
  "backseat_token_updated_at": null
76
76
  }
77
77
  }
78
78
  ```
79
-
@@ -1,6 +1,6 @@
1
1
  # Endpoints File
2
2
 
3
- This the latest contents of the ownerapi_endpoints.json file from the 3.10.0 version of the app.
3
+ This the latest contents of the ownerapi_endpoints.json file from the 3.10.2 version of the app.
4
4
 
5
5
  ```json
6
6
  {
@@ -329,7 +329,7 @@ This the latest contents of the ownerapi_endpoints.json file from the 3.10.0 ver
329
329
  "URI": "api/1/vehicles/{vehicle_id}/eligible_upgrades",
330
330
  "AUTH": true
331
331
  },
332
- "AUTOPILOT_UPGRADE_URL": {
332
+ "UPGRADE_URL": {
333
333
  "TYPE": "GET",
334
334
  "URI": "api/1/vehicles/{vehicle_id}/purchase_url",
335
335
  "AUTH": true
@@ -445,6 +445,11 @@ This the latest contents of the ownerapi_endpoints.json file from the 3.10.0 ver
445
445
  "URI": "api/1/energy_sites/{site_id}/backup",
446
446
  "AUTH": true
447
447
  },
448
+ "OFF_GRID_VEHICLE_CHARGING_RESERVE": {
449
+ "TYPE": "POST",
450
+ "URI": "api/1/energy_sites/{site_id}/off_grid_vehicle_charging_reserve",
451
+ "AUTH": true
452
+ },
448
453
  "SITE_NAME": {
449
454
  "TYPE": "POST",
450
455
  "URI": "api/1/energy_sites/{site_id}/site_name",
@@ -30,6 +30,8 @@ Stop the climate control (HVAC) system.
30
30
 
31
31
  Sets the target temperature for the climate control (HVAC) system.
32
32
 
33
+ Note: Despite accepting two parameters, only the `driver_temp` will be used to set the target temperature.
34
+
33
35
  Note: The parameters are always in celsius, regardless of the region the car is in or the display settings of the car.
34
36
 
35
37
  ### Parameters
@@ -8,7 +8,7 @@ Opens or closes the primary Homelink device. The provided location must be in pr
8
8
 
9
9
  | Parameter | Example | Description |
10
10
  | :-------- | :----------------- | :----------------- |
11
- | lat | 36.98765432109876 | Current lattitude. |
11
+ | lat | 36.98765432109876 | Current latitude. |
12
12
  | lon | -77.12345678901234 | Current longitude. |
13
13
 
14
14
  ### Response
@@ -4,7 +4,7 @@
4
4
 
5
5
  Sends a location for the car to start navigation or play a video in theatre mode.
6
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:
7
+ These docs take from the Android app, which sends the data in JSON form. However, a [URL-encoded](https://en.wikipedia.org/wiki/Percent-encoding) POST body will work as well. The basic format to a request looks like this:
8
8
 
9
9
  ```json
10
10
  {
@@ -24,7 +24,7 @@ Note: This API was previously `navigation_request`, but has been updated to supp
24
24
  | Parameter | Example | Description |
25
25
  | :------------------------------- | :-------------------------- | :------------------------------------------------------------- |
26
26
  | type | share_ext_content_raw | Must be `share_ext_content_raw`. |
27
- | locale | en-US | The locale for the navigation request. |
27
+ | locale | en-US | The locale for the navigation request. [ISO 639-1 standard language codes](https://www.andiamo.co.uk/resources/iso-language-codes/) |
28
28
  | timestamp_ms | 1539465730 | The current UNIX timestamp. |
29
29
  | value[android.intent.extra.TEXT] | 123 Main St, City, ST 12345 | The address or video URL to set as the navigation destination. |
30
30
 
@@ -4,16 +4,18 @@ Valet Mode limits the car's top speed to 70MPH and 80kW of acceleration power. I
4
4
  Wifi settings, and the ability to disable mobile access to the car. It also hides your favorites, home, and work
5
5
  locations in navigation.
6
6
 
7
+ Note: the `password` parameter isn't required to turn on or off Valet Mode, even with a previous PIN set. If you clear the PIN and activate Valet Mode without the parameter, you will only be able to deactivate it from your car's screen by signing into your Tesla account.
8
+
7
9
  ## POST `/api/1/vehicles/{id}/command/set_valet_mode`
8
10
 
9
11
  Activates or deactivates Valet Mode.
10
12
 
11
13
  ### Parameters
12
14
 
13
- | Parameter | Example | Description |
14
- | :-------- | :------ | :-------------------------------------------------------------------------------- |
15
- | on | true | true to activate, false to deactivate. Must include previous PIN if deactivating. |
16
- | password | 1234 | A PIN to deactivate Valet Mode. Can be blank if activating with a previous PIN. |
15
+ | Parameter | Example | Description |
16
+ | :-------- | :------ | :------------------------------------------------------------------------------ |
17
+ | on | true | true to activate, false to deactivate. |
18
+ | password | 1234 | A PIN to deactivate Valet Mode. Please see note about the `password` parameter. |
17
19
 
18
20
  ### Response
19
21
 
@@ -26,7 +28,7 @@ Activates or deactivates Valet Mode.
26
28
 
27
29
  ## POST `/api/1/vehicles/{id}/command/reset_valet_pin`
28
30
 
29
- Clears the currently set PIN for Valet Mode when deactivated. A new PIN will be required when activating again.
31
+ Clears the currently set PIN for Valet Mode when deactivated. A new PIN will be required when activating from the car screen. See the note above about activating via the API without a PIN set.
30
32
 
31
33
  ### Response
32
34
 
@@ -4,6 +4,9 @@
4
4
 
5
5
  Wakes up the car from a sleeping state.
6
6
 
7
+ The API will return a response immediately, however it could take several seconds before the car is actually online and ready to receive other commands.
8
+ One way to deal with this is to call this endpoint in a loop until the returned state says "online", with a timeout to give up. In some cases, the wake up can be slow, so consider using a timeout of atleast 30 seconds.
9
+
7
10
  ### Response
8
11
 
9
12
  ```json
@@ -21,7 +24,7 @@ Wakes up the car from a sleeping state.
21
24
  "in_service": false,
22
25
  "id_s": "12345678901234567",
23
26
  "calendar_enabled": true,
24
- "api_version": 4,
27
+ "api_version": 7,
25
28
  "backseat_token": null,
26
29
  "backseat_token_updated_at": null
27
30
  }
@@ -4,13 +4,17 @@
4
4
 
5
5
  Controls the windows. Will vent or close all windows simultaneously.
6
6
 
7
+ `lat` and `lon` values must be near the current location of the car for
8
+ `close` operation to succeed. For `vent`, the `lat` and `lon` values are
9
+ ignored, and may both be `0` (which has been observed from the app itself).
10
+
7
11
  ### Parameters
8
12
 
9
13
  | Parameter | Example | Description |
10
14
  | :-------- | :------ | :-------------------------------------------------------------------------- |
11
15
  | command | close | What action to take with the windows. Allows the values `vent` and `close`. |
12
- | lat | 0 | Seems to not care what this is, 0 is the only value sent by the app. |
13
- | lon | 0 | Seems to not care what this is, 0 is the only value sent by the app. |
16
+ | lat | 0 | Your current latitude. See Notes above. |
17
+ | lon | 0 | Your current longitude. See Notes above. |
14
18
 
15
19
  ### Response
16
20
 
@@ -10,6 +10,9 @@ edit this page and submit a_
10
10
  [_pull request_](https://github.com/timdorr/tesla-api/pulls)_. It is much
11
11
  appreciated!_
12
12
 
13
+ **As of August 2019, Option Codes cannot be relied on.** Vehicles now
14
+ return a generic set of codes related to a Model 3.
15
+
13
16
  | Code | Title | Description |
14
17
  | :--- | :--- | :--- |
15
18
  | MDLS | Model S | This vehicle is a Model S |
@@ -59,7 +62,7 @@ appreciated!_
59
62
  | BC0B | Black Brake Calipers | |
60
63
  | BC0R | Red Brake Calipers | |
61
64
  | BC3B | Black Brake Calipers, Model 3 | |
62
- | BCMB | Black Brake Calipers | |
65
+ | BCMB | Black Brake Calipers, Mando Brakes | |
63
66
  | BCYR | Performance Brakes | |
64
67
  | BG30 | No Badge | Model 3 |
65
68
  | BP00 | No Ludicrous | |
@@ -205,7 +208,7 @@ appreciated!_
205
208
  | PF01 | Performance Legacy Package | |
206
209
  | PI00 | No Premium Interior | |
207
210
  | PI01 | Premium Upgrades Package | |
208
- | PK00 | Parking Sensors | |
211
+ | PK00 | Parking Sensors | No Parking Sensors |
209
212
  | PMAB | Anza Brown Metallic Color | |
210
213
  | PMBL | Obsidian Black Multi-Coat Color | |
211
214
  | PMMB | Monterey Blue Metallic Color | |
@@ -288,14 +291,15 @@ appreciated!_
288
291
  | STY5S | Five Seat Interior | |
289
292
  | STY7S | Seven Seat Interior | |
290
293
  | SU00 | Standard Suspension | |
291
- | SU01 | Smart Air Suspension | |
294
+ | SU01 | Smart Air Suspension | |
295
+ | SU03 | Suspension Suspension Update | Model X 2020 |
292
296
  | SU3C | Suspension | Coil spring suspension |
293
297
  | T3MA | Tires M3 | 18 Michelin All Season, Square |
294
298
  | TIC4 | Tires | All-Season Tires |
295
299
  | TIG2 | Summer Tires | |
296
300
  | TIM7 | Summer Tires | |
297
301
  | TIMP | Tires | Michelin Primacy 19" Tire |
298
- | TIP0 | All-season Tires | |
302
+ | TIP0 | All-season Tires | Pirelli Scorpion Zero Asimmetrico 22” Tire |
299
303
  | TM00 | Model Trim | General Production Series Vehicle |
300
304
  | TM02 | General Production Signature Trim | |
301
305
  | TM0A | ALPHA PRE-PRODUCTION NON-SALEABLE | |
@@ -323,6 +327,7 @@ appreciated!_
323
327
  | SPT31 | Performance Upgrade | Model 3 |
324
328
  | SPTY1 | Performance Upgrade | Model Y |
325
329
  | W32P | 20" Performance Wheels | Model 3 |
330
+ | W32D | 20" Gray Performance Wheels | Model 3 |
326
331
  | W38B | 18" Aero Wheels | For the Model 3 and Model Y |
327
332
  | W39B | 19" Sport Wheels | |
328
333
  | WR00 | No Wrap | |
@@ -341,7 +346,7 @@ appreciated!_
341
346
  | WTSS | 21" Turbine Wheels | |
342
347
  | WTTB | 19" Cyclone Wheels | |
343
348
  | WTTC | 21" Sonic Carbon Twin Turbine Wheels | |
344
- | WTUT | 22" Onyx Black Wheels | |
349
+ | WTUT | 22" Onyx Black Wheels | 22" Ultrasonic Turbine wheels |
345
350
  | WTW2 | 19" Nokian Winter Wheel Set | |
346
351
  | WTW3 | 19" Pirelli Winter Wheel Set | |
347
352
  | WTW4 | 19" Winter Tire Set | |
@@ -366,7 +371,7 @@ appreciated!_
366
371
  | X001 | Override: Power Liftgate | |
367
372
  | X003 | Maps & Navigation | |
368
373
  | X004 | Override: No Navigation | |
369
- | X007 | Daytime running lights | |
374
+ | X007 | Exterior Lights Override: Premium exterior lighting YES | |
370
375
  | X010 | Base Mirrors | |
371
376
  | X011 | Override: Homelink | |
372
377
  | X012 | Override: No Homelink | |
@@ -377,6 +382,7 @@ appreciated!_
377
382
  | X021 | No Rear Carbon Fiber Spoiler | |
378
383
  | X024 | Performance Package | |
379
384
  | X025 | Performance Powertrain | |
385
+ | X026 | Door handle | No light handle |
380
386
  | X027 | Lighted Door Handles | Light handle |
381
387
  | X028 | Battery Badge | Normal Badging |
382
388
  | X029 | Remove Battery Badge | |
@@ -43,6 +43,7 @@ Information on the state of charge in the battery and its various settings.
43
43
  "managed_charging_start_time": null,
44
44
  "managed_charging_user_canceled": false,
45
45
  "max_range_charge_counter": 0,
46
+ "minutes_to_full_charge": 0,
46
47
  "not_enough_power_to_heat": false,
47
48
  "scheduled_charging_pending": false,
48
49
  "scheduled_charging_start_time": null,
@@ -12,6 +12,7 @@ Information on the current internal temperature and climate control system.
12
12
  "battery_heater": false,
13
13
  "battery_heater_no_power": false,
14
14
  "climate_keeper_mode": "dog",
15
+ "defrost_mode": 0,
15
16
  "driver_temp_setting": 21.6,
16
17
  "fan_status": 0,
17
18
  "inside_temp": null,
@@ -35,7 +36,6 @@ Information on the current internal temperature and climate control system.
35
36
  "seat_heater_rear_right_back": 0,
36
37
  "seat_heater_right": 2,
37
38
  "side_mirror_heaters": false,
38
- "smart_preconditioning": false,
39
39
  "steering_wheel_heater": false,
40
40
  "timestamp": 1543187641727,
41
41
  "wiper_blade_heater": false
@@ -4,7 +4,7 @@
4
4
 
5
5
  A rollup of all the `data_request` endpoints plus vehicle configuration.
6
6
 
7
- *Note:* all `*_range` values are in miles, irrespective of GUI configuration.
7
+ _Note:_ all `*_range` values are in miles, irrespective of GUI configuration.
8
8
 
9
9
  ### Response
10
10
 
@@ -23,7 +23,7 @@ A rollup of all the `data_request` endpoints plus vehicle configuration.
23
23
  "in_service": false,
24
24
  "id_s": "12345678901234567",
25
25
  "calendar_enabled": true,
26
- "api_version": 6,
26
+ "api_version": 7,
27
27
  "backseat_token": null,
28
28
  "backseat_token_updated_at": null,
29
29
  "drive_state": {
@@ -44,6 +44,7 @@ A rollup of all the `data_request` endpoints plus vehicle configuration.
44
44
  "battery_heater": false,
45
45
  "battery_heater_no_power": false,
46
46
  "climate_keeper_mode": "dog",
47
+ "defrost_mode": 0,
47
48
  "driver_temp_setting": 21.6,
48
49
  "fan_status": 0,
49
50
  "inside_temp": null,
@@ -67,7 +68,6 @@ A rollup of all the `data_request` endpoints plus vehicle configuration.
67
68
  "seat_heater_rear_right_back": 0,
68
69
  "seat_heater_right": 2,
69
70
  "side_mirror_heaters": false,
70
- "smart_preconditioning": false,
71
71
  "steering_wheel_heater": false,
72
72
  "timestamp": 1543186971731,
73
73
  "wiper_blade_heater": false
@@ -107,6 +107,7 @@ A rollup of all the `data_request` endpoints plus vehicle configuration.
107
107
  "managed_charging_start_time": null,
108
108
  "managed_charging_user_canceled": false,
109
109
  "max_range_charge_counter": 0,
110
+ "minutes_to_full_charge": 0,
110
111
  "not_enough_power_to_heat": false,
111
112
  "scheduled_charging_pending": false,
112
113
  "scheduled_charging_start_time": null,
@@ -122,34 +123,51 @@ A rollup of all the `data_request` endpoints plus vehicle configuration.
122
123
  "gui_distance_units": "mi/hr",
123
124
  "gui_range_display": "Rated",
124
125
  "gui_temperature_units": "F",
126
+ "show_range_units": true,
125
127
  "timestamp": 1543186971728
126
128
  },
127
129
  "vehicle_state": {
128
- "api_version": 6,
130
+ "api_version": 7,
129
131
  "autopark_state_v2": "standby",
130
132
  "autopark_style": "standard",
131
133
  "calendar_supported": true,
132
- "car_version": "2018.42.2 19e7e44",
134
+ "car_version": "2019.40.2.1 38f55d9f9205",
133
135
  "center_display_state": 0,
134
136
  "df": 0,
135
137
  "dr": 0,
138
+ "fd_window": 0,
139
+ "fp_window": 0,
136
140
  "ft": 0,
141
+ "homelink_device_count": 0,
137
142
  "homelink_nearby": true,
138
143
  "is_user_present": false,
139
144
  "last_autopark_error": "no_error",
140
145
  "locked": true,
141
- "media_state": { "remote_control_enabled": true },
146
+ "media_state": {
147
+ "remote_control_enabled": true
148
+ },
142
149
  "notifications_supported": true,
143
150
  "odometer": 33561.422505,
144
151
  "parsed_calendar_supported": true,
145
152
  "pf": 0,
146
153
  "pr": 0,
154
+ "rd_window": 0,
147
155
  "remote_start": false,
148
156
  "remote_start_enabled": true,
149
157
  "remote_start_supported": true,
158
+ "rp_window": 0,
150
159
  "rt": 0,
151
160
  "sentry_mode": true,
152
- "software_update": { "expected_duration_sec": 2700, "status": "" },
161
+ "sentry_mode_available": true,
162
+ "smart_summon_available": true,
163
+ "software_update": {
164
+ "download_perc": 100,
165
+ "expected_duration_sec": 2700,
166
+ "install_perc": 10,
167
+ "scheduled_time_ms": 1575689678432,
168
+ "status": "scheduled",
169
+ "version": "2019.40.2.1"
170
+ },
153
171
  "speed_limit_mode": {
154
172
  "active": false,
155
173
  "current_limit_mph": 75.0,
@@ -157,6 +175,7 @@ A rollup of all the `data_request` endpoints plus vehicle configuration.
157
175
  "min_limit_mph": 50,
158
176
  "pin_code_set": false
159
177
  },
178
+ "summon_standby_mode_enabled": true,
160
179
  "sun_roof_percent_open": 0,
161
180
  "sun_roof_state": "unknown",
162
181
  "timestamp": 1538364666096,
@@ -188,6 +207,7 @@ A rollup of all the `data_request` endpoints plus vehicle configuration.
188
207
  "third_row_seats": "None",
189
208
  "timestamp": 1538364666096,
190
209
  "trim_badging": "p90d",
210
+ "use_range_badging": false,
191
211
  "wheel_type": "AeroTurbine19"
192
212
  }
193
213
  }
@@ -14,6 +14,7 @@ Returns various information about the GUI settings of the car, such as unit form
14
14
  "gui_distance_units": "mi/hr",
15
15
  "gui_range_display": "Rated",
16
16
  "gui_temperature_units": "F",
17
+ "show_range_units": true,
17
18
  "timestamp": 1543187561462
18
19
  }
19
20
  }
@@ -4,36 +4,75 @@
4
4
 
5
5
  Returns the vehicle's physical state, such as which doors are open.
6
6
 
7
+ For the trunk (rt) and frunk (ft) fields, you should interpret a zero (0) value as closed and a non-zero value as open (partially or fully).
8
+
9
+ Here are the currently known values for the `center_display_state` field:
10
+
11
+ | State | Description |
12
+ | ----- | --------------- |
13
+ | 0 | Off |
14
+ | 2 | Normal On |
15
+ | 3 | Charging Screen |
16
+ | 7 | Sentry Mode |
17
+ | 8 | Dog Mode |
18
+
19
+ Here are the descriptions for the shorthand fields:
20
+
21
+ | Field | Description |
22
+ | ----- | --------------- |
23
+ | df | driver front |
24
+ | dr | driver rear |
25
+ | pf | passenger front |
26
+ | pr | passenger rear |
27
+ | ft | front trunk |
28
+ | rt | rear trunk |
29
+
7
30
  ### Response
8
31
 
9
32
  ```json
10
33
  {
11
34
  "response": {
12
- "api_version": 6,
13
- "autopark_state_v2": "ready",
14
- "autopark_style": "standard",
35
+ "api_version": 7,
36
+ "autopark_state_v3": "standby",
37
+ "autopark_style": "dead_man",
15
38
  "calendar_supported": true,
16
- "car_version": "2018.42.2 19e7e44",
39
+ "car_version": "2019.40.2.1 38f55d9f9205",
17
40
  "center_display_state": 0,
18
41
  "df": 0,
19
42
  "dr": 0,
43
+ "fd_window": 0,
44
+ "fp_window": 0,
20
45
  "ft": 0,
46
+ "homelink_device_count": 0,
21
47
  "homelink_nearby": true,
22
48
  "is_user_present": false,
23
49
  "last_autopark_error": "no_error",
24
50
  "locked": true,
25
- "media_state": { "remote_control_enabled": true },
51
+ "media_state": {
52
+ "remote_control_enabled": true
53
+ },
26
54
  "notifications_supported": true,
27
55
  "odometer": 36051.517239,
28
56
  "parsed_calendar_supported": true,
29
57
  "pf": 0,
30
58
  "pr": 0,
59
+ "rd_window": 0,
31
60
  "remote_start": false,
32
61
  "remote_start_enabled": true,
33
62
  "remote_start_supported": true,
63
+ "rp_window": 0,
34
64
  "rt": 0,
35
65
  "sentry_mode": true,
36
- "software_update": { "expected_duration_sec": 2700, "status": "" },
66
+ "sentry_mode_available": true,
67
+ "smart_summon_available": true,
68
+ "software_update": {
69
+ "download_perc": 100,
70
+ "expected_duration_sec": 2700,
71
+ "install_perc": 10,
72
+ "scheduled_time_ms": 1575689678432,
73
+ "status": "scheduled",
74
+ "version": "2019.40.2.1"
75
+ },
37
76
  "speed_limit_mode": {
38
77
  "active": false,
39
78
  "current_limit_mph": 50.0,
@@ -41,6 +80,7 @@ Returns the vehicle's physical state, such as which doors are open.
41
80
  "min_limit_mph": 50,
42
81
  "pin_code_set": false
43
82
  },
83
+ "summon_standby_mode_enabled": true,
44
84
  "sun_roof_percent_open": 0,
45
85
  "sun_roof_state": "unknown",
46
86
  "timestamp": 1543187581934,
@@ -50,12 +90,3 @@ Returns the vehicle's physical state, such as which doors are open.
50
90
  }
51
91
  }
52
92
  ```
53
-
54
- ### Center Display States
55
- | State | Description |
56
- |-------|-----------------|
57
- | 0 | Off |
58
- | 2 | Normal On |
59
- | 3 | Charging Screen |
60
- | 7 | Sentry Mode |
61
- | 8 | Dog Mode |
@@ -2,7 +2,7 @@ module TeslaApi
2
2
  class Client
3
3
  attr_reader :api, :email, :access_token, :access_token_expires_at, :refresh_token, :client_id, :client_secret
4
4
 
5
- BASE_URI = 'https://owner-api.teslamotors.com/api/1'
5
+ BASE_URI = 'https://owner-api.teslamotors.com'
6
6
 
7
7
  def initialize(
8
8
  email: nil,
@@ -10,9 +10,13 @@ module TeslaApi
10
10
  access_token_expires_at: nil,
11
11
  refresh_token: nil,
12
12
  client_id: ENV['TESLA_CLIENT_ID'],
13
- client_secret: ENV['TESLA_CLIENT_SECRET']
13
+ client_secret: ENV['TESLA_CLIENT_SECRET'],
14
+ retry_options: nil,
15
+ base_uri: nil,
16
+ client_options: {}
14
17
  )
15
18
  @email = email
19
+ @base_uri = base_uri || BASE_URI
16
20
 
17
21
  @client_id = client_id
18
22
  @client_secret = client_secret
@@ -22,19 +26,22 @@ module TeslaApi
22
26
  @refresh_token = refresh_token
23
27
 
24
28
  @api = Faraday.new(
25
- BASE_URI,
26
- headers: { 'User-Agent' => "github.com/timdorr/tesla-api v:#{VERSION}" }
29
+ @base_uri + '/api/1',
30
+ {
31
+ headers: { 'User-Agent' => "github.com/timdorr/tesla-api v:#{VERSION}" }
32
+ }.merge(client_options)
27
33
  ) do |conn|
28
34
  conn.request :json
29
35
  conn.response :json
30
36
  conn.response :raise_error
37
+ conn.request :retry, retry_options if retry_options # Must be registered after :raise_error
31
38
  conn.adapter Faraday.default_adapter
32
39
  end
33
40
  end
34
41
 
35
42
  def refresh_access_token
36
43
  response = api.post(
37
- 'https://owner-api.teslamotors.com/oauth/token',
44
+ @base_uri + '/oauth/token',
38
45
  {
39
46
  grant_type: 'refresh_token',
40
47
  client_id: client_id,
@@ -52,7 +59,7 @@ module TeslaApi
52
59
 
53
60
  def login!(password)
54
61
  response = api.post(
55
- 'https://owner-api.teslamotors.com/oauth/token',
62
+ @base_uri + '/oauth/token',
56
63
  {
57
64
  grant_type: 'password',
58
65
  client_id: client_id,
@@ -94,7 +94,7 @@ module TeslaApi
94
94
  end
95
95
 
96
96
  def set_charge_limit(percent)
97
- command('set_charge_limit', body: {percent: percent})['response']
97
+ command('set_charge_limit', body: {percent: percent.to_i})['response']
98
98
  end
99
99
 
100
100
  def charge_start
@@ -1,3 +1,3 @@
1
1
  module TeslaApi
2
- VERSION = '3.0.4'
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
@@ -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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tesla_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
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-10-14 00:00:00.000000000 Z
11
+ date: 2020-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-websocket
@@ -198,6 +198,7 @@ files:
198
198
  - lib/tesla_api/vehicle.rb
199
199
  - lib/tesla_api/version.rb
200
200
  - spec/cassettes/client-login.yml
201
+ - spec/cassettes/client-login_timeout.yml
201
202
  - spec/cassettes/client-refresh.yml
202
203
  - spec/cassettes/client-vehicles.yml
203
204
  - spec/cassettes/vehicle-activate_speed_limit.yml
@@ -263,7 +264,7 @@ homepage: https://github.com/timdorr/tesla-api
263
264
  licenses:
264
265
  - MIT
265
266
  metadata: {}
266
- post_install_message:
267
+ post_install_message:
267
268
  rdoc_options: []
268
269
  require_paths:
269
270
  - lib
@@ -278,12 +279,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
279
  - !ruby/object:Gem::Version
279
280
  version: '0'
280
281
  requirements: []
281
- rubygems_version: 3.0.6
282
- signing_key:
282
+ rubygems_version: 3.0.3
283
+ signing_key:
283
284
  specification_version: 4
284
285
  summary: A wrapper for the Tesla JSON API
285
286
  test_files:
286
287
  - spec/cassettes/client-login.yml
288
+ - spec/cassettes/client-login_timeout.yml
287
289
  - spec/cassettes/client-refresh.yml
288
290
  - spec/cassettes/client-vehicles.yml
289
291
  - spec/cassettes/vehicle-activate_speed_limit.yml