tesla-fleet-api 0.0.5 → 0.0.7

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 (48) hide show
  1. package/dist/charging.d.ts +22 -0
  2. package/dist/charging.js +22 -0
  3. package/dist/charging.js.map +1 -1
  4. package/dist/energy.d.ts +75 -0
  5. package/dist/energy.js +76 -0
  6. package/dist/energy.js.map +1 -1
  7. package/dist/energyspecific.d.ts +59 -0
  8. package/dist/energyspecific.js +60 -0
  9. package/dist/energyspecific.js.map +1 -1
  10. package/dist/helpers.d.ts +2 -0
  11. package/dist/helpers.js +10 -0
  12. package/dist/helpers.js.map +1 -0
  13. package/dist/index.d.ts +5 -1
  14. package/dist/index.js +5 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/partner.d.ts +15 -0
  17. package/dist/partner.js +16 -0
  18. package/dist/partner.js.map +1 -1
  19. package/dist/teslafleetapi.d.ts +8 -0
  20. package/dist/teslafleetapi.js +9 -0
  21. package/dist/teslafleetapi.js.map +1 -1
  22. package/dist/teslemetry.d.ts +7 -0
  23. package/dist/teslemetry.js +7 -0
  24. package/dist/teslemetry.js.map +1 -1
  25. package/dist/tessie.d.ts +3 -0
  26. package/dist/tessie.js +3 -0
  27. package/dist/tessie.js.map +1 -1
  28. package/dist/types.d.ts +7 -0
  29. package/dist/types.js.map +1 -1
  30. package/dist/user.d.ts +11 -5
  31. package/dist/user.js +5 -0
  32. package/dist/user.js.map +1 -1
  33. package/dist/vehicle.d.ts +503 -64
  34. package/dist/vehicle.js +453 -0
  35. package/dist/vehicle.js.map +1 -1
  36. package/dist/vehiclespecific.d.ts +409 -63
  37. package/dist/vehiclespecific.js +349 -1
  38. package/dist/vehiclespecific.js.map +1 -1
  39. package/package.json +1 -1
  40. package/src/helpers.ts +11 -0
  41. package/src/index.ts +5 -1
  42. package/src/teslafleetapi.ts +8 -0
  43. package/src/teslemetry.ts +7 -2
  44. package/src/tessie.ts +3 -1
  45. package/src/types.ts +8 -0
  46. package/src/user.ts +6 -5
  47. package/src/vehicle.ts +91 -69
  48. package/src/vehiclespecific.ts +67 -63
package/dist/vehicle.js CHANGED
@@ -1,90 +1,233 @@
1
1
  import { ClimateModes, Seats } from "./types.js";
2
2
  import VehicleSpecific from "./vehiclespecific.js";
3
+ const Models = {
4
+ S: "Model S",
5
+ "3": "Model 3",
6
+ X: "Model X",
7
+ Y: "Model Y",
8
+ C: "Cybertruck",
9
+ T: "Semi",
10
+ };
3
11
  export default class Vehicle {
4
12
  constructor(parent) {
5
13
  this.parent = parent;
6
14
  }
15
+ /**
16
+ * Returns a class for a single vehicle.
17
+ * @param vin
18
+ * @returns
19
+ */
7
20
  specific(vin) {
8
21
  return new VehicleSpecific(this, vin);
9
22
  }
23
+ /**
24
+ * Return the vehicle model name
25
+ * @param vin
26
+ * @returns
27
+ */
28
+ model(vin) {
29
+ return Models?.[vin[3]] || "Unknown";
30
+ }
31
+ /**
32
+ * Return if the vehicle was build before 2021 and cannot sleep without a break
33
+ * @param vin
34
+ * @returns
35
+ */
36
+ pre2021(vin) {
37
+ return (vin[3] === "S" || vin[3] === "X") && vin[9] < "L";
38
+ }
39
+ // Vehicle Commands
40
+ /**
41
+ * Controls the front (which_trunk: "front") or rear (which_trunk: "rear") trunk.
42
+ * @param vehicle_tag VIN or id field of a vehicle
43
+ * @param which_trunk "front" or "rear"
44
+ */
10
45
  async actuate_truck(vehicle_tag, which_trunk) {
11
46
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/actuate_trunk`, null, { which_trunk });
12
47
  }
48
+ /**
49
+ * Adjusts vehicle media playback volume.
50
+ * @param vehicle_tag VIN or id field of a vehicle
51
+ * @param volume A floating point number from 0.0 to 11.0.
52
+ */
13
53
  async adjust_volume(vehicle_tag, volume) {
14
54
  if (volume < 0 || volume > 11) {
15
55
  throw new Error("Volume must a number from 0.0 to 11.0");
16
56
  }
17
57
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/adjust_volume`, null, { volume });
18
58
  }
