tesla-fleet-api 0.0.4__py3-none-any.whl → 0.0.5__py3-none-any.whl

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.
@@ -1,1490 +0,0 @@
1
- import aiohttp
2
- from .exceptions import raise_for_status, InvalidRegion, LibraryError
3
- from typing import Any
4
- from .const import (
5
- SERVERS,
6
- Methods,
7
- Trunks,
8
- ClimateKeeperMode,
9
- CabinOverheatProtectionTemps,
10
- VehicleDataEndpoints,
11
- SunRoofCommands,
12
- WindowCommands,
13
- DeviceTypes,
14
- )
15
-
16
-
17
- # Based on https://developer.tesla.com/docs/fleet-api
18
- class TeslaFleetApi:
19
- """Class describing the Tesla Fleet API."""
20
-
21
- server: str
22
- session: aiohttp.ClientSession
23
- headers: dict[str, str]
24
- raise_for_status: bool
25
-
26
- def __init__(
27
- self,
28
- session: aiohttp.ClientSession,
29
- access_token: str,
30
- use_command_protocol: bool = False,
31
- region: str | None = None,
32
- server: str | None = None,
33
- raise_for_status: bool = True,
34
- ):
35
- """Initialize the Tesla Fleet API."""
36
-
37
- self.session = session
38
- self.access_token = access_token
39
- self.use_command_protocol = use_command_protocol
40
-
41
- if region and not server and region not in SERVERS:
42
- raise ValueError(f"Region must be one of {", ".join(SERVERS.keys())}")
43
- self.server = server or SERVERS.get(region)
44
- self.raise_for_status = raise_for_status
45
-
46
- self.user = self.User(self)
47
- self.charging = self.Charging(self)
48
- self.partner = self.Partner(self)
49
- self.vehicle = self.Vehicle(self)
50
-
51
- async def find_server(self) -> None:
52
- """Find the server URL for the Tesla Fleet API."""
53
- for server in SERVERS.values():
54
- self.server = server
55
- try:
56
- await self.user.region()
57
- return
58
- except InvalidRegion:
59
- continue
60
- raise LibraryError("Could not find a valid Tesla API server.")
61
-
62
- async def _request(
63
- self,
64
- method: Methods,
65
- path: str,
66
- params: dict[str:Any] | None = None,
67
- data: dict[str:Any] | None = None,
68
- json: dict[str:Any] | None = None,
69
- ):
70
- """Send a request to the Tesla Fleet API."""
71
-
72
- if not self.server:
73
- raise ValueError("Server was not set at init. Call find_server() first.")
74
-
75
- if method == Methods.GET and (data is not None or json is not None):
76
- raise ValueError("GET requests cannot have data or json parameters.")
77
-
78
- if params:
79
- params = {k: v for k, v in params.items() if v is not None}
80
- if data:
81
- data = {k: v for k, v in data.items() if v is not None}
82
- if json:
83
- json = {k: v for k, v in json.items() if v is not None}
84
-
85
- async with self.session.request(
86
- method,
87
- f"{self.server}/{path}",
88
- headers={
89
- "Authorization": f"Bearer {self.access_token}",
90
- "Content-Type": "application/json",
91
- },
92
- data=data,
93
- json=json,
94
- params=params,
95
- ) as resp:
96
- if self.raise_for_status:
97
- await raise_for_status(resp)
98
- return await resp.json()
99
-
100
- async def status(self):
101
- """This endpoint returns the string "ok" if the API is operating normally. No HTTP headers are required."""
102
- if not self.server:
103
- raise ValueError("Server was not set at init. Call find_server() first.")
104
- async with self.session.get(f"{self.server}/status") as resp:
105
- return await resp.text()
106
-
107
- class Charging:
108
- """Class describing the Tesla Fleet API charging endpoints."""
109
-
110
- def __init__(self, parent):
111
- self._request = parent._request
112
-
113
- async def history(
114
- self,
115
- vin: str | None = None,
116
- startTime: str | None = None,
117
- endTime: str | None = None,
118
- pageNo: int | None = None,
119
- pageSize: int | None = None,
120
- sortBy: str | None = None,
121
- sortOrder: str | None = None,
122
- ) -> dict[str, Any]:
123
- """Returns the paginated charging history."""
124
- return await self._request(
125
- Methods.GET,
126
- "api/1/dx/charging/history",
127
- {
128
- vin: vin,
129
- startTime: startTime,
130
- endTime: endTime,
131
- pageNo: pageNo,
132
- pageSize: pageSize,
133
- sortBy: sortBy,
134
- sortOrder: sortOrder,
135
- },
136
- )
137
-
138
- async def sessions(
139
- self,
140
- vin: str | None = None,
141
- date_from: str | None = None,
142
- date_to: str | None = None,
143
- limit: int | None = None,
144
- offset: int | None = None,
145
- ) -> dict[str, Any]:
146
- """Returns the charging session information including pricing and energy data. This endpoint is only available for business accounts that own a fleet of vehicles."""
147
- return await self._request(
148
- Methods.GET,
149
- "api/1/dx/charging/sessions",
150
- {
151
- vin: vin,
152
- date_from: date_from,
153
- date_to: date_to,
154
- limit: limit,
155
- offset: offset,
156
- },
157
- )
158
-
159
- class Partner:
160
- """Class describing the Tesla Fleet API partner endpoints"""
161
-
162
- def __init__(self, parent):
163
- self._request = parent._request
164
-
165
- async def public_key(self, domain: str | None = None) -> dict[str, Any]:
166
- """Returns the public key associated with a domain. It can be used to ensure the registration was successful."""
167
- return await self._request(
168
- Methods.GET, "api/1/partner_accounts/public_key", data={domain: domain}
169
- )
170
-
171
- async def register(self, domain: str) -> dict[str, Any]:
172
- """Registers an existing account before it can be used for general API access. Each application from developer.tesla.com must complete this step."""
173
- return await self._request(
174
- Methods.POST, "api/1/partner_accounts", data={domain: domain}
175
- )
176
-
177
- class User:
178
- """Class describing the Tesla Fleet API user endpoints"""
179
-
180
- def __init__(self, parent):
181
- self._request = parent._request
182
-
183
- async def backup_key(self) -> dict[str, Any]:
184
- """Returns the public key associated with the user."""
185
- return await self._request(Methods.GET, "api/1/users/backup_key")
186
-
187
- async def feature_config(self) -> dict[str, Any]:
188
- """Returns any custom feature flag applied to a user."""
189
- return await self._request(Methods.GET, "api/1/users/feature_config")
190
-
191
- async def me(self) -> dict[str, Any]:
192
- """Returns a summary of a user's account."""
193
- return await self._request(Methods.GET, "api/1/users/me")
194
-
195
- async def orders(self) -> dict[str, Any]:
196
- """Returns the active orders for a user."""
197
- return await self._request(Methods.GET, "api/1/users/orders")
198
-
199
- async def region(self) -> dict[str, Any]:
200
- """Returns a user's region and appropriate fleet-api base URL. Accepts no parameters, response is based on the authentication token subject."""
201
- return await self._request(Methods.GET, "api/1/users/region")
202
-
203
- class Vehicle:
204
- """Class describing the Tesla Fleet API vehicle endpoints and commands."""
205
-
206
- def __init__(self, parent):
207
- self._parent = parent
208
- self._request = parent._request
209
- self.use_command_protocol = parent.use_command_protocol
210
-
211
- async def actuate_trunk(
212
- self, vehicle_tag: str | int, which_trunk: Trunks | str
213
- ) -> dict[str, Any]:
214
- """Controls the front or rear trunk."""
215
- if self.use_command_protocol:
216
- raise NotImplementedError("Command Protocol not implemented")
217
- return await self._request(
218
- Methods.POST,
219
- f"api/1/vehicles/{vehicle_tag}/command/actuate_trunk",
220
- json={which_trunk: which_trunk},
221
- )
222
-
223
- async def adjust_volume(
224
- self, vehicle_tag: str | int, volume: float
225
- ) -> dict[str, Any]:
226
- """Adjusts vehicle media playback volume."""
227
- if self.use_command_protocol:
228
- raise NotImplementedError("Command Protocol not implemented")
229
- if volume < 0.0 or volume > 11.0:
230
- raise ValueError("Volume must a number from 0.0 to 11.0")
231
- return await self._request(
232
- Methods.POST,
233
- f"api/1/vehicles/{vehicle_tag}/command/adjust_volume",
234
- json={volume: volume},
235
- )
236
-
237
- async def auto_conditioning_start(
238
- self, vehicle_tag: str | int
239
- ) -> dict[str, Any]:
240
- """Starts climate preconditioning."""
241
- if self.use_command_protocol:
242
- raise NotImplementedError("Command Protocol not implemented")
243
- return await self._request(
244
- Methods.POST,
245
- f"api/1/vehicles/{vehicle_tag}/command/auto_conditioning_start",
246
- )
247
-
248
- async def auto_conditioning_stop(
249
- self, vehicle_tag: str | int
250
- ) -> dict[str, Any]:
251
- """Stops climate preconditioning."""
252
- if self.use_command_protocol:
253
- raise NotImplementedError("Command Protocol not implemented")
254
- return await self._request(
255
- Methods.POST,
256
- f"api/1/vehicles/{vehicle_tag}/command/auto_conditioning_stop",
257
- )
258
-
259
- async def cancel_software_update(
260
- self, vehicle_tag: str | int
261
- ) -> dict[str, Any]:
262
- """Cancels the countdown to install the vehicle software update."""
263
- if self.use_command_protocol:
264
- raise NotImplementedError("Command Protocol not implemented")
265
- return await self._request(
266
- Methods.POST,
267
- f"api/1/vehicles/{vehicle_tag}/command/cancel_software_update",
268
- )
269
-
270
- async def charge_max_range(self, vehicle_tag: str | int) -> dict[str, Any]:
271
- """Charges in max range mode -- we recommend limiting the use of this mode to long trips."""
272
- if self.use_command_protocol:
273
- raise NotImplementedError("Command Protocol not implemented")
274
- return await self._request(
275
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/charge_max_range"
276
- )
277
-
278
- async def charge_port_door_close(
279
- self, vehicle_tag: str | int
280
- ) -> dict[str, Any]:
281
- """Closes the charge port door."""
282
- if self.use_command_protocol:
283
- raise NotImplementedError("Command Protocol not implemented")
284
- return await self._request(
285
- Methods.POST,
286
- f"api/1/vehicles/{vehicle_tag}/command/charge_port_door_close",
287
- )
288
-
289
- async def charge_port_door_open(self, vehicle_tag: str | int) -> dict[str, Any]:
290
- """Opens the charge port door."""
291
- if self.use_command_protocol:
292
- raise NotImplementedError("Command Protocol not implemented")
293
- return await self._request(
294
- Methods.POST,
295
- f"api/1/vehicles/{vehicle_tag}/command/charge_port_door_open",
296
- )
297
-
298
- async def charge_standard(self, vehicle_tag: str | int) -> dict[str, Any]:
299
- """Charges in Standard mode."""
300
- if self.use_command_protocol:
301
- raise NotImplementedError("Command Protocol not implemented")
302
- return await self._request(
303
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/charge_standard"
304
- )
305
-
306
- async def charge_start(self, vehicle_tag: str | int) -> dict[str, Any]:
307
- """Starts charging the vehicle."""
308
- if self.use_command_protocol:
309
- raise NotImplementedError("Command Protocol not implemented")
310
- return await self._request(
311
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/charge_start"
312
- )
313
-
314
- async def charge_stop(self, vehicle_tag: str | int) -> dict[str, Any]:
315
- """Stops charging the vehicle."""
316
- if self.use_command_protocol:
317
- raise NotImplementedError("Command Protocol not implemented")
318
- return await self._request(
319
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/charge_stop"
320
- )
321
-
322
- async def clear_pin_to_drive_admin(self, vehicle_tag: str | int):
323
- """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."""
324
- return await self._request(
325
- Methods.POST,
326
- f"api/1/vehicles/{vehicle_tag}/command/clear_pin_to_drive_admin",
327
- )
328
-
329
- async def door_lock(self, vehicle_tag: str | int) -> dict[str, Any]:
330
- """Locks the vehicle."""
331
- if self.use_command_protocol:
332
- raise NotImplementedError("Command Protocol not implemented")
333
- return await self._request(
334
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/door_lock"
335
- )
336
-
337
- async def door_unlock(self, vehicle_tag: str | int) -> dict[str, Any]:
338
- """Unlocks the vehicle."""
339
- if self.use_command_protocol:
340
- raise NotImplementedError("Command Protocol not implemented")
341
- return await self._request(
342
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/door_unlock"
343
- )
344
-
345
- async def erase_user_data(self, vehicle_tag: str | int) -> dict[str, Any]:
346
- """Erases user's data from the user interface. Requires the vehicle to be in park."""
347
- return await self._request(
348
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/erase_user_data"
349
- )
350
-
351
- async def flash_lights(self, vehicle_tag: str | int) -> dict[str, Any]:
352
- """Briefly flashes the vehicle headlights. Requires the vehicle to be in park."""
353
- if self.use_command_protocol:
354
- raise NotImplementedError("Command Protocol not implemented")
355
- return await self._request(
356
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/flash_lights"
357
- )
358
-
359
- async def guest_mode(
360
- self, vehicle_tag: str | int, enable: bool
361
- ) -> dict[str, Any]:
362
- """Restricts certain vehicle UI functionality from guest users"""
363
- if self.use_command_protocol:
364
- raise NotImplementedError("Command Protocol not implemented")
365
- return await self._request(
366
- Methods.POST,
367
- f"api/1/vehicles/{vehicle_tag}/command/guest_mode",
368
- json={enable: enable},
369
- )
370
-
371
- async def honk_horn(self, vehicle_tag: str | int) -> dict[str, Any]:
372
- """Honks the vehicle horn. Requires the vehicle to be in park."""
373
- if self.use_command_protocol:
374
- raise NotImplementedError("Command Protocol not implemented")
375
- return await self._request(
376
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/honk_horn"
377
- )
378
-
379
- async def media_next_fav(self, vehicle_tag: str | int) -> dict[str, Any]:
380
- """Advances media player to next favorite track."""
381
- return await self._request(
382
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/media_next_fav"
383
- )
384
-
385
- async def media_next_track(self, vehicle_tag: str | int) -> dict[str, Any]:
386
- """Advances media player to next track."""
387
- return await self._request(
388
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/media_next_track"
389
- )
390
-
391
- async def media_prev_fav(self, vehicle_tag: str | int) -> dict[str, Any]:
392
- """Advances media player to previous favorite track."""
393
- return await self._request(
394
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/media_prev_fav"
395
- )
396
-
397
- async def media_prev_track(self, vehicle_tag: str | int) -> dict[str, Any]:
398
- """Advances media player to previous track."""
399
- return await self._request(
400
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/media_prev_track"
401
- )
402
-
403
- async def media_toggle_playback(self, vehicle_tag: str | int) -> dict[str, Any]:
404
- """Toggles current play/pause state."""
405
- return await self._request(
406
- Methods.POST,
407
- f"api/1/vehicles/{vehicle_tag}/command/media_toggle_playback",
408
- )
409
-
410
- async def media_volume_down(self, vehicle_tag: str | int) -> dict[str, Any]:
411
- """Turns the volume down by one."""
412
- return await self._request(
413
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/media_volume_down"
414
- )
415
-
416
- async def navigation_gps_request(
417
- self, vehicle_tag: str | int, lat: float, lon: float, order: int
418
- ) -> dict[str, Any]:
419
- """Start navigation to given coordinates. Order can be used to specify order of multiple stops."""
420
- if self.use_command_protocol:
421
- raise NotImplementedError("Command Protocol not implemented")
422
- return await self._request(
423
- Methods.POST,
424
- f"api/1/vehicles/{vehicle_tag}/command/navigation_gps_request",
425
- json={lat: lat, lon: lon, order: order},
426
- )
427
-
428
- async def navigation_request(
429
- self, vehicle_tag: str | int, type: str, locale: str, timestamp_ms: str
430
- ) -> dict[str, Any]:
431
- """Sends a location to the in-vehicle navigation system."""
432
- return await self._request(
433
- Methods.POST,
434
- f"api/1/vehicles/{vehicle_tag}/command/navigation_request",
435
- json={type: type, locale: locale, timestamp_ms: timestamp_ms},
436
- )
437
-
438
- async def navigation_sc_request(
439
- self, vehicle_tag: str | int, id: int, order: int
440
- ) -> dict[str, Any]:
441
- """Sends a location to the in-vehicle navigation system."""
442
- return await self._request(
443
- Methods.POST,
444
- f"api/1/vehicles/{vehicle_tag}/command/navigation_sc_request",
445
- json={type: type, id: id, order: order},
446
- )
447
-
448
- async def remote_auto_seat_climate_request(
449
- self, vehicle_tag: str | int, auto_seat_position: int, auto_climate_on: bool
450
- ) -> dict[str, Any]:
451
- """Sets automatic seat heating and cooling."""
452
- if self.use_command_protocol:
453
- raise NotImplementedError("Command Protocol not implemented")
454
- return await self._request(
455
- Methods.POST,
456
- f"api/1/vehicles/{vehicle_tag}/command/remote_auto_seat_climate_request",
457
- json={
458
- auto_seat_position: auto_seat_position,
459
- auto_climate_on: auto_climate_on,
460
- },
461
- )
462
-
463
- async def remote_auto_steering_wheel_heat_climate_request(
464
- self, vehicle_tag: str | int, on: bool
465
- ) -> dict[str, Any]:
466
- """Sets automatic steering wheel heating on/off."""
467
- return await self._request(
468
- Methods.POST,
469
- f"api/1/vehicles/{vehicle_tag}/command/remote_auto_steering_wheel_heat_climate_request",
470
- json={on: on},
471
- )
472
-
473
- async def remote_boombox(
474
- self, vehicle_tag: str | int, sound: int
475
- ) -> dict[str, Any]:
476
- """Plays a sound through the vehicle external speaker."""
477
- return await self._request(
478
- Methods.POST,
479
- f"api/1/vehicles/{vehicle_tag}/command/remote_boombox",
480
- json={sound: sound},
481
- )
482
-
483
- async def remote_seat_cooler_request(
484
- self, vehicle_tag: str | int, seat_position: int, seat_cooler_level: int
485
- ) -> dict[str, Any]:
486
- """Sets seat cooling."""
487
- if self.use_command_protocol:
488
- raise NotImplementedError("Command Protocol not implemented")
489
- return await self._request(
490
- Methods.POST,
491
- f"api/1/vehicles/{vehicle_tag}/command/remote_seat_cooler_request",
492
- json={
493
- seat_position: seat_position,
494
- seat_cooler_level: seat_cooler_level,
495
- },
496
- )
497
-
498
- async def remote_seat_heater_request(
499
- self, vehicle_tag: str | int
500
- ) -> dict[str, Any]:
501
- """Sets seat heating."""
502
- if self.use_command_protocol:
503
- raise NotImplementedError("Command Protocol not implemented")
504
- return await self._request(
505
- Methods.POST,
506
- f"api/1/vehicles/{vehicle_tag}/command/remote_seat_heater_request",
507
- )
508
-
509
- async def remote_start_drive(self, vehicle_tag: str | int) -> dict[str, Any]:
510
- """Starts the vehicle remotely. Requires keyless driving to be enabled."""
511
- if self.use_command_protocol:
512
- raise NotImplementedError("Command Protocol not implemented")
513
- return await self._request(
514
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/remote_start_drive"
515
- )
516
-
517
- async def remote_steering_wheel_heat_level_request(
518
- self, vehicle_tag: str | int, level: int
519
- ) -> dict[str, Any]:
520
- """Sets steering wheel heat level."""
521
- if self.use_command_protocol:
522
- raise NotImplementedError("Command Protocol not implemented")
523
- return await self._request(
524
- Methods.POST,
525
- f"api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heat_level_request",
526
- json={level: level},
527
- )
528
-
529
- async def remote_steering_wheel_heater_request(
530
- self, vehicle_tag: str | int, on: bool
531
- ) -> dict[str, Any]:
532
- """Sets steering wheel heating on/off. For vehicles that do not support auto steering wheel heat."""
533
- if self.use_command_protocol:
534
- raise NotImplementedError("Command Protocol not implemented")
535
- return await self._request(
536
- Methods.POST,
537
- f"api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heater_request",
538
- json={on: on},
539
- )
540
-
541
- async def reset_pin_to_drive_pin(
542
- self, vehicle_tag: str | int
543
- ) -> dict[str, Any]:
544
- """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."""
545
- if self.use_command_protocol:
546
- raise NotImplementedError("Command Protocol not implemented")
547
- return await self._request(
548
- Methods.POST,
549
- f"api/1/vehicles/{vehicle_tag}/command/reset_pin_to_drive_pin",
550
- )
551
-
552
- async def reset_valet_pin(self, vehicle_tag: str | int) -> dict[str, Any]:
553
- """Removes PIN for Valet Mode."""
554
- if self.use_command_protocol:
555
- raise NotImplementedError("Command Protocol not implemented")
556
- return await self._request(
557
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/command/reset_valet_pin"
558
- )
559
-
560
- async def schedule_software_update(
561
- self, vehicle_tag: str | int, offset_sec: int
562
- ) -> dict[str, Any]:
563
- """Schedules a vehicle software update (over the air "OTA") to be installed in the future."""
564
- if self.use_command_protocol:
565
- raise NotImplementedError("Command Protocol not implemented")
566
- return await self._request(
567
- Methods.POST,
568
- f"api/1/vehicles/{vehicle_tag}/command/schedule_software_update",
569
- json={offset_sec: offset_sec},
570
- )
571
-
572
- async def set_bioweapon_mode(
573
- self, vehicle_tag: str | int, on: bool, manual_override: bool
574
- ) -> dict[str, Any]:
575
- """Turns Bioweapon Defense Mode on and off."""
576
- if self.use_command_protocol:
577
- raise NotImplementedError("Command Protocol not implemented")
578
- return await self._request(
579
- Methods.POST,
580
- f"api/1/vehicles/{vehicle_tag}/command/set_bioweapon_mode",
581
- json={on: on, manual_override: manual_override},
582
- )
583
-
584
- async def set_cabin_overheat_protection(
585
- self, vehicle_tag: str | int, on: bool, fan_only: bool
586
- ) -> dict[str, Any]:
587
- """Sets the vehicle overheat protection."""
588
- if self.use_command_protocol:
589
- raise NotImplementedError("Command Protocol not implemented")
590
- return await self._request(
591
- Methods.POST,
592
- f"api/1/vehicles/{vehicle_tag}/command/set_cabin_overheat_protection",
593
- json={on: on, fan_only: fan_only},
594
- )
595
-
596
- async def set_charge_limit(
597
- self, vehicle_tag: str | int, percent: int
598
- ) -> dict[str, Any]:
599
- """Sets the vehicle charge limit."""
600
- if self.use_command_protocol:
601
- raise NotImplementedError("Command Protocol not implemented")
602
- return await self._request(
603
- Methods.POST,
604
- f"api/1/vehicles/{vehicle_tag}/command/set_charge_limit",
605
- json={percent: percent},
606
- )
607
-
608
- async def set_charging_amps(
609
- self, vehicle_tag: str | int, charging_amps: int
610
- ) -> dict[str, Any]:
611
- """Sets the vehicle charging amps."""
612
- if self.use_command_protocol:
613
- raise NotImplementedError("Command Protocol not implemented")
614
- return await self._request(
615
- Methods.POST,
616
- f"api/1/vehicles/{vehicle_tag}/command/set_charging_amps",
617
- json={charging_amps: charging_amps},
618
- )
619
-
620
- async def set_climate_keeper_mode(
621
- self, vehicle_tag: str | int, climate_keeper_mode: ClimateKeeperMode | int
622
- ) -> dict[str, Any]:
623
- """Enables climate keeper mode."""
624
- if self.use_command_protocol:
625
- raise NotImplementedError("Command Protocol not implemented")
626
- return await self._request(
627
- Methods.POST,
628
- f"api/1/vehicles/{vehicle_tag}/command/set_climate_keeper_mode",
629
- json={climate_keeper_mode: climate_keeper_mode},
630
- )
631
-
632
- async def set_cop_temp(
633
- self, vehicle_tag: str | int, cop_temp: CabinOverheatProtectionTemps | int
634
- ) -> dict[str, Any]:
635
- """Adjusts the Cabin Overheat Protection temperature (COP)."""
636
- if self.use_command_protocol:
637
- raise NotImplementedError("Command Protocol not implemented")
638
- return await self._request(
639
- Methods.POST,
640
- f"api/1/vehicles/{vehicle_tag}/command/set_cop_temp",
641
- json={cop_temp: cop_temp},
642
- )
643
-
644
- async def set_pin_to_drive(
645
- self, vehicle_tag: str | int, on: bool, password: str | int
646
- ) -> dict[str, Any]:
647
- """Sets a four-digit passcode for PIN to Drive. This PIN must then be entered before the vehicle can be driven."""
648
- if self.use_command_protocol:
649
- raise NotImplementedError("Command Protocol not implemented")
650
- return await self._request(
651
- Methods.POST,
652
- f"api/1/vehicles/{vehicle_tag}/command/set_pin_to_drive",
653
- json={on: on, password: str(password)},
654
- )
655
-
656
- async def set_preconditioning_max(
657
- self, vehicle_tag: str | int, on: bool, manual_override: bool
658
- ) -> dict[str, Any]:
659
- """Sets an override for preconditioning — it should default to empty if no override is used."""
660
- if self.use_command_protocol:
661
- raise NotImplementedError("Command Protocol not implemented")
662
- return await self._request(
663
- Methods.POST,
664
- f"api/1/vehicles/{vehicle_tag}/command/set_preconditioning_max",
665
- json={on: on, manual_override: manual_override},
666
- )
667
-
668
- async def set_scheduled_charging(
669
- self, vehicle_tag: str | int, enable: bool, time: int
670
- ) -> dict[str, Any]:
671
- """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)."""
672
- if self.use_command_protocol:
673
- raise NotImplementedError("Command Protocol not implemented")
674
- return await self._request(
675
- Methods.POST,
676
- f"api/1/vehicles/{vehicle_tag}/command/set_scheduled_charging",
677
- json={enable: enable, time: time},
678
- )
679
-
680
- async def set_scheduled_departure(
681
- self, vehicle_tag: str | int, enable: bool, time: int
682
- ) -> dict[str, Any]:
683
- """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)."""
684
- if self.use_command_protocol:
685
- raise NotImplementedError("Command Protocol not implemented")
686
- return await self._request(
687
- Methods.POST,
688
- f"api/1/vehicles/{vehicle_tag}/command/set_scheduled_departure",
689
- json={enable: enable, time: time},
690
- )
691
-
692
- async def set_sentry_mode(
693
- self, vehicle_tag: str | int, on: bool
694
- ) -> dict[str, Any]:
695
- """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."""
696
- if self.use_command_protocol:
697
- raise NotImplementedError("Command Protocol not implemented")
698
- return await self._request(
699
- Methods.POST,
700
- f"api/1/vehicles/{vehicle_tag}/command/set_sentry_mode",
701
- json={on: on},
702
- )
703
-
704
- async def set_temps(
705
- self, vehicle_tag: str | int, driver_temp: int, passenger_temp: int
706
- ) -> dict[str, Any]:
707
- """Sets the driver and/or passenger-side cabin temperature (and other zones if sync is enabled)."""
708
- if self.use_command_protocol:
709
- raise NotImplementedError("Command Protocol not implemented")
710
- return await self._request(
711
- Methods.POST,
712
- f"api/1/vehicles/{vehicle_tag}/command/set_temps",
713
- json={driver_temp: driver_temp, passenger_temp: passenger_temp},
714
- )
715
-
716
- async def set_valet_mode(
717
- self, vehicle_tag: str | int, on: bool, password: str | int
718
- ) -> dict[str, Any]:
719
- """Turns on Valet Mode and sets a four-digit passcode that must then be entered to disable Valet Mode."""
720
- if self.use_command_protocol:
721
- raise NotImplementedError("Command Protocol not implemented")
722
- return await self._request(
723
- Methods.POST,
724
- f"api/1/vehicles/{vehicle_tag}/command/set_valet_mode",
725
- json={on: on, password: str(password)},
726
- )
727
-
728
- async def set_vehicle_name(
729
- self, vehicle_tag: str | int, vehicle_name: str
730
- ) -> dict[str, Any]:
731
- """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."""
732
- if self.use_command_protocol:
733
- raise NotImplementedError("Command Protocol not implemented")
734
- return await self._request(
735
- Methods.POST,
736
- f"api/1/vehicles/{vehicle_tag}/command/set_vehicle_name",
737
- json={vehicle_name: vehicle_name},
738
- )
739
-
740
- async def speed_limit_activate(
741
- self, vehicle_tag: str | int, pin: str | int
742
- ) -> dict[str, Any]:
743
- """Activates Speed Limit Mode with a four-digit PIN."""
744
- if self.use_command_protocol:
745
- raise NotImplementedError("Command Protocol not implemented")
746
- return await self._request(
747
- Methods.POST,
748
- f"api/1/vehicles/{vehicle_tag}/command/speed_limit_activate",
749
- json={pin: str(pin)},
750
- )
751
-
752
- async def speed_limit_clear_pin(
753
- self, vehicle_tag: str | int, pin: str | int
754
- ) -> dict[str, Any]:
755
- """Deactivates Speed Limit Mode and resets the associated PIN."""
756
- if self.use_command_protocol:
757
- raise NotImplementedError("Command Protocol not implemented")
758
- return await self._request(
759
- Methods.POST,
760
- f"api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin",
761
- json={pin: str(pin)},
762
- )
763
-
764
- async def speed_limit_clear_pin_admin(
765
- self, vehicle_tag: str | int
766
- ) -> dict[str, Any]:
767
- """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."""
768
- return await self._request(
769
- Methods.POST,
770
- f"api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin_admin",
771
- )
772
-
773
- async def speed_limit_deactivate(
774
- self, vehicle_tag: str | int, pin: str | int
775
- ) -> dict[str, Any]:
776
- """Deactivates Speed Limit Mode."""
777
- if self.use_command_protocol:
778
- raise NotImplementedError("Command Protocol not implemented")
779
- return await self._request(
780
- Methods.POST,
781
- f"api/1/vehicles/{vehicle_tag}/command/speed_limit_deactivate",
782
- json={pin: str(pin)},
783
- )
784
-
785
- async def speed_limit_set_limit(
786
- self, vehicle_tag: str | int, limit_mph: int
787
- ) -> dict[str, Any]:
788
- """Sets the maximum speed allowed when Speed Limit Mode is active."""
789
- if self.use_command_protocol:
790
- raise NotImplementedError("Command Protocol not implemented")
791
- return await self._request(
792
- Methods.POST,
793
- f"api/1/vehicles/{vehicle_tag}/command/speed_limit_set_limit",
794
- json={limit_mph: limit_mph},
795
- )
796
-
797
- async def sun_roof_control(
798
- self, vehicle_tag: str | int, state: str | SunRoofCommands
799
- ) -> dict[str, Any]:
800
- """Controls the panoramic sunroof on the Model S."""
801
- return await self._request(
802
- Methods.POST,
803
- f"api/1/vehicles/{vehicle_tag}/command/sun_roof_control",
804
- {state: state},
805
- )
806
-
807
- async def take_drivenote(
808
- self, vehicle_tag: str | int, note: str
809
- ) -> dict[str, Any]:
810
- """Records a drive note. The note parameter is truncated to 80 characters in length."""
811
- return await self._request(
812
- Methods.POST,
813
- f"api/1/vehicles/{vehicle_tag}/command/take_drivenote",
814
- {note: note},
815
- )
816
-
817
- async def trigger_homelink(
818
- self, vehicle_tag: str | int, lat: float, lon: float, token: str
819
- ) -> dict[str, Any]:
820
- """Turns on HomeLink (used to open and close garage doors)."""
821
- if self.use_command_protocol:
822
- raise NotImplementedError("Command Protocol not implemented")
823
- return await self._request(
824
- Methods.POST,
825
- f"api/1/vehicles/{vehicle_tag}/command/trigger_homelink",
826
- {lat: lat, lon: lon, token: token},
827
- )
828
-
829
- async def upcoming_calendar_entries(
830
- self, vehicle_tag: str | int, calendar_data: str
831
- ) -> dict[str, Any]:
832
- """Upcoming calendar entries stored on the vehicle."""
833
- return await self._request(
834
- Methods.POST,
835
- f"api/1/vehicles/{vehicle_tag}/command/upcoming_calendar_entries",
836
- {calendar_data: calendar_data},
837
- )
838
-
839
- async def window_control(
840
- self,
841
- vehicle_tag: str | int,
842
- lat: float,
843
- lon: float,
844
- command: str | WindowCommands,
845
- ) -> dict[str, Any]:
846
- """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)."""
847
- return await self._request(
848
- Methods.POST,
849
- f"api/1/vehicles/{vehicle_tag}/command/window_control",
850
- {lat: lat, lon: lon, command: command},
851
- )
852
-
853
- async def drivers(self, vehicle_tag: str | int) -> dict[str, Any]:
854
- """Returns all allowed drivers for a vehicle. This endpoint is only available for the vehicle owner."""
855
- return await self._request(
856
- Methods.GET, f"api/1/vehicles/{vehicle_tag}/drivers"
857
- )
858
-
859
- async def drivers_remove(
860
- self, vehicle_tag: str | int, share_user_id: str | int | None = None
861
- ) -> dict[str, Any]:
862
- """Removes driver access from a vehicle. Share users can only remove their own access. Owners can remove share access or their own."""
863
- return await self._request(
864
- Methods.DELETE,
865
- f"api/1/vehicles/{vehicle_tag}/drivers",
866
- {share_user_id: share_user_id},
867
- )
868
-
869
- async def list(
870
- self, page: int | None = None, per_page: int | None = None
871
- ) -> dict[str, Any]:
872
- """Returns vehicles belonging to the account."""
873
- return await self._request(
874
- Methods.GET, "api/1/vehicles", {page: page, per_page: per_page}
875
- )
876
-
877
- async def mobile_enabled(self, vehicle_tag: str | int) -> dict[str, Any]:
878
- """Returns whether or not mobile access is enabled for the vehicle."""
879
- return await self._request(
880
- Methods.GET, f"api/1/vehicles/{vehicle_tag}/mobile_enabled"
881
- )
882
-
883
- async def nearby_charging_sites(
884
- self,
885
- vehicle_tag: str | int,
886
- count: int | None = None,
887
- radius: int | None = None,
888
- detail: bool | None = None,
889
- ) -> dict[str, Any]:
890
- """Returns the charging sites near the current location of the vehicle."""
891
- return await self._request(
892
- Methods.GET,
893
- f"api/1/vehicles/{vehicle_tag}/nearby_charging_sites",
894
- {count: count, radius: radius, detail: detail},
895
- )
896
-
897
- async def options(self, vin: str) -> dict[str, Any]:
898
- """Returns vehicle option details."""
899
- return await self._request(
900
- Methods.GET, "api/1/dx/vehicles/options", {vin: vin}
901
- )
902
-
903
- async def recent_alerts(self, vehicle_tag: str | int) -> dict[str, Any]:
904
- """List of recent alerts"""
905
- return await self._request(
906
- Methods.GET, f"api/1/vehicles/{vehicle_tag}/recent_alerts"
907
- )
908
-
909
- async def release_notes(
910
- self,
911
- vehicle_tag: str | int,
912
- staged: bool | None = None,
913
- language: int | None = None,
914
- ) -> dict[str, Any]:
915
- """Returns firmware release notes."""
916
- return await self._request(
917
- Methods.GET,
918
- f"api/1/vehicles/{vehicle_tag}/release_notes",
919
- {staged: staged, language: language},
920
- )
921
-
922
- async def service_data(self, vehicle_tag: str | int) -> dict[str, Any]:
923
- """Returns service data."""
924
- return await self._request(
925
- Methods.GET, f"api/1/vehicles/{vehicle_tag}/service_data"
926
- )
927
-
928
- async def share_invites(self, vehicle_tag: str | int) -> dict[str, Any]:
929
- """Returns the share invites for a vehicle."""
930
- return await self._request(
931
- Methods.GET, f"api/1/vehicles/{vehicle_tag}/invitations"
932
- )
933
-
934
- async def share_invites_create(self, vehicle_tag: str | int) -> dict[str, Any]:
935
- """Creates a share invite for a vehicle."""
936
- return await self._request(
937
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/invitations"
938
- )
939
-
940
- async def share_invites_redeem(self, code: str) -> dict[str, Any]:
941
- """Redeems a share invite."""
942
- return await self._request(
943
- Methods.POST, "api/1/invitations/redeem", {code: code}
944
- )
945
-
946
- async def share_invites_revoke(
947
- self, vehicle_tag: str | int, id: str
948
- ) -> dict[str, Any]:
949
- """Revokes a share invite."""
950
- return await self._request(
951
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/invitations/{id}/revoke"
952
- )
953
-
954
- async def signed_command(
955
- self, vehicle_tag: str | int, routable_message: str
956
- ) -> dict[str, Any]:
957
- """Signed Commands is a generic endpoint replacing legacy commands."""
958
- return await self._request(
959
- Methods.POST,
960
- f"api/1/vehicles/{vehicle_tag}/signed_command",
961
- {routable_message: routable_message},
962
- )
963
-
964
- async def subscriptions(
965
- self, device_token: str, device_type: str
966
- ) -> dict[str, Any]:
967
- """Returns the list of vehicles for which this mobile device currently subscribes to push notifications."""
968
- return await self._request(
969
- Methods.GET,
970
- "api/1/subscriptions",
971
- query={device_token: device_token, device_type: device_type},
972
- )
973
-
974
- async def subscriptions_set(
975
- self, device_token: str, device_type: str
976
- ) -> dict[str, Any]:
977
- """Allows a mobile device to specify which vehicles to receive push notifications from."""
978
- return await self._request(
979
- Methods.POST,
980
- "api/1/subscriptions",
981
- query={device_token: device_token, device_type: device_type},
982
- )
983
-
984
- async def vehicle(self, vehicle_tag: str | int) -> dict[str, Any]:
985
- """Returns information about a vehicle."""
986
- return await self._request(Methods.GET, f"api/1/vehicles/{vehicle_tag}")
987
-
988
- async def vehicle_data(
989
- self,
990
- vehicle_tag: str | int,
991
- endpoints: VehicleDataEndpoints | str | None = None,
992
- ) -> dict[str, Any]:
993
- """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."""
994
- return await self._request(
995
- Methods.GET,
996
- f"api/1/vehicles/{vehicle_tag}/vehicle_data",
997
- {endpoints: endpoints},
998
- )
999
-
1000
- async def vehicle_subscriptions(
1001
- self, device_token: str, device_type: DeviceTypes | str
1002
- ) -> dict[str, Any]:
1003
- """Returns the list of vehicles for which this mobile device currently subscribes to push notifications."""
1004
- return await self._request(
1005
- Methods.GET,
1006
- "api/1/vehicle_subscriptions",
1007
- {device_token: device_token, device_type: device_type},
1008
- )
1009
-
1010
- async def vehicle_subscriptions_set(
1011
- self, device_token: str, device_type: DeviceTypes | str
1012
- ) -> dict[str, Any]:
1013
- """Allows a mobile device to specify which vehicles to receive push notifications from."""
1014
- return await self._request(
1015
- Methods.POST,
1016
- "api/1/vehicle_subscriptions",
1017
- params={device_token: device_token, device_type: device_type},
1018
- )
1019
-
1020
- async def wake_up(self, vehicle_tag: str | int) -> dict[str, Any]:
1021
- """Wakes the vehicle from sleep, which is a state to minimize idle energy consumption."""
1022
- return await self._request(
1023
- Methods.POST, f"api/1/vehicles/{vehicle_tag}/wake_up"
1024
- )
1025
-
1026
- async def warranty_details(self, vin: str | None) -> dict[str, Any]:
1027
- """Returns warranty details."""
1028
- return await self._request(
1029
- Methods.GET, "api/1/dx/warranty/details", {vin: vin}
1030
- )
1031
-
1032
- async def fleet_telemetry_config(
1033
- self, config: dict[str, Any]
1034
- ) -> dict[str, Any]:
1035
- """Configures fleet telemetry."""
1036
- return await self._request(
1037
- Methods.POST, "api/1/vehicles/fleet_telemetry_config", json=config
1038
- )
1039
-
1040
- class Specific:
1041
- """Class describing the Tesla Fleet API vehicle endpoints and commands for a specific vehicle."""
1042
-
1043
- def __init__(self, parent, vin: str | None = None):
1044
- self.parent = parent
1045
- self.vin = vin
1046
-
1047
- async def actuate_trunk(self, which_trunk: Trunks | str) -> dict[str, Any]:
1048
- """Controls the front or rear trunk."""
1049
- return await self.parent.actuate_trunk(self.vin, which_trunk)
1050
-
1051
- async def adjust_volume(self, volume: float) -> dict[str, Any]:
1052
- """Adjusts vehicle media playback volume."""
1053
- return await self.parent.adjust_volume(self.vin, volume)
1054
-
1055
- async def auto_conditioning_start(self) -> dict[str, Any]:
1056
- """Starts climate preconditioning."""
1057
- return await self.parent.auto_conditioning_start(self.vin)
1058
-
1059
- async def auto_conditioning_stop(self) -> dict[str, Any]:
1060
- """Stops climate preconditioning."""
1061
- return await self.parent.auto_conditioning_stop(self.vin)
1062
-
1063
- async def cancel_software_update(self) -> dict[str, Any]:
1064
- """Cancels the countdown to install the vehicle software update."""
1065
- return await self.parent.cancel_software_update(self.vin)
1066
-
1067
- async def charge_max_range(self) -> dict[str, Any]:
1068
- """Charges in max range mode -- we recommend limiting the use of this mode to long trips."""
1069
- return await self.parent.charge_max_range(self.vin)
1070
-
1071
- async def charge_port_door_close(self) -> dict[str, Any]:
1072
- """Closes the charge port door."""
1073
- return await self.parent.charge_port_door_close(self.vin)
1074
-
1075
- async def charge_port_door_open(self) -> dict[str, Any]:
1076
- """Opens the charge port door."""
1077
- return await self.parent.charge_port_door_open(self.vin)
1078
-
1079
- async def charge_standard(self) -> dict[str, Any]:
1080
- """Charges in Standard mode."""
1081
- return await self.parent.charge_standard(self.vin)
1082
-
1083
- async def charge_start(self) -> dict[str, Any]:
1084
- """Starts charging the vehicle."""
1085
- return await self.parent.charge_start(self.vin)
1086
-
1087
- async def charge_stop(self) -> dict[str, Any]:
1088
- """Stops charging the vehicle."""
1089
- return await self.parent.charge_stop(self.vin)
1090
-
1091
- async def clear_pin_to_drive_admin(self):
1092
- """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."""
1093
- return await self.parent.clear_pin_to_drive_admin(self.vin)
1094
-
1095
- async def door_lock(self) -> dict[str, Any]:
1096
- """Locks the vehicle."""
1097
- return await self.parent.door_lock(self.vin)
1098
-
1099
- async def door_unlock(self) -> dict[str, Any]:
1100
- """Unlocks the vehicle."""
1101
- return await self.parent.door_unlock(self.vin)
1102
-
1103
- async def erase_user_data(self) -> dict[str, Any]:
1104
- """Erases user's data from the user interface. Requires the vehicle to be in park."""
1105
- return await self.parent.erase_user_data(self.vin)
1106
-
1107
- async def flash_lights(self) -> dict[str, Any]:
1108
- """Briefly flashes the vehicle headlights. Requires the vehicle to be in park."""
1109
- return await self.parent.flash_lights(self.vin)
1110
-
1111
- async def guest_mode(self, enable: bool) -> dict[str, Any]:
1112
- """Restricts certain vehicle UI functionality from guest users"""
1113
- return await self.parent.guest_mode(self.vin, enable)
1114
-
1115
- async def honk_horn(self) -> dict[str, Any]:
1116
- """Honks the vehicle horn. Requires the vehicle to be in park."""
1117
- return await self.parent.honk_horn(self.vin)
1118
-
1119
- async def media_next_fav(self) -> dict[str, Any]:
1120
- """Advances media player to next favorite track."""
1121
- return await self.parent.media_next_fav(self.vin)
1122
-
1123
- async def media_next_track(self) -> dict[str, Any]:
1124
- """Advances media player to next track."""
1125
- return await self.parent.media_next_track(self.vin)
1126
-
1127
- async def media_prev_fav(self) -> dict[str, Any]:
1128
- """Advances media player to previous favorite track."""
1129
- return await self.parent.media_prev_fav(self.vin)
1130
-
1131
- async def media_prev_track(self) -> dict[str, Any]:
1132
- """Advances media player to previous track."""
1133
- return await self.parent.media_prev_track(self.vin)
1134
-
1135
- async def media_toggle_playback(self) -> dict[str, Any]:
1136
- """Toggles current play/pause state."""
1137
- return await self.parent.media_toggle_playback(self.vin)
1138
-
1139
- async def media_volume_down(self) -> dict[str, Any]:
1140
- """Turns the volume down by one."""
1141
- return await self.parent.media_volume_down(self.vin)
1142
-
1143
- async def navigation_gps_request(
1144
- self, lat: float, lon: float, order: int
1145
- ) -> dict[str, Any]:
1146
- """Start navigation to given coordinates. Order can be used to specify order of multiple stops."""
1147
- self.parent.navigation_gps_request(self.vin, lat, lon, order)
1148
-
1149
- async def navigation_request(
1150
- self, type: str, locale: str, timestamp_ms: str
1151
- ) -> dict[str, Any]:
1152
- """Sends a location to the in-vehicle navigation system."""
1153
- return await self.parent.navigation_request(
1154
- self.vin, type, locale, timestamp_ms
1155
- )
1156
-
1157
- async def navigation_sc_request(
1158
- self, id: int, order: int
1159
- ) -> dict[str, Any]:
1160
- """Sends a location to the in-vehicle navigation system."""
1161
- return await self.parent.navigation_sc_request(self.vin, id, order)
1162
-
1163
- async def remote_auto_seat_climate_request(
1164
- self, auto_seat_position: int, auto_climate_on: bool
1165
- ) -> dict[str, Any]:
1166
- """Sets automatic seat heating and cooling."""
1167
- return await self.parent.remote_auto_seat_climate_request(
1168
- self.vin, auto_seat_position, auto_climate_on
1169
- )
1170
-
1171
- async def remote_auto_steering_wheel_heat_climate_request(
1172
- self, on: bool
1173
- ) -> dict[str, Any]:
1174
- """Sets automatic steering wheel heating on/off."""
1175
- return (
1176
- await self.parent.remote_auto_steering_wheel_heat_climate_request(
1177
- self.vin, on
1178
- )
1179
- )
1180
-
1181
- async def remote_boombox(self, sound: int) -> dict[str, Any]:
1182
- """Plays a sound through the vehicle external speaker."""
1183
- return await self.parent.remote_boombox(self.vin, sound)
1184
-
1185
- async def remote_seat_cooler_request(
1186
- self, seat_position: int, seat_cooler_level: int
1187
- ) -> dict[str, Any]:
1188
- """Sets seat cooling."""
1189
- return await self.parent.remote_seat_cooler_request(
1190
- self.vin, seat_position, seat_cooler_level
1191
- )
1192
-
1193
- async def remote_seat_heater_request(self) -> dict[str, Any]:
1194
- """Sets seat heating."""
1195
- return await self.parent.remote_seat_heater_request(self.vin)
1196
-
1197
- async def remote_start_drive(self) -> dict[str, Any]:
1198
- """Starts the vehicle remotely. Requires keyless driving to be enabled."""
1199
- return await self.parent.remote_start_drive(self.vin)
1200
-
1201
- async def remote_steering_wheel_heat_level_request(
1202
- self, level: int
1203
- ) -> dict[str, Any]:
1204
- """Sets steering wheel heat level."""
1205
- return await self.parent.remote_steering_wheel_heat_level_request(
1206
- self.vin, level
1207
- )
1208
-
1209
- async def remote_steering_wheel_heater_request(
1210
- self, on: bool
1211
- ) -> dict[str, Any]:
1212
- """Sets steering wheel heating on/off. For vehicles that do not support auto steering wheel heat."""
1213
- return await self.parent.remote_steering_wheel_heater_request(
1214
- self.vin, on
1215
- )
1216
-
1217
- async def reset_pin_to_drive_pin(self) -> dict[str, Any]:
1218
- """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."""
1219
- return await self.parent.reset_pin_to_drive_pin(self.vin)
1220
-
1221
- async def reset_valet_pin(self) -> dict[str, Any]:
1222
- """Removes PIN for Valet Mode."""
1223
- return await self.parent.reset_valet_pin(self.vin)
1224
-
1225
- async def schedule_software_update(self, offset_sec: int) -> dict[str, Any]:
1226
- """Schedules a vehicle software update (over the air "OTA") to be installed in the future."""
1227
- return await self.parent.schedule_software_update(self.vin, offset_sec)
1228
-
1229
- async def set_bioweapon_mode(
1230
- self, on: bool, manual_override: bool
1231
- ) -> dict[str, Any]:
1232
- """Turns Bioweapon Defense Mode on and off."""
1233
- return await self.parent.set_bioweapon_mode(
1234
- self.vin, on, manual_override
1235
- )
1236
-
1237
- async def set_cabin_overheat_protection(
1238
- self, on: bool, fan_only: bool
1239
- ) -> dict[str, Any]:
1240
- """Sets the vehicle overheat protection."""
1241
- return await self.parent.set_cabin_overheat_protection(
1242
- self.vin, on, fan_only
1243
- )
1244
-
1245
- async def set_charge_limit(self, percent: int) -> dict[str, Any]:
1246
- """Sets the vehicle charge limit."""
1247
- return await self.parent.set_charge_limit(self.vin, percent)
1248
-
1249
- async def set_charging_amps(self, charging_amps: int) -> dict[str, Any]:
1250
- """Sets the vehicle charging amps."""
1251
- return await self.parent.set_charging_amps(self.vin, charging_amps)
1252
-
1253
- async def set_climate_keeper_mode(
1254
- self, climate_keeper_mode: ClimateKeeperMode | int
1255
- ) -> dict[str, Any]:
1256
- """Enables climate keeper mode."""
1257
- return await self.parent.set_climate_keeper_mode(
1258
- self.vin, climate_keeper_mode
1259
- )
1260
-
1261
- async def set_cop_temp(
1262
- self, cop_temp: CabinOverheatProtectionTemps | int
1263
- ) -> dict[str, Any]:
1264
- """Adjusts the Cabin Overheat Protection temperature (COP)."""
1265
- return await self.parent.set_cop_temp(self.vin, cop_temp)
1266
-
1267
- async def set_pin_to_drive(
1268
- self, on: bool, password: str | int
1269
- ) -> dict[str, Any]:
1270
- """Sets a four-digit passcode for PIN to Drive. This PIN must then be entered before the vehicle can be driven."""
1271
- return await self.parent.set_pin_to_drive(self.vin, on, password)
1272
-
1273
- async def set_preconditioning_max(
1274
- self, on: bool, manual_override: bool
1275
- ) -> dict[str, Any]:
1276
- """Sets an override for preconditioning — it should default to empty if no override is used."""
1277
- return await self.parent.set_preconditioning_max(
1278
- self.vin, on, manual_override
1279
- )
1280
-
1281
- async def set_scheduled_charging(
1282
- self, enable: bool, time: int
1283
- ) -> dict[str, Any]:
1284
- """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)."""
1285
- return await self.parent.set_scheduled_charging(self.vin, enable, time)
1286
-
1287
- async def set_scheduled_departure(
1288
- self, enable: bool, time: int
1289
- ) -> dict[str, Any]:
1290
- """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)."""
1291
- return await self.parent.set_scheduled_departure(self.vin, enable, time)
1292
-
1293
- async def set_sentry_mode(self, on: bool) -> dict[str, Any]:
1294
- """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."""
1295
- return await self.parent.set_sentry_mode(self.vin, on)
1296
-
1297
- async def set_temps(
1298
- self, driver_temp: int, passenger_temp: int
1299
- ) -> dict[str, Any]:
1300
- """Sets the driver and/or passenger-side cabin temperature (and other zones if sync is enabled)."""
1301
- return await self.parent.set_temps(
1302
- self.vin, driver_temp, passenger_temp
1303
- )
1304
-
1305
- async def set_valet_mode(
1306
- self, on: bool, password: str | int
1307
- ) -> dict[str, Any]:
1308
- """Turns on Valet Mode and sets a four-digit passcode that must then be entered to disable Valet Mode."""
1309
- return await self.parent.set_valet_mode(self.vin, on, password)
1310
-
1311
- async def set_vehicle_name(self, vehicle_name: str) -> dict[str, Any]:
1312
- """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."""
1313
- return await self.parent.set_vehicle_name(self.vin, vehicle_name)
1314
-
1315
- async def speed_limit_activate(self, pin: str | int) -> dict[str, Any]:
1316
- """Activates Speed Limit Mode with a four-digit PIN."""
1317
- return await self.parent.speed_limit_activate(self.vin, pin)
1318
-
1319
- async def speed_limit_clear_pin(self, pin: str | int) -> dict[str, Any]:
1320
- """Deactivates Speed Limit Mode and resets the associated PIN."""
1321
- return await self.parent.speed_limit_clear_pin(self.vin, pin)
1322
-
1323
- async def speed_limit_clear_pin_admin(self) -> dict[str, Any]:
1324
- """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."""
1325
- return await self.parent.speed_limit_clear_pin_admin(self.vin)
1326
-
1327
- async def speed_limit_deactivate(self, pin: str | int) -> dict[str, Any]:
1328
- """Deactivates Speed Limit Mode."""
1329
- return await self.parent.speed_limit_deactivate(self.vin, pin)
1330
-
1331
- async def speed_limit_set_limit(self, limit_mph: int) -> dict[str, Any]:
1332
- """Sets the maximum speed allowed when Speed Limit Mode is active."""
1333
- return await self.parent.speed_limit_set_limit(self.vin, limit_mph)
1334
-
1335
- async def sun_roof_control(
1336
- self, state: str | SunRoofCommands
1337
- ) -> dict[str, Any]:
1338
- """Controls the panoramic sunroof on the Model S."""
1339
- return await self.parent.sun_roof_control(self.vin, state)
1340
-
1341
- async def take_drivenote(self, note: str) -> dict[str, Any]:
1342
- """Records a drive note. The note parameter is truncated to 80 characters in length."""
1343
- return await self.parent.take_drivenote(self.vin, note)
1344
-
1345
- async def trigger_homelink(
1346
- self, lat: float, lon: float, token: str
1347
- ) -> dict[str, Any]:
1348
- """Turns on HomeLink (used to open and close garage doors)."""
1349
- return await self.parent.trigger_homelink(self.vin, lat, lon, token)
1350
-
1351
- async def upcoming_calendar_entries(
1352
- self, calendar_data: str
1353
- ) -> dict[str, Any]:
1354
- """Upcoming calendar entries stored on the vehicle."""
1355
- return await self.parent.upcoming_calendar_entries(
1356
- self.vin, calendar_data
1357
- )
1358
-
1359
- async def window_control(
1360
- self,
1361
- vehicle_tag: str | int,
1362
- lat: float,
1363
- lon: float,
1364
- command: str | WindowCommands,
1365
- ) -> dict[str, Any]:
1366
- """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)."""
1367
- return await self.parent.window_control(self.vin, lat, lon, command)
1368
-
1369
- async def drivers(self) -> dict[str, Any]:
1370
- """Returns all allowed drivers for a vehicle. This endpoint is only available for the vehicle owner."""
1371
- return await self.parent.drivers(self.vin)
1372
-
1373
- async def drivers_remove(
1374
- self, share_user_id: str | int | None = None
1375
- ) -> dict[str, Any]:
1376
- """Removes driver access from a vehicle. Share users can only remove their own access. Owners can remove share access or their own."""
1377
- return await self.parent.drivers_remove(self.vin, share_user_id)
1378
-
1379
- async def mobile_enabled(self) -> dict[str, Any]:
1380
- """Returns whether or not mobile access is enabled for the vehicle."""
1381
- return await self.parent.mobile_enabled(self.vin)
1382
-
1383
- async def nearby_charging_sites(
1384
- self,
1385
- vehicle_tag: str | int,
1386
- count: int | None = None,
1387
- radius: int | None = None,
1388
- detail: bool | None = None,
1389
- ) -> dict[str, Any]:
1390
- """Returns the charging sites near the current location of the vehicle."""
1391
- return await self.parent.nearby_charging_sites(
1392
- self.vin, count, radius, detail
1393
- )
1394
-
1395
- async def options(self, vin: str) -> dict[str, Any]:
1396
- """Returns vehicle option details."""
1397
- return await self.parent.options(self.vin)
1398
-
1399
- async def recent_alerts(self) -> dict[str, Any]:
1400
- """List of recent alerts"""
1401
- return await self.parent.recent_alerts(self.vin)
1402
-
1403
- async def release_notes(
1404
- self,
1405
- vehicle_tag: str | int,
1406
- staged: bool | None = None,
1407
- language: int | None = None,
1408
- ) -> dict[str, Any]:
1409
- """Returns firmware release notes."""
1410
- return await self.parent.release_notes(self.vin, staged, language)
1411
-
1412
- async def service_data(self) -> dict[str, Any]:
1413
- """Returns service data."""
1414
- return await self.parent.service_data(self.vin)
1415
-
1416
- async def share_invites(self) -> dict[str, Any]:
1417
- """Returns the share invites for a vehicle."""
1418
- return await self.parent.share_invites(self.vin)
1419
-
1420
- async def share_invites_create(self) -> dict[str, Any]:
1421
- """Creates a share invite for a vehicle."""
1422
- return await self.parent.share_invites_create(self.vin)
1423
-
1424
- async def share_invites_redeem(self, code: str) -> dict[str, Any]:
1425
- """Redeems a share invite."""
1426
- return await self.parent.share_invites_redeem(code)
1427
-
1428
- async def share_invites_revoke(self, id: str) -> dict[str, Any]:
1429
- """Revokes a share invite."""
1430
- return await self.parent.share_invites_revoke(self.vin, id)
1431
-
1432
- async def signed_command(self, routable_message: str) -> dict[str, Any]:
1433
- """Signed Commands is a generic endpoint replacing legacy commands."""
1434
- return await self.parent.signed_command(self.vin, routable_message)
1435
-
1436
- async def subscriptions(
1437
- self, device_token: str, device_type: str
1438
- ) -> dict[str, Any]:
1439
- """Returns the list of vehicles for which this mobile device currently subscribes to push notifications."""
1440
- return await self.parent.subscriptions(
1441
- self.vin, device_token, device_type
1442
- )
1443
-
1444
- async def subscriptions_set(
1445
- self, device_token: str, device_type: str
1446
- ) -> dict[str, Any]:
1447
- """Allows a mobile device to specify which vehicles to receive push notifications from."""
1448
- return await self.parent.subscriptions_set(
1449
- self.vin, device_token, device_type
1450
- )
1451
-
1452
- async def vehicle(self) -> dict[str, Any]:
1453
- """Returns information about a vehicle."""
1454
- return await self.parent.vehicle(self.vin)
1455
-
1456
- async def vehicle_data(
1457
- self,
1458
- endpoints: VehicleDataEndpoints | str | None = None,
1459
- ) -> dict[str, Any]:
1460
- """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."""
1461
- return await self.parent.vehicle_data(self.vin, endpoints)
1462
-
1463
- async def vehicle_subscriptions(
1464
- self, device_token: str, device_type: DeviceTypes | str
1465
- ) -> dict[str, Any]:
1466
- """Returns the list of vehicles for which this mobile device currently subscribes to push notifications."""
1467
- return await self.parent.vehicle_subscriptions(
1468
- self.vin, device_token, device_type
1469
- )
1470
-
1471
- async def vehicle_subscriptions_set(
1472
- self, device_token: str, device_type: DeviceTypes | str
1473
- ) -> dict[str, Any]:
1474
- """Allows a mobile device to specify which vehicles to receive push notifications from."""
1475
- return await self.parent.vehicle_subscriptions_set(
1476
- self.vin, device_token, device_type
1477
- )
1478
-
1479
- async def wake_up(self) -> dict[str, Any]:
1480
- """Wakes the vehicle from sleep, which is a state to minimize idle energy consumption."""
1481
- return await self.parent.wake_up(self.vin)
1482
-
1483
- async def warranty_details(self) -> dict[str, Any]:
1484
- """Returns warranty details."""
1485
- return await self.parent.warranty_details(self.vin)
1486
-
1487
- async def create(self) -> [Specific]:
1488
- """Creates a class for each vehicle."""
1489
- list = await self.list()
1490
- return [self.Specific(self, x["vin"]) for x in list["response"]]