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