59
+ /**
60
+ * Starts climate preconditioning.
61
+ * @param vehicle_tag VIN or id field of a vehicle
62
+ */
19
63
  async auto_conditioning_start(vehicle_tag) {
20
64
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/auto_conditioning_start`);
21
65
  }
66
+ /**
67
+ * Stops climate preconditioning.
68
+ * @param vehicle_tag VIN or id field of a vehicle
69
+ */
22
70
  async auto_conditioning_stop(vehicle_tag) {
23
71
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/auto_conditioning_stop`);
24
72
  }
73
+ /**
74
+ * Cancels the countdown to install the vehicle software update.
75
+ * @param vehicle_tag VIN or id field of a vehicle
76
+ */
25
77
  async cancel_software_update(vehicle_tag) {
26
78
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/cancel_software_update`);
27
79
  }
80
+ /**
81
+ * Charges in max range mode -- we recommend limiting the use of this mode to long trips.
82
+ * @param vehicle_tag VIN or id field of a vehicle
83
+ */
28
84
  async charge_max_range(vehicle_tag) {
29
85
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_max_range`);
30
86
  }
87
+ /**
88
+ * Closes the charge port door.
89
+ * @param vehicle_tag VIN or id field of a vehicle
90
+ */
31
91
  async charge_port_door_close(vehicle_tag) {
32
92
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_port_door_close`);
33
93
  }
94
+ /**
95
+ * Opens the charge port door.
96
+ * @param vehicle_tag VIN or id field of a vehicle
97
+ */
34
98
  async charge_port_door_open(vehicle_tag) {
35
99
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_port_door_open`);
36
100
  }
101
+ /**
102
+ * Charges in Standard mode.
103
+ * @param vehicle_tag VIN or id field of a vehicle
104
+ */
37
105
  async charge_standard(vehicle_tag) {
38
106
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_standard`);
39
107
  }
108
+ /**
109
+ * Starts charging the vehicle.
110
+ * @param vehicle_tag VIN or id field of a vehicle
111
+ */
40
112
  async charge_start(vehicle_tag) {
41
113
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_start`);
42
114
  }
115
+ /**
116
+ * Stops charging the vehicle.
117
+ * @param vehicle_tag VIN or id field of a vehicle
118
+ */
43
119
  async charge_stop(vehicle_tag) {
44
120
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_stop`);
45
121
  }
122
+ /**
123
+ * Deactivates PIN to Drive and resets the associated PIN for vehicles running firmware versions 2023.44+. This command is only accessible to fleet managers or owners.
124
+ * @param vehicle_tag VIN or id field of a vehicle
125
+ */
46
126
  async clear_pin_to_drive_admin(vehicle_tag) {
47
127
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/clear_pin_to_drive_admin`);
48
128
  }
129
+ /**
130
+ * Locks the vehicle.
131
+ * @param vehicle_tag VIN or id field of a vehicle
132
+ */
49
133
  async door_lock(vehicle_tag) {
50
134
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/door_lock`);
51
135
  }
136
+ /**
137
+ * Unlocks the vehicle.
138
+ * @param vehicle_tag VIN or id field of a vehicle
139
+ */
52
140
  async door_unlock(vehicle_tag) {
53
141
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/door_unlock`);
54
142
  }
143
+ /**
144
+ * Erases user's data from the user interface. Requires the vehicle to be in park.
145
+ * @param vehicle_tag VIN or id field of a vehicle
146
+ */
55
147
  async erase_user_data(vehicle_tag) {
56
148
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/erase_user_data`);
57
149
  }
150
+ /**
151
+ * Briefly flashes the vehicle headlights. Requires the vehicle to be in park.
152
+ * @param vehicle_tag VIN or id field of a vehicle
153
+ */
58
154
  async flash_lights(vehicle_tag) {
59
155
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/flash_lights`);
60
156
  }
157
+ /**
158
+ * Restricts certain vehicle UI functionality from guest users
159
+ * @param vehicle_tag VIN or id field of a vehicle
160
+ * @param enable `true` or `false`
161
+ */
61
162
  async guest_mode(vehicle_tag, enable) {
62
163
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/guest_mode`, null, { enable });
63
164
  }
165
+ /**
166
+ * Honks the vehicle horn. Requires the vehicle to be in park.
167
+ * @param vehicle_tag VIN or id field of a vehicle
168
+ */
64
169
  async honk_horn(vehicle_tag) {
65
170
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/honk_horn`);
66
171
  }
