tesla-fleet-api 0.0.4 → 0.0.6

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/src/vehicle.ts CHANGED
@@ -1,7 +1,16 @@
1
1
  import TeslaFleetApi from "./teslafleetapi.js";
2
- import { ClimateMode, ClimateModes, FleetTelemetryConfig, Level, Seat, Seats, Trunk, VehicleDataEndpoint } from "./types.js";
2
+ import { ClimateMode, ClimateModes, CommandResponse, FleetTelemetryConfig, Level, Seat, Seats, Trunk, VehicleDataEndpoint } from "./types.js";
3
3
  import VehicleSpecific from "./vehiclespecific.js";
4
4
 
5
+ const Models: Record<string, string> = {
6
+ S: "Model S",
7
+ "3": "Model 3",
8
+ X: "Model X",
9
+ Y: "Model Y",
10
+ C: "Cybertruck",
11
+ T: "Semi",
12
+ };
13
+
5
14
  export default class Vehicle {
6
15
  parent: TeslaFleetApi;
7
16
 
@@ -14,10 +23,28 @@ export default class Vehicle {
14
23
  * @param vin
15
24
  * @returns
16
25
  */
17
- specific(vin: string): VehicleSpecific {
26
+ specific(vin: String): VehicleSpecific {
18
27
  return new VehicleSpecific(this, vin);
19
28
  }
20
29
 
30
+ /**
31
+ * Return the vehicle model name
32
+ * @param vin
33
+ * @returns
34
+ */
35
+ model(vin: String): String {
36
+ return Models?.[vin[3]] || "Unknown";
37
+ }
38
+
39
+ /**
40
+ * Return if the vehicle was build before 2021 and cannot sleep without a break
41
+ * @param vin
42
+ * @returns
43
+ */
44
+ pre2021(vin: String): Boolean {
45
+ return (vin[3] === "S" || vin[3] === "X") && vin[9] < "L";
46
+ }
47
+
21
48
  // Vehicle Commands
22
49
 
23
50
  /**
@@ -25,7 +52,7 @@ export default class Vehicle {
25
52
  * @param vehicle_tag VIN or id field of a vehicle
26
53
  * @param which_trunk "front" or "rear"
27
54
  */
28
- async actuate_truck(vehicle_tag: string | number, which_trunk: Trunk): Promise<Record<string, any>> {
55
+ async actuate_truck(vehicle_tag: string | number, which_trunk: Trunk): Promise<CommandResponse> {
29
56
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/actuate_trunk`, null, { which_trunk });
30
57
  }
31
58
 
@@ -34,7 +61,7 @@ export default class Vehicle {
34
61
  * @param vehicle_tag VIN or id field of a vehicle
35
62
  * @param volume A floating point number from 0.0 to 11.0.
36
63
  */
37
- async adjust_volume(vehicle_tag: string | number, volume: number): Promise<Record<string, any>> {
64
+ async adjust_volume(vehicle_tag: string | number, volume: number): Promise<CommandResponse> {
38
65
  if (volume < 0 || volume > 11) {
39
66
  throw new Error("Volume must a number from 0.0 to 11.0");
40
67
  }
@@ -45,7 +72,7 @@ export default class Vehicle {
45
72
  * Starts climate preconditioning.
46
73
  * @param vehicle_tag VIN or id field of a vehicle
47
74
  */
48
- async auto_conditioning_start(vehicle_tag: string | number): Promise<Record<string, any>> {
75
+ async auto_conditioning_start(vehicle_tag: string | number): Promise<CommandResponse> {
49
76
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/auto_conditioning_start`);
50
77
  }
51
78
 
@@ -53,7 +80,7 @@ export default class Vehicle {
53
80
  * Stops climate preconditioning.
54
81
  * @param vehicle_tag VIN or id field of a vehicle
55
82
  */
56
- async auto_conditioning_stop(vehicle_tag: string | number): Promise<Record<string, any>> {
83
+ async auto_conditioning_stop(vehicle_tag: string | number): Promise<CommandResponse> {
57
84
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/auto_conditioning_stop`);
58
85
  }
59
86
 
@@ -61,7 +88,7 @@ export default class Vehicle {
61
88
  * Cancels the countdown to install the vehicle software update.
62
89
  * @param vehicle_tag VIN or id field of a vehicle
63
90
  */
64
- async cancel_software_update(vehicle_tag: string | number): Promise<Record<string, any>> {
91
+ async cancel_software_update(vehicle_tag: string | number): Promise<CommandResponse> {
65
92
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/cancel_software_update`);
66
93
  }
67
94
 
@@ -69,7 +96,7 @@ export default class Vehicle {
69
96
  * Charges in max range mode -- we recommend limiting the use of this mode to long trips.
70
97
  * @param vehicle_tag VIN or id field of a vehicle
71
98
  */
72
- async charge_max_range(vehicle_tag: string | number): Promise<Record<string, any>> {
99
+ async charge_max_range(vehicle_tag: string | number): Promise<CommandResponse> {
73
100
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_max_range`);
74
101
  }
75
102
 
@@ -77,7 +104,7 @@ export default class Vehicle {
77
104
  * Closes the charge port door.
78
105
  * @param vehicle_tag VIN or id field of a vehicle
79
106
  */
80
- async charge_port_door_close(vehicle_tag: string | number): Promise<Record<string, any>> {
107
+ async charge_port_door_close(vehicle_tag: string | number): Promise<CommandResponse> {
81
108
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_port_door_close`);
82
109
  }
83
110
 
@@ -85,7 +112,7 @@ export default class Vehicle {
85
112
  * Opens the charge port door.
86
113
  * @param vehicle_tag VIN or id field of a vehicle
87
114
  */
88
- async charge_port_door_open(vehicle_tag: string | number): Promise<Record<string, any>> {
115
+ async charge_port_door_open(vehicle_tag: string | number): Promise<CommandResponse> {
89
116
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_port_door_open`);
90
117
  }
91
118
 
@@ -93,7 +120,7 @@ export default class Vehicle {
93
120
  * Charges in Standard mode.
94
121
  * @param vehicle_tag VIN or id field of a vehicle
95
122
  */
96
- async charge_standard(vehicle_tag: string | number): Promise<Record<string, any>> {
123
+ async charge_standard(vehicle_tag: string | number): Promise<CommandResponse> {
97
124
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_standard`);
98
125
  }
99
126
 
@@ -101,7 +128,7 @@ export default class Vehicle {
101
128
  * Starts charging the vehicle.
102
129
  * @param vehicle_tag VIN or id field of a vehicle
103
130
  */
104
- async charge_start(vehicle_tag: string | number): Promise<Record<string, any>> {
131
+ async charge_start(vehicle_tag: string | number): Promise<CommandResponse> {
105
132
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_start`);
106
133
  }
107
134
 
@@ -109,7 +136,7 @@ export default class Vehicle {
109
136
  * Stops charging the vehicle.
110
137
  * @param vehicle_tag VIN or id field of a vehicle
111
138
  */
112
- async charge_stop(vehicle_tag: string | number): Promise<Record<string, any>> {
139
+ async charge_stop(vehicle_tag: string | number): Promise<CommandResponse> {
113
140
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/charge_stop`);
114
141
  }
115
142
 
@@ -117,7 +144,7 @@ export default class Vehicle {
117
144
  * 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.
118
145
  * @param vehicle_tag VIN or id field of a vehicle
119
146
  */
120
- async clear_pin_to_drive_admin(vehicle_tag: string | number): Promise<Record<string, any>> {
147
+ async clear_pin_to_drive_admin(vehicle_tag: string | number): Promise<CommandResponse> {
121
148
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/clear_pin_to_drive_admin`);
122
149
  }
123
150
 
@@ -125,7 +152,7 @@ export default class Vehicle {
125
152
  * Locks the vehicle.
126
153
  * @param vehicle_tag VIN or id field of a vehicle
127
154
  */
128
- async door_lock(vehicle_tag: string | number): Promise<Record<string, any>> {
155
+ async door_lock(vehicle_tag: string | number): Promise<CommandResponse> {
129
156
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/door_lock`);
130
157
  }
131
158
 
@@ -133,7 +160,7 @@ export default class Vehicle {
133
160
  * Unlocks the vehicle.
134
161
  * @param vehicle_tag VIN or id field of a vehicle
135
162
  */
136
- async door_unlock(vehicle_tag: string | number): Promise<Record<string, any>> {
163
+ async door_unlock(vehicle_tag: string | number): Promise<CommandResponse> {
137
164
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/door_unlock`);
138
165
  }
139
166
 
@@ -141,7 +168,7 @@ export default class Vehicle {
141
168
  * Erases user's data from the user interface. Requires the vehicle to be in park.
142
169
  * @param vehicle_tag VIN or id field of a vehicle
143
170
  */
144
- async erase_user_data(vehicle_tag: string | number): Promise<Record<string, any>> {
171
+ async erase_user_data(vehicle_tag: string | number): Promise<CommandResponse> {
145
172
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/erase_user_data`);
146
173
  }
147
174
 
@@ -149,7 +176,7 @@ export default class Vehicle {
149
176
  * Briefly flashes the vehicle headlights. Requires the vehicle to be in park.
150
177
  * @param vehicle_tag VIN or id field of a vehicle
151
178
  */
152
- async flash_lights(vehicle_tag: string | number): Promise<Record<string, any>> {
179
+ async flash_lights(vehicle_tag: string | number): Promise<CommandResponse> {
153
180
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/flash_lights`);
154
181
  }
155
182
 
@@ -158,7 +185,7 @@ export default class Vehicle {
158
185
  * @param vehicle_tag VIN or id field of a vehicle
159
186
  * @param enable `true` or `false`
160
187
  */
161
- async guest_mode(vehicle_tag: string | number, enable: boolean): Promise<Record<string, any>> {
188
+ async guest_mode(vehicle_tag: string | number, enable: boolean): Promise<CommandResponse> {
162
189
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/guest_mode`, null, { enable });
163
190
  }
164
191
 
@@ -166,7 +193,7 @@ export default class Vehicle {
166
193
  * Honks the vehicle horn. Requires the vehicle to be in park.
167
194
  * @param vehicle_tag VIN or id field of a vehicle
168
195
  */
169
- async honk_horn(vehicle_tag: string | number): Promise<Record<string, any>> {
196
+ async honk_horn(vehicle_tag: string | number): Promise<CommandResponse> {
170
197
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/honk_horn`);
171
198
  }
172
199
 
@@ -174,7 +201,7 @@ export default class Vehicle {
174
201
  * Advances media player to next favorite track.
175
202
  * @param vehicle_tag VIN or id field of a vehicle
176
203
  */
177
- async media_next_fav(vehicle_tag: string | number): Promise<Record<string, any>> {
204
+ async media_next_fav(vehicle_tag: string | number): Promise<CommandResponse> {
178
205
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_next_fav`);
179
206
  }
180
207
 
@@ -182,7 +209,7 @@ export default class Vehicle {
182
209
  * Advances media player to next track.
183
210
  * @param vehicle_tag VIN or id field of a vehicle
184
211
  */
185
- async media_next_track(vehicle_tag: string | number): Promise<Record<string, any>> {
212
+ async media_next_track(vehicle_tag: string | number): Promise<CommandResponse> {
186
213
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_next_track`);
187
214
  }
188
215
 
@@ -190,7 +217,7 @@ export default class Vehicle {
190
217
  * Advances media player to previous favorite track.
191
218
  * @param vehicle_tag VIN or id field of a vehicle
192
219
  */
193
- async media_prev_fav(vehicle_tag: string | number): Promise<Record<string, any>> {
220
+ async media_prev_fav(vehicle_tag: string | number): Promise<CommandResponse> {
194
221
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_prev_fav`);
195
222
  }
196
223
 
@@ -198,7 +225,7 @@ export default class Vehicle {
198
225
  * Advances media player to previous track.
199
226
  * @param vehicle_tag VIN or id field of a vehicle
200
227
  */
201
- async media_prev_track(vehicle_tag: string | number): Promise<Record<string, any>> {
228
+ async media_prev_track(vehicle_tag: string | number): Promise<CommandResponse> {
202
229
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_prev_track`);
203
230
  }
204
231
 
@@ -206,7 +233,7 @@ export default class Vehicle {
206
233
  * Toggles current play/pause state.
207
234
  * @param vehicle_tag VIN or id field of a vehicle
208
235
  */
209
- async media_toggle_playback(vehicle_tag: string | number): Promise<Record<string, any>> {
236
+ async media_toggle_playback(vehicle_tag: string | number): Promise<CommandResponse> {
210
237
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_toggle_playback`);
211
238
  }
212
239
 
@@ -214,7 +241,7 @@ export default class Vehicle {
214
241
  * Turns the volume down by one.
215
242
  * @param vehicle_tag VIN or id field of a vehicle
216
243
  */
217
- async media_volume_down(vehicle_tag: string | number): Promise<Record<string, any>> {
244
+ async media_volume_down(vehicle_tag: string | number): Promise<CommandResponse> {
218
245
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/media_volume_down`);
219
246
  }
220
247
 
@@ -225,7 +252,7 @@ export default class Vehicle {
225
252
  * @param lon Longitude
226
253
  * @param order Order of multiple stops
227
254
  */
228
- async navigation_gps_request(vehicle_tag: string | number, lat: number, lon: number, order?: number): Promise<Record<string, any>> {
255
+ async navigation_gps_request(vehicle_tag: string | number, lat: number, lon: number, order?: number): Promise<CommandResponse> {
229
256
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/navigation_gps_request`, null, { lat, lon, order });
230
257
  }
231
258
 
@@ -236,12 +263,7 @@ export default class Vehicle {
236
263
  * @param locale ISO locale such as "en-US"
237
264
  * @param timestamp_ms
238
265
  */
239
- async navigation_request(
240
- vehicle_tag: string | number,
241
- value: string,
242
- locale: string,
243
- type: string = "share_ext_content_raw"
244
- ): Promise<Record<string, any>> {
266
+ async navigation_request(vehicle_tag: string | number, value: string, locale: string, type: string = "share_ext_content_raw"): Promise<CommandResponse> {
245
267
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/navigation_request`, null, {
246
268
  type,
247
269
  locale,
@@ -259,7 +281,7 @@ export default class Vehicle {
259
281
  * @param order Order of multiple stops
260
282
  * @returns
261
283
  */
262
- async navigation_sc_request(vehicle_tag: string | number, id: number, order?: number): Promise<Record<string, any>> {
284
+ async navigation_sc_request(vehicle_tag: string | number, id: number, order?: number): Promise<CommandResponse> {
263
285
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/navigation_sc_request`, null, { id, order });
264
286
  }
265
287
 
@@ -273,7 +295,7 @@ export default class Vehicle {
273
295
  vehicle_tag: string | number,
274
296
  auto_seat_position: Seat | number,
275
297
  auto_climate_on: boolean
276
- ): Promise<Record<string, any>> {
298
+ ): Promise<CommandResponse> {
277
299
  if (typeof auto_seat_position === "string") {
278
300
  auto_seat_position = Seats[auto_seat_position];
279
301
  }
@@ -288,7 +310,7 @@ export default class Vehicle {
288
310
  * @param vehicle_tag VIN or id field of a vehicle
289
311
  * @param on `true` or `false`
290
312
  */
291
- async remote_auto_steering_wheel_heat_climate_request(vehicle_tag: string | number, on: boolean): Promise<Record<string, any>> {
313
+ async remote_auto_steering_wheel_heat_climate_request(vehicle_tag: string | number, on: boolean): Promise<CommandResponse> {
292
314
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_auto_steering_wheel_heat_climate_request`, null, { on });
293
315
  }
294
316
 
@@ -297,7 +319,7 @@ export default class Vehicle {
297
319
  * @param vehicle_tag VIN or id field of a vehicle
298
320
  * @param sound Fart is `0`, Locate ping is `2000`
299
321
  */
300
- async remote_boombox(vehicle_tag: string | number, sound: number = 0): Promise<Record<string, any>> {
322
+ async remote_boombox(vehicle_tag: string | number, sound: number = 0): Promise<CommandResponse> {
301
323
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_boombox`, null, { sound });
302
324
  }
303
325
 
@@ -307,7 +329,7 @@ export default class Vehicle {
307
329
  * @param seat_position Seat position
308
330
  * @param seat_cooler_level Cooling level
309
331
  */
310
- async remote_seat_cooler_request(vehicle_tag: string | number, seat_position: Seat | number, seat_cooler_level: Level): Promise<Record<string, any>> {
332
+ async remote_seat_cooler_request(vehicle_tag: string | number, seat_position: Seat | number, seat_cooler_level: Level): Promise<CommandResponse> {
311
333
  if (typeof seat_position === "string") {
312
334
  seat_position = Seats[seat_position];
313
335
  }
@@ -323,7 +345,7 @@ export default class Vehicle {
323
345
  * @param seat_position Seat position
324
346
  * @param seat_heater_level Heating level
325
347
  */
326
- async remote_seat_heater_request(vehicle_tag: string | number, seat_position: Seat | number, seat_heater_level: Level): Promise<Record<string, any>> {
348
+ async remote_seat_heater_request(vehicle_tag: string | number, seat_position: Seat | number, seat_heater_level: Level): Promise<CommandResponse> {
327
349
  if (typeof seat_position === "string") {
328
350
  seat_position = Seats[seat_position];
329
351
  }
@@ -337,7 +359,7 @@ export default class Vehicle {
337
359
  * Starts the vehicle remotely. Requires keyless driving to be enabled.
338
360
  * @param vehicle_tag VIN or id field of a vehicle
339
361
  */
340
- async remote_start_drive(vehicle_tag: string | number): Promise<Record<string, any>> {
362
+ async remote_start_drive(vehicle_tag: string | number): Promise<CommandResponse> {
341
363
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_start_drive`);
342
364
  }
343
365
 
@@ -346,7 +368,7 @@ export default class Vehicle {
346
368
  * @param vehicle_tag VIN or id field of a vehicle
347
369
  * @param level Heating level
348
370
  */
349
- async remote_steering_wheel_heat_level_request(vehicle_tag: string | number, level: Level): Promise<Record<string, any>> {
371
+ async remote_steering_wheel_heat_level_request(vehicle_tag: string | number, level: Level): Promise<CommandResponse> {
350
372
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_steering_wheel_heat_level_request`, null, { level });
351
373
  }
352
374
 
@@ -355,7 +377,7 @@ export default class Vehicle {
355
377
  * @param vehicle_tag VIN or id field of a vehicle
356
378
  * @param on `true` or `false`
357
379
  */
358
- async remote_steering_wheel_heater_request(vehicle_tag: string | number, on: boolean): Promise<Record<string, any>> {
380
+ async remote_steering_wheel_heater_request(vehicle_tag: string | number, on: boolean): Promise<CommandResponse> {
359
381
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/remote_steering_wheel_heater_request`, null, { on });
360
382
  }
361
383
 
@@ -363,7 +385,7 @@ export default class Vehicle {
363
385
  * 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.
364
386
  * @param vehicle_tag VIN or id field of a vehicle
365
387
  */
366
- async reset_pin_to_drive_pin(vehicle_tag: string | number): Promise<Record<string, any>> {
388
+ async reset_pin_to_drive_pin(vehicle_tag: string | number): Promise<CommandResponse> {
367
389
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/reset_pin_to_drive_pin`);
368
390
  }
369
391
 
@@ -371,7 +393,7 @@ export default class Vehicle {
371
393
  * Removes PIN for Valet Mode.
372
394
  * @param vehicle_tag VIN or id field of a vehicle
373
395
  */
374
- async reset_valet_pin(vehicle_tag: string | number): Promise<Record<string, any>> {
396
+ async reset_valet_pin(vehicle_tag: string | number): Promise<CommandResponse> {
375
397
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/reset_valet_pin`);
376
398
  }
377
399
 
@@ -380,7 +402,7 @@ export default class Vehicle {
380
402
  * @param vehicle_tag VIN or id field of a vehicle
381
403
  * @param offset_sec Offset in seconds
382
404
  */
383
- async schedule_software_update(vehicle_tag: string | number, offset_sec: number): Promise<Record<string, any>> {
405
+ async schedule_software_update(vehicle_tag: string | number, offset_sec: number): Promise<CommandResponse> {
384
406
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/schedule_software_update`, null, { offset_sec });
385
407
  }
386
408
 
@@ -390,7 +412,7 @@ export default class Vehicle {
390
412
  * @param on `true` or `false`
391
413
  * @param manual_override `true` or `false`
392
414
  */
393
- async set_bioweapon_mode(vehicle_tag: string | number, on: boolean, manual_override: boolean): Promise<Record<string, any>> {
415
+ async set_bioweapon_mode(vehicle_tag: string | number, on: boolean, manual_override: boolean): Promise<CommandResponse> {
394
416
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_bioweapon_mode`, null, { on, manual_override });
395
417
  }
396
418
 
@@ -400,7 +422,7 @@ export default class Vehicle {
400
422
  * @param on `true` or `false`
401
423
  * @param fan_only `true` or `false`
402
424
  */
403
- async set_cabin_overheat_protection(vehicle_tag: string | number, on: boolean, fan_only: boolean): Promise<Record<string, any>> {
425
+ async set_cabin_overheat_protection(vehicle_tag: string | number, on: boolean, fan_only: boolean): Promise<CommandResponse> {
404
426
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_cabin_overheat_protection`, null, { on, fan_only });
405
427
  }
406
428
 
@@ -409,7 +431,7 @@ export default class Vehicle {
409
431
  * @param vehicle_tag VIN or id field of a vehicle
410
432
  * @param percent Charge limit percentage typically between 50-100
411
433
  */
412
- async set_charge_limit(vehicle_tag: string | number, percent: number): Promise<Record<string, any>> {
434
+ async set_charge_limit(vehicle_tag: string | number, percent: number): Promise<CommandResponse> {
413
435
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_charge_limit`, null, { percent });
414
436
  }
415
437
 
@@ -418,7 +440,7 @@ export default class Vehicle {
418
440
  * @param vehicle_tag VIN or id field of a vehicle
419
441
  * @param percent Current limit in Amps typically between 5-32
420
442
  */
421
- async set_charging_amps(vehicle_tag: string | number, charging_amps: number): Promise<Record<string, any>> {
443
+ async set_charging_amps(vehicle_tag: string | number, charging_amps: number): Promise<CommandResponse> {
422
444
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_charging_amps`, null, { charging_amps });
423
445
  }
424
446
 
@@ -427,7 +449,7 @@ export default class Vehicle {
427
449
  * @param vehicle_tag VIN or id field of a vehicle
428
450
  * @param climate_keeper_mode `0` is Off, `1` is Keep, `2` is Dog, `3` is Camp
429
451
  */
430
- async set_climate_keeper_mode(vehicle_tag: string | number, climate_keeper_mode: number | ClimateMode): Promise<Record<string, any>> {
452
+ async set_climate_keeper_mode(vehicle_tag: string | number, climate_keeper_mode: number | ClimateMode): Promise<CommandResponse> {
431
453
  if (typeof climate_keeper_mode === "string") {
432
454
  climate_keeper_mode = ClimateModes[climate_keeper_mode];
433
455
  }
@@ -439,7 +461,7 @@ export default class Vehicle {
439
461
  * @param vehicle_tag VIN or id field of a vehicle
440
462
  * @param cop_temp Integer representing Low (0/30C/90F), Medium (1/35C/95F), or High (2/40C/100F)
441
463
  */
442
- async set_cop_temp(vehicle_tag: string | number, cop_temp: 0 | 1 | 2 | 30 | 35 | 40 | 90 | 95 | 100): Promise<Record<string, any>> {
464
+ async set_cop_temp(vehicle_tag: string | number, cop_temp: 0 | 1 | 2 | 30 | 35 | 40 | 90 | 95 | 100): Promise<CommandResponse> {
443
465
  if (cop_temp >= 90) {
444
466
  cop_temp = (cop_temp - 90) / 5;
445
467
  } else if (cop_temp >= 30) {
@@ -455,7 +477,7 @@ export default class Vehicle {
455
477
  * @param on `true` or `false`
456
478
  * @param password Four-digit passcode
457
479
  */
458
- async set_pin_to_drive(vehicle_tag: string | number, on: boolean, password: string | number): Promise<Record<string, any>> {
480
+ async set_pin_to_drive(vehicle_tag: string | number, on: boolean, password: string | number): Promise<CommandResponse> {
459
481
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_pin_to_drive`, null, { on, password: String(password) });
460
482
  }
461
483
 
@@ -466,7 +488,7 @@ export default class Vehicle {
466
488
  * @param on `true` or `false`
467
489
  * @param manual_override `true` or `false`
468
490
  */
469
- async set_preconditioning_max(vehicle_tag: string | number, on: boolean, manual_override: boolean): Promise<Record<string, any>> {
491
+ async set_preconditioning_max(vehicle_tag: string | number, on: boolean, manual_override: boolean): Promise<CommandResponse> {
470
492
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_preconditioning_max`, null, { on, manual_override });
471
493
  }
472
494
 
@@ -476,7 +498,7 @@ export default class Vehicle {
476
498
  * @param enable `true` or `false`
477
499
  * @param time Minutes after midnight
478
500
  */
479
- async set_scheduled_charging(vehicle_tag: string | number, enable: boolean, time: number): Promise<Record<string, any>> {
501
+ async set_scheduled_charging(vehicle_tag: string | number, enable: boolean, time: number): Promise<CommandResponse> {
480
502
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_scheduled_charging`, null, { enable, time });
481
503
  }
482
504
 
@@ -500,7 +522,7 @@ export default class Vehicle {
500
522
  off_peak_charging_enabled: boolean = false,
501
523
  off_peak_charging_weekdays_only: boolean = false,
502
524
  end_off_peak_time: number = 0
503
- ): Promise<Record<string, any>> {
525
+ ): Promise<CommandResponse> {
504
526
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_scheduled_departure`, null, {
505
527
  enable,
506
528
  preconditioning_enabled,
@@ -517,7 +539,7 @@ export default class Vehicle {
517
539
  * @param vehicle_tag VIN or id field of a vehicle
518
540
  * @param on `true` or `false`
519
541
  */
520
- async set_sentry_mode(vehicle_tag: string | number, on: boolean): Promise<Record<string, any>> {
542
+ async set_sentry_mode(vehicle_tag: string | number, on: boolean): Promise<CommandResponse> {
521
543
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_sentry_mode`, null, { on });
522
544
  }
523
545
 
@@ -527,7 +549,7 @@ export default class Vehicle {
527
549
  * @param driver_temp Driver temperature
528
550
  * @param passenger_temp Passenger temperature
529
551
  */
530
- async set_temps(vehicle_tag: string | number, driver_temp: number, passenger_temp: number): Promise<Record<string, any>> {
552
+ async set_temps(vehicle_tag: string | number, driver_temp: number, passenger_temp: number): Promise<CommandResponse> {
531
553
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_temps`, null, { driver_temp, passenger_temp });
532
554
  }
533
555
 
@@ -537,7 +559,7 @@ export default class Vehicle {
537
559
  * @param on `true` or `false`
538
560
  * @param password Four-digit passcode
539
561
  */
540
- async set_valet_mode(vehicle_tag: string | number, on: boolean, password: string | number): Promise<Record<string, any>> {
562
+ async set_valet_mode(vehicle_tag: string | number, on: boolean, password: string | number): Promise<CommandResponse> {
541
563
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_valet_mode`, null, { on, password: String(password) });
542
564
  }
543
565
 
@@ -546,7 +568,7 @@ export default class Vehicle {
546
568
  * @param vehicle_tag VIN or id field of a vehicle
547
569
  * @param vehicle_name New name
548
570
  */
549
- async set_vehicle_name(vehicle_tag: string | number, vehicle_name: string): Promise<Record<string, any>> {
571
+ async set_vehicle_name(vehicle_tag: string | number, vehicle_name: string): Promise<CommandResponse> {
550
572
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/set_vehicle_name`, null, { vehicle_name });
551
573
  }
552
574
 
@@ -555,7 +577,7 @@ export default class Vehicle {
555
577
  * @param vehicle_tag VIN or id field of a vehicle
556
578
  * @param pin Four-digit PIN
557
579
  */
558
- async speed_limit_activate(vehicle_tag: string | number, pin: string | number): Promise<Record<string, any>> {
580
+ async speed_limit_activate(vehicle_tag: string | number, pin: string | number): Promise<CommandResponse> {
559
581
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_activate`, null, { pin: String(pin) });
560
582
  }
561
583
 
@@ -564,7 +586,7 @@ export default class Vehicle {
564
586
  * @param vehicle_tag VIN or id field of a vehicle
565
587
  * @param pin Four-digit PIN
566
588
  */
567
- async speed_limit_clear_pin(vehicle_tag: string | number, pin: string | number): Promise<Record<string, any>> {
589
+ async speed_limit_clear_pin(vehicle_tag: string | number, pin: string | number): Promise<CommandResponse> {
568
590
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_clear_pin`, null, { pin: String(pin) });
569
591
  }
570
592
 
@@ -572,7 +594,7 @@ export default class Vehicle {
572
594
  * 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.
573
595
  * @param vehicle_tag VIN or id field of a vehicle
574
596
  */
575
- async speed_limit_clear_pin_admin(vehicle_tag: string | number): Promise<Record<string, any>> {
597
+ async speed_limit_clear_pin_admin(vehicle_tag: string | number): Promise<CommandResponse> {
576
598
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_clear_pin_admin`);
577
599
  }
578
600
 
@@ -581,7 +603,7 @@ export default class Vehicle {
581
603
  * @param vehicle_tag VIN or id field of a vehicle
582
604
  * @param pin Four-digit PIN
583
605
  */
584
- async speed_limit_deactivate(vehicle_tag: string | number, pin: string | number): Promise<Record<string, any>> {
606
+ async speed_limit_deactivate(vehicle_tag: string | number, pin: string | number): Promise<CommandResponse> {
585
607
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_deactivate`, null, { pin: String(pin) });
586
608
  }
587
609
 
@@ -590,7 +612,7 @@ export default class Vehicle {
590
612
  * @param vehicle_tag VIN or id field of a vehicle
591
613
  * @param limit_mph Maximum speed in MPH
592
614
  */
593
- async speed_limit_set_limit(vehicle_tag: string | number, limit_mph: number): Promise<Record<string, any>> {
615
+ async speed_limit_set_limit(vehicle_tag: string | number, limit_mph: number): Promise<CommandResponse> {
594
616
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/speed_limit_set_limit`, null, { limit_mph });
595
617
  }
596
618
 
@@ -599,7 +621,7 @@ export default class Vehicle {
599
621
  * @param vehicle_tag VIN or id field of a vehicle
600
622
  * @param state "stop", "close" or "vent"
601
623
  */
602
- async sun_roof_control(vehicle_tag: string | number, state: "stop" | "close" | "vent"): Promise<Record<string, any>> {
624
+ async sun_roof_control(vehicle_tag: string | number, state: "stop" | "close" | "vent"): Promise<CommandResponse> {
603
625
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/sun_roof_control`, null, { state });
604
626
  }
605
627
 
@@ -608,7 +630,7 @@ export default class Vehicle {
608
630
  * @param vehicle_tag VIN or id field of a vehicle
609
631
  * @param note Drive note
610
632
  */
611
- async take_drivenote(vehicle_tag: string | number, note: string): Promise<Record<string, any>> {
633
+ async take_drivenote(vehicle_tag: string | number, note: string): Promise<CommandResponse> {
612
634
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/take_drivenote`, null, { note });
613
635
  }
614
636
 
@@ -619,7 +641,7 @@ export default class Vehicle {
619
641
  * @param lat Latitude
620
642
  * @param lon Longitude
621
643
  */
622
- async trigger_homelink(vehicle_tag: string | number, lat: number, lon: number, token?: string): Promise<Record<string, any>> {
644
+ async trigger_homelink(vehicle_tag: string | number, lat: number, lon: number, token?: string): Promise<CommandResponse> {
623
645
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/trigger_homelink`, null, { token, lat, lon });
624
646
  }
625
647
 
@@ -628,7 +650,7 @@ export default class Vehicle {
628
650
  * @param vehicle_tag VIN or id field of a vehicle
629
651
  * @param calendar_data Calendar data
630
652
  */
631
- async upcoming_calendar_entries(vehicle_tag: string | number, calendar_data: string): Promise<Record<string, any>> {
653
+ async upcoming_calendar_entries(vehicle_tag: string | number, calendar_data: string): Promise<CommandResponse> {
632
654
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/upcoming_calendar_entries`, null, { calendar_data });
633
655
  }
634
656
 
@@ -639,7 +661,7 @@ export default class Vehicle {
639
661
  * @param lat Latitude
640
662
  * @param lon Longitude
641
663
  */
642
- async window_control(vehicle_tag: string | number, command: "vent" | "close", lat: number, lon: number): Promise<Record<string, any>> {
664
+ async window_control(vehicle_tag: string | number, command: "vent" | "close", lat: number, lon: number): Promise<CommandResponse> {
643
665
  return this.parent._request("POST", `api/1/vehicles/${vehicle_tag}/command/window_control`, null, { command, lat, lon });
644
666
  }
645
667