tesla-fleet-api 0.2.0 → 0.3.0

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