172
+ /**
173
+ * Advances media player to next favorite track.
174
+ * @param vehicle_tag VIN or id field of a vehicle
175
+ */
67
176
  async media_next_fav(vehicle_tag) {
68
177
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_next_fav`);
69
178
  }
179
+ /**
180
+ * Advances media player to next track.
181
+ * @param vehicle_tag VIN or id field of a vehicle
182
+ */
70
183
  async media_next_track(vehicle_tag) {
71
184
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_next_track`);
72
185
  }
186
+ /**
187
+ * Advances media player to previous favorite track.
188
+ * @param vehicle_tag VIN or id field of a vehicle
189
+ */
73
190
  async media_prev_fav(vehicle_tag) {
74
191
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_prev_fav`);
75
192
  }
193
+ /**
194
+ * Advances media player to previous track.
195
+ * @param vehicle_tag VIN or id field of a vehicle
196
+ */
76
197
  async media_prev_track(vehicle_tag) {
77
198
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_prev_track`);
78
199
  }
200
+ /**
201
+ * Toggles current play/pause state.
202
+ * @param vehicle_tag VIN or id field of a vehicle
203
+ */
79
204
  async media_toggle_playback(vehicle_tag) {
80
205
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_toggle_playback`);
81
206
  }
207
+ /**
208
+ * Turns the volume down by one.
209
+ * @param vehicle_tag VIN or id field of a vehicle
210
+ */
82
211
  async media_volume_down(vehicle_tag) {
83
212
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_volume_down`);
84
213
  }
214
+ /**
215
+ * Start navigation to given coordinates. Order can be used to specify order of multiple stops.
216
+ * @param vehicle_tag VIN or id field of a vehicle
217
+ * @param lat Latitude
218
+ * @param lon Longitude
219
+ * @param order Order of multiple stops
220
+ */
85
221
  async navigation_gps_request(vehicle_tag, lat, lon, order) {
86
222
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/navigation_gps_request`, null, { lat, lon, order });
87
223
  }
224
+ /**
225
+ * Sends a location to the in-vehicle navigation system.
226
+ * @param vehicle_tag VIN or id field of a vehicle
227
+ * @param type "share_ext_content_raw"
228
+ * @param locale ISO locale such as "en-US"
229
+ * @param timestamp_ms
230
+ */
88
231
  async navigation_request(vehicle_tag, value, locale, type = "share_ext_content_raw") {
89
232
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/navigation_request`, null, {
90
233
  type,
@@ -95,9 +238,22 @@ export default class Vehicle {
95
238
  },
96
239
  });
97
240
  }
241
+ /**
242
+ * Start navigation to a supercharger.
243
+ * @param vehicle_tag VIN or id field of a vehicle
244
+ * @param id Supercharger ID
245
+ * @param order Order of multiple stops
246
+ * @returns
247
+ */
98
248
  async navigation_sc_request(vehicle_tag, id, order) {
99
249
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/navigation_sc_request`, null, { id, order });
100
250
  }
251
+ /**
252
+ * Sets automatic seat heating and cooling.
253
+ * @param vehicle_tag VIN or id field of a vehicle
254
+ * @param auto_seat_position Seat position
255
+ * @param auto_climate_on `true` or `false`
256
+ */
101
257
  async remote_auto_seat_climate_request(vehicle_tag, auto_seat_position, auto_climate_on) {
102
258
  if (typeof auto_seat_position === "string") {
103
259
  auto_seat_position = Seats[auto_seat_position];
@@ -107,12 +263,28 @@ export default class Vehicle {
107
263
  auto_climate_on,
108
264
  });
109
265
  }
266
+ /**
267
+ * Sets automatic steering wheel heating on/off.
268
+ * @param vehicle_tag VIN or id field of a vehicle
269
+ * @param on `true` or `false`
270
+ */
110
271
  async remote_auto_steering_wheel_heat_climate_request(vehicle_tag, on) {
111
272
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_auto_steering_wheel_heat_climate_request`, null, { on });
112
273
  }
