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