tesla-fleet-api 0.0.6 → 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.
package/dist/vehicle.js CHANGED
@@ -12,93 +12,222 @@ export default class Vehicle {
12
12
  constructor(parent) {
13
13
  this.parent = parent;
14
14
  }
15
+ /**
16
+ * Returns a class for a single vehicle.
17
+ * @param vin
18
+ * @returns
19
+ */
15
20
  specific(vin) {
16
21
  return new VehicleSpecific(this, vin);
17
22
  }
23
+ /**
24
+ * Return the vehicle model name
25
+ * @param vin
26
+ * @returns
27
+ */
18
28
  model(vin) {
19
29
  return Models?.[vin[3]] || "Unknown";
20
30
  }
31
+ /**
32
+ * Return if the vehicle was build before 2021 and cannot sleep without a break
33
+ * @param vin
34
+ * @returns
35
+ */
21
36
  pre2021(vin) {
22
37
  return (vin[3] === "S" || vin[3] === "X") && vin[9] < "L";
23
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
+ */
24
45
  async actuate_truck(vehicle_tag, which_trunk) {
25
46
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/actuate_trunk`, null, { which_trunk });
26
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
+ */
27
53
  async adjust_volume(vehicle_tag, volume) {
28
54
  if (volume < 0 || volume > 11) {
29
55
  throw new Error("Volume must a number from 0.0 to 11.0");
30
56
  }
31
57
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/adjust_volume`, null, { volume });
32
58
  }
59
+ /**
60
+ * Starts climate preconditioning.
61
+ * @param vehicle_tag VIN or id field of a vehicle
62
+ */
33
63
  async auto_conditioning_start(vehicle_tag) {
34
64
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/auto_conditioning_start`);
35
65
  }
66
+ /**
67
+ * Stops climate preconditioning.
68
+ * @param vehicle_tag VIN or id field of a vehicle
69
+ */
36
70
  async auto_conditioning_stop(vehicle_tag) {
37
71
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/auto_conditioning_stop`);
38
72
  }
73
+ /**
74
+ * Cancels the countdown to install the vehicle software update.
75
+ * @param vehicle_tag VIN or id field of a vehicle
76
+ */
39
77
  async cancel_software_update(vehicle_tag) {
40
78
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/cancel_software_update`);
41
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
+ */
42
84
  async charge_max_range(vehicle_tag) {
43
85
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_max_range`);
44
86
  }
87
+ /**
88
+ * Closes the charge port door.
89
+ * @param vehicle_tag VIN or id field of a vehicle
90
+ */
45
91
  async charge_port_door_close(vehicle_tag) {
46
92
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_port_door_close`);
47
93
  }
94
+ /**
95
+ * Opens the charge port door.
96
+ * @param vehicle_tag VIN or id field of a vehicle
97
+ */
48
98
  async charge_port_door_open(vehicle_tag) {
49
99
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_port_door_open`);
50
100
  }
101
+ /**
102
+ * Charges in Standard mode.
103
+ * @param vehicle_tag VIN or id field of a vehicle
104
+ */
51
105
  async charge_standard(vehicle_tag) {
52
106
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_standard`);
53
107
  }
108
+ /**
109
+ * Starts charging the vehicle.
110
+ * @param vehicle_tag VIN or id field of a vehicle
111
+ */
54
112
  async charge_start(vehicle_tag) {
55
113
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_start`);
56
114
  }
115
+ /**
116
+ * Stops charging the vehicle.
117
+ * @param vehicle_tag VIN or id field of a vehicle
118
+ */
57
119
  async charge_stop(vehicle_tag) {
58
120
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_stop`);
59
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
+ */
60
126
  async clear_pin_to_drive_admin(vehicle_tag) {
61
127
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/clear_pin_to_drive_admin`);
62
128
  }
129
+ /**
130
+ * Locks the vehicle.
131
+ * @param vehicle_tag VIN or id field of a vehicle
132
+ */
63
133
  async door_lock(vehicle_tag) {
64
134
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/door_lock`);
65
135
  }
136
+ /**
137
+ * Unlocks the vehicle.
138
+ * @param vehicle_tag VIN or id field of a vehicle
139
+ */
66
140
  async door_unlock(vehicle_tag) {
67
141
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/door_unlock`);
68
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
+ */
69
147
  async erase_user_data(vehicle_tag) {
70
148
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/erase_user_data`);
71
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
+ */
72
154
  async flash_lights(vehicle_tag) {
73
155
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/flash_lights`);
74
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
+ */
75
162
  async guest_mode(vehicle_tag, enable) {
76
163
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/guest_mode`, null, { enable });
77
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
+ */
78
169
  async honk_horn(vehicle_tag) {
79
170
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/honk_horn`);
80
171
  }