274
+ /**
275
+ * Plays a sound through the vehicle external speaker.
276
+ * @param vehicle_tag VIN or id field of a vehicle
277
+ * @param sound Fart is `0`, Locate ping is `2000`
278
+ */
113
279
  async remote_boombox(vehicle_tag, sound = 0) {
114
280
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_boombox`, null, { sound });
115
281
  }
282
+ /**
283
+ * Sets seat cooling.
284
+ * @param vehicle_tag VIN or id field of a vehicle
285
+ * @param seat_position Seat position
286
+ * @param seat_cooler_level Cooling level
287
+ */
116
288
  async remote_seat_cooler_request(vehicle_tag, seat_position, seat_cooler_level) {
117
289
  if (typeof seat_position === "string") {
118
290
  seat_position = Seats[seat_position];
@@ -122,6 +294,12 @@ export default class Vehicle {
122
294
  seat_cooler_level,
123
295
  });
124
296
  }
297
+ /**
298
+ * Sets seat heating.
299
+ * @param vehicle_tag VIN or id field of a vehicle
300
+ * @param seat_position Seat position
301
+ * @param seat_heater_level Heating level
302
+ */
125
303
  async remote_seat_heater_request(vehicle_tag, seat_position, seat_heater_level) {
126
304
  if (typeof seat_position === "string") {
127
305
  seat_position = Seats[seat_position];
@@ -131,42 +309,101 @@ export default class Vehicle {
131
309
  seat_heater_level,
132
310
  });
133
311
  }
312
+ /**
313
+ * Starts the vehicle remotely. Requires keyless driving to be enabled.
314
+ * @param vehicle_tag VIN or id field of a vehicle
315
+ */
134
316
  async remote_start_drive(vehicle_tag) {
135
317
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_start_drive`);
136
318
  }
319
+ /**
320
+ * Sets steering wheel heat level.
321
+ * @param vehicle_tag VIN or id field of a vehicle
322
+ * @param level Heating level
323
+ */
137
324
  async remote_steering_wheel_heat_level_request(vehicle_tag, level) {
138
325
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_steering_wheel_heat_level_request`, null, { level });
139
326
  }
327
+ /**
328
+ * Sets steering wheel heating on/off. For vehicles that do not support auto steering wheel heat.
329
+ * @param vehicle_tag VIN or id field of a vehicle
330
+ * @param on `true` or `false`
331
+ */
140
332
  async remote_steering_wheel_heater_request(vehicle_tag, on) {
141
333
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_steering_wheel_heater_request`, null, { on });
142
334
  }
335
+ /**
336
+ * Removes PIN to Drive. Requires the car to be in Pin to Drive mode and not in Valet mode. Note that this only works if PIN to Drive is not active. This command also requires the Tesla Vehicle Command Protocol - for more information, please see refer to the documentation here.
337
+ * @param vehicle_tag VIN or id field of a vehicle
338
+ */
143
339
  async reset_pin_to_drive_pin(vehicle_tag) {
144
340
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/reset_pin_to_drive_pin`);
145
341
  }
342
+ /**
343
+ * Removes PIN for Valet Mode.
344
+ * @param vehicle_tag VIN or id field of a vehicle
345
+ */
146
346
  async reset_valet_pin(vehicle_tag) {
147
347
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/reset_valet_pin`);
148
348
  }
349
+ /**
350
+ * Schedules a vehicle software update (over the air "OTA") to be installed in the future.
351
+ * @param vehicle_tag VIN or id field of a vehicle
352
+ * @param offset_sec Offset in seconds
353
+ */
149
354
  async schedule_software_update(vehicle_tag, offset_sec) {
150
355
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/schedule_software_update`, null, { offset_sec });
151
356
  }
357
+ /**
358
+ * Turns Bioweapon Defense Mode on and off.
359
+ * @param vehicle_tag VIN or id field of a vehicle
360
+ * @param on `true` or `false`
361
+ * @param manual_override `true` or `false`
362
+ */
152
363
  async set_bioweapon_mode(vehicle_tag, on, manual_override) {
153
364
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_bioweapon_mode`, null, { on, manual_override });
154
365
  }
366
+ /**
367
+ * Sets the vehicle overheat protection.
368
+ * @param vehicle_tag VIN or id field of a vehicle
369
+ * @param on `true` or `false`
370
+ * @param fan_only `true` or `false`
371
+ */
155
372
  async set_cabin_overheat_protection(vehicle_tag, on, fan_only) {
156
373
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_cabin_overheat_protection`, null, { on, fan_only });
157
374
  }
375
+ /**
376
+ * Sets the vehicle's charge limit to a custom percentage.
377
+ * @param vehicle_tag VIN or id field of a vehicle
378
+ * @param percent Charge limit percentage typically between 50-100
379
+ */
158
380
  async set_charge_limit(vehicle_tag, percent) {
159
381
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_charge_limit`, null, { percent });
160
382
  }
