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