172
+ /**
173
+ * Advances media player to next favorite track.
174
+ * @param vehicle_tag VIN or id field of a vehicle
175
+ */
81
176
  async media_next_fav(vehicle_tag) {
82
177
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_next_fav`);
83
178
  }
179
+ /**
180
+ * Advances media player to next track.
181
+ * @param vehicle_tag VIN or id field of a vehicle
182
+ */
84
183
  async media_next_track(vehicle_tag) {
85
184
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_next_track`);
86
185
  }
186
+ /**
187
+ * Advances media player to previous favorite track.
188
+ * @param vehicle_tag VIN or id field of a vehicle
189
+ */
87
190
  async media_prev_fav(vehicle_tag) {
88
191
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_prev_fav`);
89
192
  }
193
+ /**
194
+ * Advances media player to previous track.
195
+ * @param vehicle_tag VIN or id field of a vehicle
196
+ */
90
197
  async media_prev_track(vehicle_tag) {
91
198
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_prev_track`);
92
199
  }
200
+ /**
201
+ * Toggles current play/pause state.
202
+ * @param vehicle_tag VIN or id field of a vehicle
203
+ */
93
204
  async media_toggle_playback(vehicle_tag) {
94
205
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_toggle_playback`);
95
206
  }
207
+ /**
208
+ * Turns the volume down by one.
209
+ * @param vehicle_tag VIN or id field of a vehicle
210
+ */
96
211
  async media_volume_down(vehicle_tag) {
97
212
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_volume_down`);
98
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
+ */
99
221
  async navigation_gps_request(vehicle_tag, lat, lon, order) {
100
222
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/navigation_gps_request`, null, { lat, lon, order });
101
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
+ */
102
231
  async navigation_request(vehicle_tag, value, locale, type = "share_ext_content_raw") {
103
232
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/navigation_request`, null, {
104
233
  type,
@@ -109,9 +238,22 @@ export default class Vehicle {
109
238
  },
110
239
  });