383
+ /**
384
+ * Sets the charge limit to the standard setting.
385
+ * @param vehicle_tag VIN or id field of a vehicle
386
+ * @param percent Current limit in Amps typically between 5-32
387
+ */
161
388
  async set_charging_amps(vehicle_tag, charging_amps) {
162
389
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_charging_amps`, null, { charging_amps });
163
390
  }
391
+ /**
392
+ * Enables climate keeper mode.
393
+ * @param vehicle_tag VIN or id field of a vehicle
394
+ * @param climate_keeper_mode `0` is Off, `1` is Keep, `2` is Dog, `3` is Camp
395
+ */
164
396
  async set_climate_keeper_mode(vehicle_tag, climate_keeper_mode) {
165
397
  if (typeof climate_keeper_mode === "string") {
166
398
  climate_keeper_mode = ClimateModes[climate_keeper_mode];
167
399
  }
168
400
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_climate_keeper_mode`, null, { climate_keeper_mode });
169
401
  }
402
+ /**
403
+ * Adjusts the Cabin Overheat Protection temperature (COP).
404
+ * @param vehicle_tag VIN or id field of a vehicle
405
+ * @param cop_temp Integer representing Low (0/30C/90F), Medium (1/35C/95F), or High (2/40C/100F)
406
+ */
170
407
  async set_cop_temp(vehicle_tag, cop_temp) {
171
408
  if (cop_temp >= 90) {
172
409
  cop_temp = (cop_temp - 90) / 5;
@@ -176,15 +413,45 @@ export default class Vehicle {
176
413
  }
177
414
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_cop_temp`, null, { cop_temp });
178
415
  }
416
+ /**
417
+ * Sets a four-digit passcode for PIN to Drive. This PIN must then be entered before the vehicle can be driven.
418
+ * @param vehicle_tag VIN or id field of a vehicle
419
+ * @param on `true` or `false`
420
+ * @param password Four-digit passcode
421
+ */
179
422
  async set_pin_to_drive(vehicle_tag, on, password) {
180
423
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_pin_to_drive`, null, { on, password: String(password) });
181
424
  }
425
+ /**
426
+ * Sets an override for preconditioning — it should default to empty if no override is used.
427
+ * Also known as "Defrost Mode"
428
+ * @param vehicle_tag VIN or id field of a vehicle
429
+ * @param on `true` or `false`
430
+ * @param manual_override `true` or `false`
431
+ */
182
432
  async set_preconditioning_max(vehicle_tag, on, manual_override) {
183
433
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_preconditioning_max`, null, { on, manual_override });
184
434
  }
435
+ /**
436
+ * Sets a time at which charging should be completed. The time parameter is minutes after midnight (e.g: time=120 schedules charging for 2:00am vehicle local time).
437
+ * @param vehicle_tag VIN or id field of a vehicle
438
+ * @param enable `true` or `false`
439
+ * @param time Minutes after midnight
440
+ */
185
441
  async set_scheduled_charging(vehicle_tag, enable, time) {
186
442
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_scheduled_charging`, null, { enable, time });
187
443
  }
444
+ /**
445
+ * Sets a time at which departure should be completed. The time parameter is minutes after midnight (e.g: time=120 schedules departure for 2:00am vehicle local time).
446
+ * @param vehicle_tag VIN or id field of a vehicle
447
+ * @param enable `true` or `false`
448
+ * @param preconditioning_enabled `true` or `false`
449
+ * @param preconditioning_weekdays_only `true` or `false`
450
+ * @param departure_time Minutes after midnight
451
+ * @param off_peak_charging_enabled `true` or `false`
452
+ * @param off_peak_charging_weekdays_only `true` or `false`
453
+ * @param end_off_peak_time Minutes after midnight
454
+ */
188
455
  async set_scheduled_departure(vehicle_tag, enable = true, preconditioning_enabled = false, preconditioning_weekdays_only = false, departure_time = 0, off_peak_charging_enabled = false, off_peak_charging_weekdays_only = false, end_off_peak_time = 0) {
189
456
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_scheduled_departure`, null, {
190
457
  enable,
@@ -196,119 +463,305 @@ export default class Vehicle {
196
463
  end_off_peak_time,
197
464
  });
198
465
  }
466
+ /**
467
+ * Enables and disables Sentry Mode. Sentry Mode allows customers to watch the vehicle cameras live from the mobile app, as well as record sentry events.
468
+ * @param vehicle_tag VIN or id field of a vehicle
469
+ * @param on `true` or `false`
470
+ */
199
471
  async set_sentry_mode(vehicle_tag, on) {
200
472
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_sentry_mode`, null, { on });
201
473
  }
474
+ /**
475
+ * Sets the driver and/or passenger-side cabin temperature (and other zones if sync is enabled).
476
+ * @param vehicle_tag VIN or id field of a vehicle
477
+ * @param driver_temp Driver temperature
478
+ * @param passenger_temp Passenger temperature
479
+ */
202
480
  async set_temps(vehicle_tag, driver_temp, passenger_temp) {
203
481
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_temps`, null, { driver_temp, passenger_temp });
204
482
  }
483
+ /**
484
+ * Turns on Valet Mode and sets a four-digit passcode that must then be entered to disable Valet Mode.
485
+ * @param vehicle_tag VIN or id field of a vehicle
486
+ * @param on `true` or `false`
487
+ * @param password Four-digit passcode
488
+ */
205
489
  async set_valet_mode(vehicle_tag, on, password) {
206
490
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_valet_mode`, null, { on, password: String(password) });
207
491
  }
492
+ /**
493
+ * Changes the name of a vehicle. This command also requires the Tesla Vehicle Command Protocol - for more information, please see refer to the documentation here.
494
+ * @param vehicle_tag VIN or id field of a vehicle
495
+ * @param vehicle_name New name
496
+ */
208
497
  async set_vehicle_name(vehicle_tag, vehicle_name) {
209
498
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_vehicle_name`, null, { vehicle_name });
210
499
  }
500
+ /**
501
+ * Activates Speed Limit Mode with a four-digit PIN.
502
+ * @param vehicle_tag VIN or id field of a vehicle
503
+ * @param pin Four-digit PIN
504
+ */
211
505
  async speed_limit_activate(vehicle_tag, pin) {
212
506
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_activate`, null, { pin: String(pin) });
213
507
  }
508
+ /**
509
+ * Deactivates Speed Limit Mode and resets the associated PIN.
510
+ * @param vehicle_tag VIN or id field of a vehicle
511
+ * @param pin Four-digit PIN
512
+ */
214
513
  async speed_limit_clear_pin(vehicle_tag, pin) {
215
514
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_clear_pin`, null, { pin: String(pin) });
216
515
  }
516
+ /**
517
+ * Deactivates Speed Limit Mode and resets the associated PIN for vehicles running firmware versions 2023.38+. This command is only accessible to fleet managers or owners.
518
+ * @param vehicle_tag VIN or id field of a vehicle
519
+ */
217
520
  async speed_limit_clear_pin_admin(vehicle_tag) {
218
521
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_clear_pin_admin`);
219
522
  }
523
+ /**
524
+ * Deactivates Speed Limit Mode.
525
+ * @param vehicle_tag VIN or id field of a vehicle
526
+ * @param pin Four-digit PIN
527
+ */
220
528
  async speed_limit_deactivate(vehicle_tag, pin) {
221
529
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_deactivate`, null, { pin: String(pin) });
222
530
  }
531
+ /**
532
+ * Sets the maximum speed allowed when Speed Limit Mode is active.
533
+ * @param vehicle_tag VIN or id field of a vehicle
534
+ * @param limit_mph Maximum speed in MPH
535
+ */
223
536
  async speed_limit_set_limit(vehicle_tag, limit_mph) {
224
537
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_set_limit`, null, { limit_mph });
225
538
  }
539
+ /**
540
+ * Controls the panoramic sunroof on the Model S.
541
+ * @param vehicle_tag VIN or id field of a vehicle
542
+ * @param state "stop", "close" or "vent"
543
+ */
226
544
  async sun_roof_control(vehicle_tag, state) {
227
545
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/sun_roof_control`, null, { state });
228
546
  }
547
+ /**
548
+ * Records a drive note. The note parameter is truncated to 80 characters in length.
549
+ * @param vehicle_tag VIN or id field of a vehicle
550
+ * @param note Drive note
551
+ */
229
552
  async take_drivenote(vehicle_tag, note) {
230
553
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/take_drivenote`, null, { note });
231
554
  }