111
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
+ */
112
248
  async navigation_sc_request(vehicle_tag, id, order) {
113
249
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/navigation_sc_request`, null, { id, order });
114
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
+ */
115
257
  async remote_auto_seat_climate_request(vehicle_tag, auto_seat_position, auto_climate_on) {
116
258
  if (typeof auto_seat_position === "string") {
117
259
  auto_seat_position = Seats[auto_seat_position];
@@ -121,12 +263,28 @@ export default class Vehicle {
121
263
  auto_climate_on,
122
264
  });
123
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
+ */
124
271
  async remote_auto_steering_wheel_heat_climate_request(vehicle_tag, on) {
125
272
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_auto_steering_wheel_heat_climate_request`, null, { on });
126
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
+ */
127
279
  async remote_boombox(vehicle_tag, sound = 0) {
128
280
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_boombox`, null, { sound });
129
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
+ */
130
288
  async remote_seat_cooler_request(vehicle_tag, seat_position, seat_cooler_level) {
131
289
  if (typeof seat_position === "string") {
132
290
  seat_position = Seats[seat_position];
@@ -136,6 +294,12 @@ export default class Vehicle {
136
294
  seat_cooler_level,
137
295
  });
138
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
+ */
139
303
  async remote_seat_heater_request(vehicle_tag, seat_position, seat_heater_level) {
140
304
  if (typeof seat_position === "string") {
141
305
  seat_position = Seats[seat_position];
@@ -145,42 +309,101 @@ export default class Vehicle {
145
309
  seat_heater_level,
146
310
  });
147
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
+ */
148
316
  async remote_start_drive(vehicle_tag) {
149
317
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_start_drive`);
150
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
+ */
151
324
  async remote_steering_wheel_heat_level_request(vehicle_tag, level) {
152
325
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_steering_wheel_heat_level_request`, null, { level });
153
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
+ */
154
332
  async remote_steering_wheel_heater_request(vehicle_tag, on) {
155
333
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_steering_wheel_heater_request`, null, { on });
156
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
+ */
157
339
  async reset_pin_to_drive_pin(vehicle_tag) {
158
340
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/reset_pin_to_drive_pin`);
159
341
  }
342
+ /**
343
+ * Removes PIN for Valet Mode.
344
+ * @param vehicle_tag VIN or id field of a vehicle
345
+ */
160
346
  async reset_valet_pin(vehicle_tag) {
161
347
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/reset_valet_pin`);
162
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
+ */
163
354
  async schedule_software_update(vehicle_tag, offset_sec) {
164
355
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/schedule_software_update`, null, { offset_sec });
165
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
+ */
166
363
  async set_bioweapon_mode(vehicle_tag, on, manual_override) {
167
364
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_bioweapon_mode`, null, { on, manual_override });
168
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
+ */
169
372
  async set_cabin_overheat_protection(vehicle_tag, on, fan_only) {
170
373
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_cabin_overheat_protection`, null, { on, fan_only });
171
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
+ */
172
380
  async set_charge_limit(vehicle_tag, percent) {
173
381
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_charge_limit`, null, { percent });
174
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
+ */
175
388
  async set_charging_amps(vehicle_tag, charging_amps) {
176
389
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_charging_amps`, null, { charging_amps });
177
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
+ */
178
396
  async set_climate_keeper_mode(vehicle_tag, climate_keeper_mode) {
179
397
  if (typeof climate_keeper_mode === "string") {
180
398
  climate_keeper_mode = ClimateModes[climate_keeper_mode];
181
399
  }
182
400
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_climate_keeper_mode`, null, { climate_keeper_mode });
183
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
+ */
184
407
  async set_cop_temp(vehicle_tag, cop_temp) {
185
408
  if (cop_temp >= 90) {
186
409
  cop_temp = (cop_temp - 90) / 5;
@@ -190,15 +413,45 @@ export default class Vehicle {
190
413
  }
191
414
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_cop_temp`, null, { cop_temp });
192
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
+ */
193
422
  async set_pin_to_drive(vehicle_tag, on, password) {
194
423
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_pin_to_drive`, null, { on, password: String(password) });
195
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
+ */
196
432
  async set_preconditioning_max(vehicle_tag, on, manual_override) {
197
433
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_preconditioning_max`, null, { on, manual_override });
198
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
+ */
199
441
  async set_scheduled_charging(vehicle_tag, enable, time) {
200
442
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_scheduled_charging`, null, { enable, time });
201
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
+ */
202
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) {
203
456
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_scheduled_departure`, null, {
204
457
  enable,
@@ -210,119 +463,305 @@ export default class Vehicle {
210
463
  end_off_peak_time,
211
464
  });
212
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
+ */
213
471
  async set_sentry_mode(vehicle_tag, on) {
214
472
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_sentry_mode`, null, { on });
215
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
+ */
216
480
  async set_temps(vehicle_tag, driver_temp, passenger_temp) {
217
481
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_temps`, null, { driver_temp, passenger_temp });
218
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
+ */
219
489
  async set_valet_mode(vehicle_tag, on, password) {
220
490
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_valet_mode`, null, { on, password: String(password) });
221
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
+ */
222
497
  async set_vehicle_name(vehicle_tag, vehicle_name) {
223
498
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_vehicle_name`, null, { vehicle_name });
224
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
+ */
225
505
  async speed_limit_activate(vehicle_tag, pin) {
226
506
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_activate`, null, { pin: String(pin) });
227
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
+ */
228
513
  async speed_limit_clear_pin(vehicle_tag, pin) {
229
514
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_clear_pin`, null, { pin: String(pin) });
230
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
+ */
231
520
  async speed_limit_clear_pin_admin(vehicle_tag) {
232
521
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_clear_pin_admin`);
233
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
+ */
234
528
  async speed_limit_deactivate(vehicle_tag, pin) {
235
529
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_deactivate`, null, { pin: String(pin) });
236
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
+ */
237
536
  async speed_limit_set_limit(vehicle_tag, limit_mph) {
238
537
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_set_limit`, null, { limit_mph });
239
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
+ */
240
544
  async sun_roof_control(vehicle_tag, state) {
241
545
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/sun_roof_control`, null, { state });
242
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
+ */
243
552
  async take_drivenote(vehicle_tag, note) {
244
553
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/take_drivenote`, null, { note });
245
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
+ */
246
562
  async trigger_homelink(vehicle_tag, lat, lon, token) {
247
563
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/trigger_homelink`, null, { token, lat, lon });
248
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
+ */
249
570
  async upcoming_calendar_entries(vehicle_tag, calendar_data) {
250
571
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/upcoming_calendar_entries`, null, { calendar_data });
251
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
+ */
252
580
  async window_control(vehicle_tag, command, lat, lon) {
253
581
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/window_control`, null, { command, lat, lon });
254
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
+ */
255
588
  async drivers(vehicle_tag) {
256
589
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/drivers`);
257
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
+ */
258
596
  async drivers_remove(vehicle_tag, share_user_id) {
259
597
  return this.parent._request("DELETE", `api/1/vehicles/${vehicle_tag}/drivers`, null, { share_user_id });
260
598
  }
599
+ /**
600
+ * Returns eligible vehicle subscriptions.
601
+ * @param vin Vehicle Identification Number
602
+ */
261
603
  async eligible_subscriptions(vin) {
262
604
  return this.parent._request("GET", "/api/1/dx/vehicles/subscriptions/eligibility", { vin });
263
605
  }