555
+ /**
556
+ * Turns on HomeLink (used to open and close garage doors).
557
+ * @param vehicle_tag VIN or id field of a vehicle
558
+ * @param token
559
+ * @param lat Latitude
560
+ * @param lon Longitude
561
+ */
232
562
  async trigger_homelink(vehicle_tag, lat, lon, token) {
233
563
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/trigger_homelink`, null, { token, lat, lon });
234
564
  }
565
+ /**
566
+ * Upcoming calendar entries stored on the vehicle.
567
+ * @param vehicle_tag VIN or id field of a vehicle
568
+ * @param calendar_data Calendar data
569
+ */
235
570
  async upcoming_calendar_entries(vehicle_tag, calendar_data) {
236
571
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/upcoming_calendar_entries`, null, { calendar_data });
237
572
  }
573
+ /**
574
+ * Control the windows of a parked vehicle. Supported commands: vent and close. When closing, specify lat and lon of user to ensure they are within range of vehicle (unless this is an M3 platform vehicle).
575
+ * @param vehicle_tag VIN or id field of a vehicle
576
+ * @param command "vent" or "close"
577
+ * @param lat Latitude
578
+ * @param lon Longitude
579
+ */
238
580
  async window_control(vehicle_tag, command, lat, lon) {
239
581
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/window_control`, null, { command, lat, lon });
240
582
  }
583
+ // Vehicle Endpoints
584
+ /**
585
+ * Returns all allowed drivers for a vehicle. This endpoint is only available for the vehicle owner.
586
+ * @param vehicle_tag VIN or id field of a vehicle
587
+ */
241
588
  async drivers(vehicle_tag) {
242
589
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/drivers`);
243
590
  }
591
+ /**
592
+ * Removes driver access from a vehicle. Share users can only remove their own access. Owners can remove share access or their own.
593
+ * @param vehicle_tag VIN or id field of a vehicle
594
+ * @param share_user_id
595
+ */
244
596
  async drivers_remove(vehicle_tag, share_user_id) {
245
597
  return this.parent._request("DELETE", `api/1/vehicles/${vehicle_tag}/drivers`, null, { share_user_id });
246
598
  }
599
+ /**
600
+ * Returns eligible vehicle subscriptions.
601
+ * @param vin Vehicle Identification Number
602
+ */
247
603
  async eligible_subscriptions(vin) {
248
604
  return this.parent._request("GET", "/api/1/dx/vehicles/subscriptions/eligibility", { vin });
249
605
  }
606
+ /**
607
+ * Returns eligibile vehicle upgrades.
608
+ * @param vin Vehicle Identification Number
609
+ */
250
610
  async eligible_upgrades(vin) {
251
611
  return this.parent._request("GET", "/api/1/dx/vehicles/upgrades/eligibility", { vin });
252
612
  }
613
+ /**
614
+ * Checks whether vehicles can accept Tesla commands protocol for the partner's public key
615
+ * @param vins list of Vehicle Identification Number
616
+ * @returns
617
+ */
253
618
  async fleet_status(vins) {
254
619
  return this.parent._request("POST", "api/1/vehicles/fleet_status", null, { vins });
255
620
  }
621
+ /**
622
+ * Configures vehicles to connect to self-hosted fleet-telemetry server. This endpoint has concurrency 1 (status 429 will be returned if many calls are made at the same time). Multiple vehicles can be configured with a single call.
623
+ * @param config A dictionary description the fleet telemetry configuration
624
+ * @returns
625
+ */
256
626
  async fleet_telemetry_config(config) {
257
627
  return this.parent._request("POST", "api/1/vehicles/fleet_telemetry_config", null, config);
258
628
  }
629
+ /**
630
+ * Disconnects vehicles to stream telemetry data to self hosted fleet-telemetry server.
631
+ * @param vehicle_tag VIN or id field of a vehicle
632
+ * @returns
633
+ */
259
634
  async fleet_telemetry_config_delete(vehicle_tag) {
260
635
  return this.parent._request("DELETE", `api/1/vehicles/${vehicle_tag}/fleet_telemetry_config`);
261
636
  }
637
+ /**
638
+ * Fetches a vehicle's fleet telemetry config. synced set to true means the vehicle has adopted the target config. synced set to false means the vehicle will attempt to adopt the target config when it next establishes a backend connection.
639
+ * @param vehicle_tag VIN or id field of a vehicle
640
+ * @returns
641
+ */
262
642
  async fleet_telemetry_config_get(vehicle_tag) {
263
643
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/fleet_telemetry_config`);
264
644
  }
645
+ /**
646
+ * Returns vehicles belonging to the account.
647
+ * @param page Page number
648
+ * @param per_page Number of items per page
649
+ */
265
650
  async list(page, per_page) {
266
651
  return this.parent._request("GET", "api/1/vehicles", { page, per_page });
267
652
  }
653
+ /**
654
+ * Returns whether or not mobile access is enabled for the vehicle.
655
+ * @param vehicle_tag VIN or id field of a vehicle
656
+ */
268
657
  async mobile_enabled(vehicle_tag) {
269
658
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/mobile_enabled`);
270
659
  }
660
+ /**
661
+ * Returns the charging sites near the current location of the vehicle.
662
+ * @param vehicle_tag VIN or id field of a vehicle
663
+ * @param count
664
+ * @param radius
665
+ * @param detail
666
+ */
271
667
  async nearby_charging_sites(vehicle_tag, count, radius, detail) {
272
668
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/nearby_charging_sites`, { count, radius, detail });
273
669
  }
670
+ /**
671
+ * Returns vehicle option details.
672
+ * @param vin Vehicle Identification Number
673
+ */
274
674
  async options(vin) {
275
675
  return this.parent._request("GET", "api/1/dx/vehicles/options", { vin });
276
676
  }
677
+ /**
678
+ * List of recent alerts
679
+ * @param vehicle_tag VIN or id field of a vehicle
680
+ */
277
681
  async recent_alerts(vehicle_tag) {
278
682
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/recent_alerts`);
279
683
  }
684
+ /**
685
+ * Returns firmware release notes.
686
+ * @param vehicle_tag VIN or id field of a vehicle
687
+ * @param staged
688
+ * @param language
689
+ */
280
690
  async release_notes(vehicle_tag, staged, language) {
281
691
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/release_notes`, { staged, language });
282
692
  }
693
+ /**
694
+ * Returns service data.
695
+ * @param vehicle_tag VIN or id field of a vehicle
696
+ */
283
697
  async service_data(vehicle_tag) {
284
698
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/service_data`);
285
699
  }
700
+ /**
701
+ * Returns the share invites for a vehicle.
702
+ * @param vehicle_tag VIN or id field of a vehicle
703
+ */
286
704
  async share_invites(vehicle_tag) {
287
705
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/invitations`);
288
706
  }
707
+ /**
708
+ * Creates a share invite for a vehicle.
709
+ * @param vehicle_tag VIN or id field of a vehicle
710
+ */
289
711
  async share_invites_create(vehicle_tag) {
290
712
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/invitations`);
291
713
  }
714
+ /**
715
+ * Redeems a share invite.
716
+ * @param code
717
+ */
292
718
  async share_invites_redeem(code) {
293
719
  return this.parent._request("POST", "api/1/invitations/redeem", { code });
294
720
  }
721
+ /**
722
+ * Revokes a share invite.
723
+ * @param vehicle_tag VIN or id field of a vehicle
724
+ * @param id
725
+ */
295
726
  async share_invites_revoke(vehicle_tag, id) {
296
727
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/invitations/${id}/revoke`);
297
728
  }
729
+ /**
730
+ * Signed Commands is a generic endpoint replacing legacy commands.
731
+ * @param vehicle_tag VIN or id field of a vehicle
732
+ * @param routable_message
733
+ */
298
734
  async signed_command(vehicle_tag, routable_message) {
299
735
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/signed_command`, null, { routable_message });
300
736
  }
737
+ /**
738
+ * Returns information about a vehicle.
739
+ * @param vehicle_tag VIN or id field of a vehicle
740
+ */
301
741
  async vehicle(vehicle_tag) {
302
742
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}`);
303
743
  }
744
+ /**
745
+ * Makes a live call to the vehicle. This may return cached data if the vehicle is offline. For vehicles running firmware versions 2023.38+, location_data is required to fetch vehicle location. This will result in a location sharing icon to show on the vehicle UI.
746
+ * @param vehicle_tag VIN or id field of a vehicle
747
+ * @param endpoints
748
+ */
304
749
  async vehicle_data(vehicle_tag, endpoints) {
305
750
  if (typeof endpoints === "object")
306
751
  endpoints = endpoints.join(";");
307
752
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/vehicle_data`, null, { endpoints });
308
753
  }
754
+ /**
755
+ * Wakes the vehicle from sleep, which is a state to minimize idle energy consumption.
756
+ * @param vehicle_tag VIN or id field of a vehicle
757
+ */
309
758
  async wake_up(vehicle_tag) {
310
759
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/wake_up`);
311
760
  }
761
+ /**
762
+ * Returns warranty details.
763
+ * @param vin
764
+ */
312
765
  async warranty_details(vin) {
313
766
  return this.parent._request("GET", "api/1/dx/warranty/details", { vin });
314
767
  }