606
+ /**
607
+ * Returns eligibile vehicle upgrades.
608
+ * @param vin Vehicle Identification Number
609
+ */
264
610
  async eligible_upgrades(vin) {
265
611
  return this.parent._request("GET", "/api/1/dx/vehicles/upgrades/eligibility", { vin });
266
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
+ */
267
618
  async fleet_status(vins) {
268
619
  return this.parent._request("POST", "api/1/vehicles/fleet_status", null, { vins });
269
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
+ */
270
626
  async fleet_telemetry_config(config) {
271
627
  return this.parent._request("POST", "api/1/vehicles/fleet_telemetry_config", null, config);
272
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
+ */
273
634
  async fleet_telemetry_config_delete(vehicle_tag) {
274
635
  return this.parent._request("DELETE", `api/1/vehicles/${vehicle_tag}/fleet_telemetry_config`);
275
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
+ */
276
642
  async fleet_telemetry_config_get(vehicle_tag) {
277
643
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/fleet_telemetry_config`);
278
644
  }
645
+ /**
646
+ * Returns vehicles belonging to the account.
647
+ * @param page Page number
648
+ * @param per_page Number of items per page
649
+ */
279
650
  async list(page, per_page) {
280
651
  return this.parent._request("GET", "api/1/vehicles", { page, per_page });
281
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
+ */
282
657
  async mobile_enabled(vehicle_tag) {
283
658
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/mobile_enabled`);
284
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
+ */
285
667
  async nearby_charging_sites(vehicle_tag, count, radius, detail) {
286
668
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/nearby_charging_sites`, { count, radius, detail });
287
669
  }
670
+ /**
671
+ * Returns vehicle option details.
672
+ * @param vin Vehicle Identification Number
673
+ */
288
674
  async options(vin) {
289
675
  return this.parent._request("GET", "api/1/dx/vehicles/options", { vin });
290
676
  }
677
+ /**
678
+ * List of recent alerts
679
+ * @param vehicle_tag VIN or id field of a vehicle
680
+ */
291
681
  async recent_alerts(vehicle_tag) {
292
682
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/recent_alerts`);
293
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
+ */
294
690
  async release_notes(vehicle_tag, staged, language) {
295
691
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/release_notes`, { staged, language });
296
692
  }
693
+ /**
694
+ * Returns service data.
695
+ * @param vehicle_tag VIN or id field of a vehicle
696
+ */
297
697
  async service_data(vehicle_tag) {
298
698
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/service_data`);
299
699
  }
700
+ /**
701
+ * Returns the share invites for a vehicle.
702
+ * @param vehicle_tag VIN or id field of a vehicle
703
+ */
300
704
  async share_invites(vehicle_tag) {
301
705
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/invitations`);
302
706
  }
707
+ /**
708
+ * Creates a share invite for a vehicle.
709
+ * @param vehicle_tag VIN or id field of a vehicle
710
+ */
303
711
  async share_invites_create(vehicle_tag) {
304
712
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/invitations`);
305
713
  }
714
+ /**
715
+ * Redeems a share invite.
716
+ * @param code
717
+ */
306
718
  async share_invites_redeem(code) {
307
719
  return this.parent._request("POST", "api/1/invitations/redeem", { code });
308
720
  }
721
+ /**
722
+ * Revokes a share invite.
723
+ * @param vehicle_tag VIN or id field of a vehicle
724
+ * @param id
725
+ */
309
726
  async share_invites_revoke(vehicle_tag, id) {
310
727
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/invitations/${id}/revoke`);
311
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
+ */
312
734
  async signed_command(vehicle_tag, routable_message) {
313
735
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/signed_command`, null, { routable_message });
314
736
  }
737
+ /**
738
+ * Returns information about a vehicle.
739
+ * @param vehicle_tag VIN or id field of a vehicle
740
+ */
315
741
  async vehicle(vehicle_tag) {
316
742
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}`);
317
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
+ */
318
749
  async vehicle_data(vehicle_tag, endpoints) {
319
750
  if (typeof endpoints === "object")
320
751
  endpoints = endpoints.join(";");
321
752
  return this.parent._request("GET", `api/1/vehicles/${vehicle_tag}/vehicle_data`, null, { endpoints });
322
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
+ */
323
758
  async wake_up(vehicle_tag) {
324
759
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/wake_up`);
325
760
  }
761
+ /**
762
+ * Returns warranty details.
763
+ * @param vin
764
+ */
326
765
  async warranty_details(vin) {
327
766
  return this.parent._request("GET", "api/1/dx/warranty/details", { vin });
328
767
  }