tesla-fleet-api 1.0.12__py3-none-any.whl → 1.0.14__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,3 +1,8 @@
1
+ """Tesla Fleet API"""
2
+
3
+ __author__ = "hello@teslemetry.com"
4
+ __version__ = "1.0.14"
5
+
1
6
  from tesla_fleet_api.tesla.fleet import TeslaFleetApi
2
7
  from tesla_fleet_api.tesla.bluetooth import TeslaBluetooth
3
8
  from tesla_fleet_api.tesla.oauth import TeslaFleetOAuth
tesla_fleet_api/const.py CHANGED
@@ -3,7 +3,6 @@
3
3
  from enum import Enum
4
4
  import logging
5
5
 
6
- VERSION = "1.0.12"
7
6
  LOGGER = logging.getLogger(__package__)
8
7
  SERVERS = {
9
8
  "na": "https://fleet-api.prd.na.vn.cloud.tesla.com",
@@ -47,10 +46,18 @@ class Seat(IntEnum):
47
46
  FRONT_LEFT = 0
48
47
  FRONT_RIGHT = 1
49
48
  REAR_LEFT = 2
49
+ REAT_LEFT_BACK = 3
50
50
  REAR_CENTER = 4
51
51
  REAR_RIGHT = 5
52
- THIRD_LEFT = 6
53
- THIRD_RIGHT = 7
52
+ REAR_RIGHT_BACK = 6
53
+ THIRD_LEFT = 7
54
+ THIRD_RIGHT = 8
55
+
56
+ class AutoSeat(IntEnum):
57
+ """Auto Climate Seat positions"""
58
+
59
+ FRONT_LEFT = 1
60
+ FRONT_RIGHT = 2
54
61
 
55
62
 
56
63
  class Level(IntEnum):
@@ -3,9 +3,24 @@
3
3
  from tesla_fleet_api.tesla.fleet import TeslaFleetApi
4
4
  from tesla_fleet_api.tesla.bluetooth import TeslaBluetooth
5
5
  from tesla_fleet_api.tesla.oauth import TeslaFleetOAuth
6
+ from tesla_fleet_api.tesla.charging import Charging
7
+ from tesla_fleet_api.tesla.energysite import EnergySites, EnergySite
8
+ from tesla_fleet_api.tesla.partner import Partner
9
+ from tesla_fleet_api.tesla.user import User
10
+ from tesla_fleet_api.tesla.vehicle import Vehicles, VehiclesBluetooth, VehicleFleet, VehicleSigned, VehicleBluetooth
6
11
 
7
12
  __all__ = [
8
13
  "TeslaFleetApi",
9
14
  "TeslaBluetooth",
10
15
  "TeslaFleetOAuth",
16
+ "Charging",
17
+ "EnergySites",
18
+ "EnergySite",
19
+ "Partner",
20
+ "User",
21
+ "Vehicles",
22
+ "VehiclesBluetooth",
23
+ "VehicleFleet",
24
+ "VehicleSigned",
25
+ "VehicleBluetooth"
11
26
  ]
@@ -6,8 +6,8 @@ import aiohttp
6
6
 
7
7
  from tesla_fleet_api.tesla.tesla import Tesla
8
8
  from tesla_fleet_api.exceptions import raise_for_status, InvalidRegion, LibraryError, ResponseError
9
- from tesla_fleet_api.const import SERVERS, Method, LOGGER, VERSION
10
-
9
+ from tesla_fleet_api.const import SERVERS, Method, LOGGER
10
+ from tesla_fleet_api import __version__ as VERSION
11
11
 
12
12
  # Based on https://developer.tesla.com/docs/fleet-api
13
13
  class TeslaFleetApi(Tesla):
@@ -115,8 +115,7 @@ class TeslaFleetApi(Tesla):
115
115
  json=json,
116
116
  params=params,
117
117
  ) as resp:
118
- LOGGER.debug("Requested: %s", resp.url)
119
- LOGGER.debug("Response Status: %s", resp.status)
118
+ LOGGER.debug("Status %s from %s", resp.status, resp.url)
120
119
  if "x-txid" in resp.headers:
121
120
  LOGGER.debug("Response TXID: %s", resp.headers["x-txid"])
122
121
  if "RateLimit-Reset" in resp.headers:
@@ -1,12 +1,13 @@
1
1
  """Tesla Fleet API classes."""
2
2
 
3
- from tesla_fleet_api.tesla.vehicle.vehicles import Vehicles
3
+ from tesla_fleet_api.tesla.vehicle.vehicles import Vehicles, VehiclesBluetooth
4
4
  from tesla_fleet_api.tesla.vehicle.fleet import VehicleFleet
5
5
  from tesla_fleet_api.tesla.vehicle.bluetooth import VehicleBluetooth
6
6
  from tesla_fleet_api.tesla.vehicle.signed import VehicleSigned
7
7
 
8
8
  __all__ = [
9
9
  "Vehicles",
10
+ "VehiclesBluetooth",
10
11
  "VehicleFleet",
11
12
  "VehicleBluetooth",
12
13
  "VehicleSigned",
@@ -1,16 +1,12 @@
1
1
  from __future__ import annotations
2
- import asyncio
3
2
  from typing import TYPE_CHECKING
4
- from bleak import BleakClient
5
3
  from bleak.backends.device import BLEDevice
6
- from bleak_retry_connector import establish_connection
7
4
  from cryptography.hazmat.primitives.asymmetric import ec
8
5
 
9
6
  from tesla_fleet_api.tesla.vehicle.signed import VehicleSigned
10
- from tesla_fleet_api.tesla.vehicle.bluetooth import NAME_UUID, VehicleBluetooth
7
+ from tesla_fleet_api.tesla.vehicle.bluetooth import VehicleBluetooth
11
8
  from tesla_fleet_api.tesla.vehicle.fleet import VehicleFleet
12
9
  from tesla_fleet_api.tesla.vehicle.vehicle import Vehicle
13
- from tesla_fleet_api.const import LOGGER
14
10
 
15
11
  if TYPE_CHECKING:
16
12
  from tesla_fleet_api.tesla.fleet import TeslaFleetApi
@@ -1,5 +1,15 @@
1
1
  from tesla_fleet_api.teslemetry.teslemetry import Teslemetry
2
+ from tesla_fleet_api.tesla.charging import Charging
3
+ from tesla_fleet_api.tesla.energysite import EnergySites, EnergySite
4
+ from tesla_fleet_api.tesla.user import User
5
+ from tesla_fleet_api.teslemetry.vehicles import TeslemetryVehicles as Vehicles, TeslemetryVehicle as Vehicle
2
6
 
3
7
  __all__ = [
4
8
  "Teslemetry",
9
+ "Charging",
10
+ "EnergySites",
11
+ "EnergySite",
12
+ "User",
13
+ "Vehicles",
14
+ "Vehicle",
5
15
  ]
@@ -2,18 +2,13 @@ from __future__ import annotations
2
2
  from typing import TYPE_CHECKING, Any
3
3
 
4
4
  from tesla_fleet_api.const import Method
5
- from tesla_fleet_api.tesla.vehicle.vehicle import Vehicle
6
5
  from tesla_fleet_api.tesla.vehicle.vehicles import Vehicles
7
6
  from tesla_fleet_api.tesla.vehicle.fleet import VehicleFleet
8
7
 
9
8
  if TYPE_CHECKING:
10
9
  pass
11
10
 
12
- class TeslemetryVehicle(Vehicle):
13
- """Teslemetry specific base vehicle."""
14
- pass
15
-
16
- class TeslemetryVehicleFleet(VehicleFleet):
11
+ class TeslemetryVehicle(VehicleFleet):
17
12
  """Teslemetry specific API vehicle."""
18
13
 
19
14
  async def server_side_polling(
@@ -52,22 +47,22 @@ class TeslemetryVehicleFleet(VehicleFleet):
52
47
  class TeslemetryVehicles(Vehicles):
53
48
  """Class containing and creating vehicles."""
54
49
 
55
- Fleet = TeslemetryVehicleFleet
56
-
57
- def create(self, vin: str) -> TeslemetryVehicleFleet:
58
- """Creates a specific vehicle."""
59
- return self.createFleet(vin)
50
+ Vehicle = TeslemetryVehicle
60
51
 
61
- def createFleet(self, vin: str) -> TeslemetryVehicleFleet:
52
+ def create(self, vin: str) -> TeslemetryVehicle:
62
53
  """Creates a specific vehicle."""
63
- vehicle = self.Fleet(self._parent, vin)
54
+ vehicle = self.Vehicle(self._parent, vin)
64
55
  self[vin] = vehicle
65
56
  return vehicle
66
57
 
58
+ def createFleet(self, vin: str):
59
+ """Creates a specific vehicle."""
60
+ raise NotImplementedError("Teslemetry cannot use Fleet API directly")
61
+
67
62
  def createSigned(self, vin: str):
68
63
  """Creates a specific vehicle."""
69
- raise NotImplementedError("Signing is handled by Teslemetry server-side")
64
+ raise NotImplementedError("Teslemetry cannot use Fleet API directly")
70
65
 
71
66
  def createBluetooth(self, vin: str):
72
67
  """Creates a specific vehicle."""
73
- raise NotImplementedError("Bluetooth is only handled locally")
68
+ raise NotImplementedError("Teslemetry cannot use local Bluetooth")
@@ -1,5 +1,15 @@
1
1
  from tesla_fleet_api.tessie.tessie import Tessie
2
+ from tesla_fleet_api.tesla.charging import Charging
3
+ from tesla_fleet_api.tesla.energysite import EnergySites, EnergySite
4
+ from tesla_fleet_api.tesla.user import User
5
+ from tesla_fleet_api.tessie.vehicles import TessieVehicles as Vehicles, TessieVehicle as Vehicle
2
6
 
3
7
  __all__ = [
4
8
  "Tessie",
9
+ "Charging",
10
+ "EnergySites",
11
+ "EnergySite",
12
+ "User",
13
+ "Vehicles",
14
+ "Vehicle",
5
15
  ]
@@ -1,37 +1,32 @@
1
1
  from __future__ import annotations
2
2
 
3
- from tesla_fleet_api.tesla.vehicle.vehicle import Vehicle
4
3
  from tesla_fleet_api.tesla.vehicle.vehicles import Vehicles
5
4
  from tesla_fleet_api.tesla.vehicle.fleet import VehicleFleet
6
5
 
7
6
 
8
- class TessieVehicle(Vehicle):
9
- """Tessie specific base vehicle."""
10
- pass
11
-
12
- class TessieVehicleFleet(VehicleFleet):
7
+ class TessieVehicle(VehicleFleet):
13
8
  """Tessie specific API vehicle."""
14
9
  pass
15
10
 
16
11
  class TessieVehicles(Vehicles):
17
12
  """Class containing and creating vehicles."""
18
13
 
19
- Fleet = TessieVehicleFleet
20
-
21
- def create(self, vin: str) -> TessieVehicleFleet:
22
- """Creates a specific vehicle."""
23
- return self.createFleet(vin)
14
+ Vehicle = TessieVehicle
24
15
 
25
- def createFleet(self, vin: str) -> TessieVehicleFleet:
16
+ def create(self, vin: str) -> TessieVehicle:
26
17
  """Creates a specific vehicle."""
27
- vehicle = self.Fleet(self._parent, vin)
18
+ vehicle = self.Vehicle(self._parent, vin)
28
19
  self[vin] = vehicle
29
20
  return vehicle
30
21
 
22
+ def createFleet(self, vin: str):
23
+ """Creates a specific vehicle."""
24
+ raise NotImplementedError("Tessie cannot use Fleet API directly")
25
+
31
26
  def createSigned(self, vin: str):
32
27
  """Creates a specific vehicle."""
33
- raise NotImplementedError("Signing is handled by Tessie server-side")
28
+ raise NotImplementedError("Tessie cannot use Fleet API directly")
34
29
 
35
30
  def createBluetooth(self, vin: str):
36
31
  """Creates a specific vehicle."""
37
- raise NotImplementedError("Bluetooth is only handled locally")
32
+ raise NotImplementedError("Tessie cannot use local Bluetooth")
@@ -0,0 +1,254 @@
1
+ Metadata-Version: 2.2
2
+ Name: tesla_fleet_api
3
+ Version: 1.0.14
4
+ Summary: Tesla Fleet API library for Python
5
+ Home-page: https://github.com/Teslemetry/python-tesla-fleet-api
6
+ Author: Brett Adams
7
+ Author-email: hello@teslemetry.com
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: aiohttp
16
+ Requires-Dist: aiofiles
17
+ Requires-Dist: aiolimiter
18
+ Requires-Dist: cryptography
19
+ Requires-Dist: protobuf
20
+ Requires-Dist: bleak
21
+ Requires-Dist: bleak-retry-connector
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: requires-dist
29
+ Dynamic: requires-python
30
+ Dynamic: summary
31
+
32
+ # Tesla Fleet API
33
+
34
+ Tesla Fleet API is a Python library that provides an interface to interact with Tesla's Fleet API, including signed commands and encrypted local Bluetooth (BLE) communication. It also supports interactions with Teslemetry and Tessie services.
35
+
36
+ ## Features
37
+
38
+ - Fleet API for vehicles
39
+ - Fleet API for energy sites
40
+ - Fleet API with signed vehicle commands
41
+ - Bluetooth for vehicles
42
+ - Teslemetry integration
43
+ - Tessie integration
44
+
45
+ ## Installation
46
+
47
+ You can install the library using pip:
48
+
49
+ ```bash
50
+ pip install tesla-fleet-api
51
+ ```
52
+
53
+ ## Usage
54
+
55
+ ### Authentication
56
+
57
+ The `TeslaFleetOAuth` class provides methods that help with authenticating to the Tesla Fleet API. Here's a basic example:
58
+
59
+ ```python
60
+ import asyncio
61
+ import aiohttp
62
+ from tesla_fleet_api import TeslaFleetOAuth
63
+
64
+ async def main():
65
+ async with aiohttp.ClientSession() as session:
66
+ oauth = TeslaFleetOAuth(
67
+ session=session,
68
+ client_id="<client_id>",
69
+ client_secret="<client_secret>",
70
+ redirect_uri="<redirect_uri>",
71
+ )
72
+
73
+ # Get the login URL and navigate the user to it
74
+ login_url = oauth.get_login_url(scopes=["openid", "email", "offline_access"])
75
+ print(f"Please go to {login_url} and authorize access.")
76
+
77
+ # After the user authorizes access, they will be redirected to the redirect_uri with a code
78
+ code = input("Enter the code you received: ")
79
+
80
+ # Exchange the code for a refresh token
81
+ await oauth.get_refresh_token(code)
82
+ print(f"Access token: {oauth.access_token}")
83
+ print(f"Refresh token: {oauth.refresh_token}")
84
+ # Dont forget to store the refresh token so you can use it again later
85
+
86
+ asyncio.run(main())
87
+ ```
88
+
89
+ ### Fleet API for Vehicles
90
+
91
+ The `TeslaFleetApi` class provides methods to interact with the Fleet API for vehicles. Here's a basic example:
92
+
93
+ ```python
94
+ import asyncio
95
+ import aiohttp
96
+ from tesla_fleet_api import TeslaFleetApi
97
+ from tesla_fleet_api.exceptions import TeslaFleetError
98
+
99
+ async def main():
100
+ async with aiohttp.ClientSession() as session:
101
+ api = TeslaFleetApi(
102
+ access_token="<access_token>",
103
+ session=session,
104
+ region="na",
105
+ )
106
+
107
+ try:
108
+ data = await api.vehicles.list()
109
+ print(data)
110
+ except TeslaFleetError as e:
111
+ print(e)
112
+
113
+ asyncio.run(main())
114
+ ```
115
+
116
+ For more detailed examples, see [Fleet API for Vehicles](docs/fleet_api_vehicles.md).
117
+
118
+ ### Fleet API for Energy Sites
119
+
120
+ The `EnergySites` class provides methods to interact with the Fleet API for energy sites. Here's a basic example:
121
+
122
+ ```python
123
+ import asyncio
124
+ import aiohttp
125
+ from tesla_fleet_api import TeslaFleetApi
126
+ from tesla_fleet_api.exceptions import TeslaFleetError
127
+
128
+ async def main():
129
+ async with aiohttp.ClientSession() as session:
130
+ api = TeslaFleetApi(
131
+ access_token="<access_token>",
132
+ session=session,
133
+ region="na",
134
+ )
135
+
136
+ try:
137
+ energy_sites = await api.energySites.list()
138
+ print(energy_sites)
139
+ except TeslaFleetError as e:
140
+ print(e)
141
+
142
+ asyncio.run(main())
143
+ ```
144
+
145
+ For more detailed examples, see [Fleet API for Energy Sites](docs/fleet_api_energy_sites.md).
146
+
147
+ ### Fleet API with Signed Vehicle Commands
148
+
149
+ The `VehicleSigned` class provides methods to interact with the Fleet API using signed vehicle commands. Here's a basic example:
150
+
151
+ ```python
152
+ import asyncio
153
+ import aiohttp
154
+ from tesla_fleet_api import TeslaFleetApi
155
+ from tesla_fleet_api.tesla.vehicle.signed import VehicleSigned
156
+ from tesla_fleet_api.exceptions import TeslaFleetError
157
+
158
+ async def main():
159
+ async with aiohttp.ClientSession() as session:
160
+ api = TeslaFleetApi(
161
+ access_token="<access_token>",
162
+ session=session,
163
+ region="na",
164
+ )
165
+
166
+ try:
167
+ vehicle = VehicleSigned(api, "<vin>")
168
+ await vehicle.handshake()
169
+ data = await vehicle.wake_up()
170
+ print(data)
171
+ except TeslaFleetError as e:
172
+ print(e)
173
+
174
+ asyncio.run(main())
175
+ ```
176
+
177
+ For more detailed examples, see [Fleet API with Signed Vehicle Commands](docs/fleet_api_signed_commands.md).
178
+
179
+ ### Bluetooth for Vehicles
180
+
181
+ The `TeslaBluetooth` class provides methods to interact with Tesla vehicles using Bluetooth. Here's a basic example:
182
+
183
+ ```python
184
+ import asyncio
185
+ from bleak import BleakScanner
186
+ from tesla_fleet_api import TeslaBluetooth
187
+
188
+ async def main():
189
+ scanner = BleakScanner()
190
+ devices = await scanner.discover()
191
+ for device in devices:
192
+ if TeslaBluetooth().valid_name(device.name):
193
+ print(f"Found Tesla vehicle: {device.name}")
194
+
195
+ asyncio.run(main())
196
+ ```
197
+
198
+ For more detailed examples, see [Bluetooth for Vehicles](docs/bluetooth_vehicles.md).
199
+
200
+ ### Teslemetry
201
+
202
+ The `Teslemetry` class provides methods to interact with the Teslemetry service. Here's a basic example:
203
+
204
+ ```python
205
+ import asyncio
206
+ import aiohttp
207
+ from tesla_fleet_api import Teslemetry
208
+ from tesla_fleet_api.exceptions import TeslaFleetError
209
+
210
+ async def main():
211
+ async with aiohttp.ClientSession() as session:
212
+ api = Teslemetry(
213
+ access_token="<access_token>",
214
+ session=session,
215
+ )
216
+
217
+ try:
218
+ data = await api.vehicles.list()
219
+ print(data)
220
+ except TeslaFleetError as e:
221
+ print(e)
222
+
223
+ asyncio.run(main())
224
+ ```
225
+
226
+ For more detailed examples, see [Teslemetry](docs/teslemetry.md).
227
+
228
+ ### Tessie
229
+
230
+ The `Tessie` class provides methods to interact with the Tessie service. Here's a basic example:
231
+
232
+ ```python
233
+ import asyncio
234
+ import aiohttp
235
+ from tesla_fleet_api import Tessie
236
+ from tesla_fleet_api.exceptions import TeslaFleetError
237
+
238
+ async def main():
239
+ async with aiohttp.ClientSession() as session:
240
+ api = Tessie(
241
+ access_token="<access_token>",
242
+ session=session,
243
+ )
244
+
245
+ try:
246
+ data = await api.vehicles.list()
247
+ print(data)
248
+ except TeslaFleetError as e:
249
+ print(e)
250
+
251
+ asyncio.run(main())
252
+ ```
253
+
254
+ For more detailed examples, see [Tessie](docs/tessie.md).
@@ -1,23 +1,22 @@
1
- tesla_fleet_api/__init__.py,sha256=3DZMoZ-5srW-7SooAjqcRubQDuZPY8rMKH7eqIp4qtg,392
2
- tesla_fleet_api/const.py,sha256=GyNepuHCbWnq7w_1TgJT5PjBpTNQhoCZdWCwIPKz4a8,3749
1
+ tesla_fleet_api/__init__.py,sha256=eFUgI1Ardu7JVG2Sn9hwW9VT9ou7IYR3aFjrCxGSSw0,475
2
+ tesla_fleet_api/const.py,sha256=cu9jvvFTLOw56bL78lIPWJKlb35T9CYACI5pBT6DBQI,3881
3
3
  tesla_fleet_api/exceptions.py,sha256=GvjJBR77xGt2g3vhiAxcNtysj-e1Me7F-9PwO9dyzOo,35430
4
- tesla_fleet_api/ratecalculator.py,sha256=4lz8yruUeouHXh_3ezsXX-CTpIegp1T1J4VuRV_qdHA,1791
5
- tesla_fleet_api/tesla/__init__.py,sha256=Cvpqu8OaOFmbuwu9KjgYrje8eVluDp2IU_zwdtXbmO0,282
4
+ tesla_fleet_api/tesla/__init__.py,sha256=oAWKAqERcL0fN5ahyU9Lq9YajY_WcO-KCphj6Iq0NsI,799
6
5
  tesla_fleet_api/tesla/bluetooth.py,sha256=lyPRVf1YdcElrYBsKOMCaLwMPE9rO7Iw1a6nE7VUZ94,2369
7
6
  tesla_fleet_api/tesla/charging.py,sha256=D7I7cAf-3-95sIjyP6wpVqCq9Cppj6U-VPFQGpQQ8bs,1704
8
7
  tesla_fleet_api/tesla/energysite.py,sha256=vStffklBQfQNAO_1wrHLFu7BlBCTVVbLh7_IrAUL3wg,6131
9
- tesla_fleet_api/tesla/fleet.py,sha256=zfmagXF4TbbVOPWcngCSKebaGB1daXbw8mTJ9o8einY,5432
8
+ tesla_fleet_api/tesla/fleet.py,sha256=3pPwPM4LNm5glZxQzS0DieOYVljp0laXaQxVagw258U,5429
10
9
  tesla_fleet_api/tesla/oauth.py,sha256=aWBsWmnM-QxzaU8W9TXVNxGsYn_LraXnpexwdE8wOqo,4104
11
10
  tesla_fleet_api/tesla/partner.py,sha256=e-l6sEP6-IupjFEQieSUjhhvRXF3aL4ebPNahcGFRCE,1238
12
11
  tesla_fleet_api/tesla/tesla.py,sha256=Gs8-L3OsEMhs1N_vdDx-E46bOHKGowXTBxmRiP8NKh4,2391
13
12
  tesla_fleet_api/tesla/user.py,sha256=w8rwiAOIFjuDus8M0RpZ0wucJtw8kYFKtJfYVk7Ekr0,1194
14
- tesla_fleet_api/tesla/vehicle/__init__.py,sha256=3A5_wTQHofRShof4pUNOtF78-7lUh62uz2jq2ecnmRY,381
13
+ tesla_fleet_api/tesla/vehicle/__init__.py,sha256=EYqPyPjaD9JP846c1iGBkk697VZ-eY_tcHntDixhDGE,425
15
14
  tesla_fleet_api/tesla/vehicle/bluetooth.py,sha256=rMxKOrc8T3Wz_sbuGYFot4ffCbOVP2jFSCd5tVuSWv0,21035
16
15
  tesla_fleet_api/tesla/vehicle/commands.py,sha256=L3apfGwry-IBuSSLbuoPPjW_q4new2xTr6Iy_kUa2pA,51268
17
16
  tesla_fleet_api/tesla/vehicle/fleet.py,sha256=K9BVZj6CChJSDSMFroa7Cz0KrsYWj32ILtQumarkLaU,32080
18
17
  tesla_fleet_api/tesla/vehicle/signed.py,sha256=RUzVnZIfykz3YZW2gaxd1iaN1i8LkLaEoiXrbqZn9kg,1339
19
18
  tesla_fleet_api/tesla/vehicle/vehicle.py,sha256=IBvRO6qGkUf4bi-pFongA9fIe9iScvz_wGXtzEJXilY,870
20
- tesla_fleet_api/tesla/vehicle/vehicles.py,sha256=wU0wXa57BD7InaUC1xoRhVc7oI5CemsocSryuUItyGI,2792
19
+ tesla_fleet_api/tesla/vehicle/vehicles.py,sha256=c1KFTAYDvuTVNjM5O23KvT54UbNwo3ofFVpfkY-Mq5Y,2640
21
20
  tesla_fleet_api/tesla/vehicle/proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
21
  tesla_fleet_api/tesla/vehicle/proto/__init__.pyi,sha256=qFXWNIgl71wB260u-XPzaAwWAHL6krw21q-aXnBtop0,252
23
22
  tesla_fleet_api/tesla/vehicle/proto/car_server_pb2.py,sha256=v_eb4NDIkx_ZYPYW29_EFRky5vQ4b2q14gwuQSbouYw,29202
@@ -38,14 +37,14 @@ tesla_fleet_api/tesla/vehicle/proto/vcsec_pb2.py,sha256=PDv9TfiXnNs6sQ0D5vBrsSSP
38
37
  tesla_fleet_api/tesla/vehicle/proto/vcsec_pb2.pyi,sha256=cyK1uyRtDjRVqVlyl5uRQYY1RhFlWSJheLg3PGfs-_s,28524
39
38
  tesla_fleet_api/tesla/vehicle/proto/vehicle_pb2.py,sha256=bqyFJM-1qZ7W9XKREINhYZx8yXAudmq6W8_Pdfkhbkk,44711
40
39
  tesla_fleet_api/tesla/vehicle/proto/vehicle_pb2.pyi,sha256=sAUW_9aVB8NqJCnhZjXMLfqfePLVZv_7PfSKZKEBaQA,74251
41
- tesla_fleet_api/teslemetry/__init__.py,sha256=CX7rMtlTuVvXoH9GkOAkQBTtM13ltuOO6EsGELuzQzY,94
40
+ tesla_fleet_api/teslemetry/__init__.py,sha256=BFi16_y-1wRF8XhtgHsYM22eT8T1hTAGJ10S3Q9rWHI,464
42
41
  tesla_fleet_api/teslemetry/teslemetry.py,sha256=wcZOD1GnZ4lwC9LoicuSNbZ3z-ka9I4m1AMZP4LDYCY,3088
43
- tesla_fleet_api/teslemetry/vehicles.py,sha256=9nybVg7VHKLa2woMG6fzMmQP6xJIE_jdAdScXytxElI,2209
44
- tesla_fleet_api/tessie/__init__.py,sha256=9lhQJaB6X4PObUL9QdaaZYqs2BxiTidu3zmHcBESLVw,78
42
+ tesla_fleet_api/teslemetry/vehicles.py,sha256=IJMRKb3jrW9ZSdJrCQ5wOYYZGVbFvSVza24Zpdh4d_0,2067
43
+ tesla_fleet_api/tessie/__init__.py,sha256=8HiaMLz1RueRoT5PSF1Y7iRr0-RV6ujgOH2RBSSUFk4,436
45
44
  tesla_fleet_api/tessie/tessie.py,sha256=uhg0oOIxpwDvlvdBhKHeF3AGR2PzmdBgzh2-_EkmSq0,2617
46
- tesla_fleet_api/tessie/vehicles.py,sha256=gfEatilI_ct-R4CM5xYhrlduqCR9IHlyc56WmJf7v7k,1149
47
- tesla_fleet_api-1.0.12.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
48
- tesla_fleet_api-1.0.12.dist-info/METADATA,sha256=Z3qVhTn4BJs_P54gNAn4W02VUgvFhXkRh7yTveJvPn4,4383
49
- tesla_fleet_api-1.0.12.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
50
- tesla_fleet_api-1.0.12.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
51
- tesla_fleet_api-1.0.12.dist-info/RECORD,,
45
+ tesla_fleet_api/tessie/vehicles.py,sha256=Cdp0pt2Z8bzK5T9wQ8_KubGSZ3Gevx1Q18kqJqEUxfs,1011
46
+ tesla_fleet_api-1.0.14.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
47
+ tesla_fleet_api-1.0.14.dist-info/METADATA,sha256=ZG36GhQmSWLB-xe866eHesBemeY68vijuB_LRKElpZw,6960
48
+ tesla_fleet_api-1.0.14.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
49
+ tesla_fleet_api-1.0.14.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
50
+ tesla_fleet_api-1.0.14.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (76.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,60 +0,0 @@
1
- """Rate Calculator helper"""
2
-
3
- import time
4
-
5
- DAY = 24 * 60 * 60
6
-
7
-
8
- class RateCalculator:
9
- """Calculate the consumption and remaining rate of a rate limit."""
10
-
11
- def __init__(
12
- self,
13
- limit: int,
14
- period: int = 86400,
15
- min_wait: int = 0,
16
- max_wait: int | None = None,
17
- factor: int = 5,
18
- ) -> None:
19
- """Initialize the rate calculator."""
20
- self.limit: int = limit
21
- self.period: int = period
22
- self.history: list[int] = []
23
- self.start = time.time()
24
- self.min_wait = min_wait
25
- self.max_wait = max_wait if max_wait is not None else period
26
- self.factor = factor
27
-
28
- def constrain(self, value: float) -> float:
29
- """Constrain a value between min and max."""
30
- return max(self.min_wait, min(self.max_wait, value))
31
-
32
- def consume(self, timestamp: int | None = None) -> None:
33
- """Consume a unit of the rate limit."""
34
- now = timestamp or int(time.time() + 1)
35
- self.history.append(now)
36
-
37
- def calculate(self, timestamp: int | None = None) -> float:
38
- """Return the ideal delay to avoid rate limiting."""
39
-
40
- count = len(self.history)
41
- if count == 0:
42
- return self.min_wait
43
-
44
- now = timestamp or int(time.time())
45
-
46
- while self.history and self.history[0] < now - self.period:
47
- self.history.pop(0)
48
-
49
- remaining = self.limit - count
50
-
51
- if remaining <= 0:
52
- # The wait until a request is available
53
- return self.constrain(self.history[abs(remaining)] + self.period - now)
54
-
55
- return self.constrain(self.period / remaining / self.factor)
56
-
57
- @property
58
- def count(self) -> int:
59
- """Return the number of requests in the current period."""
60
- return len(self.history)
@@ -1,158 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: tesla_fleet_api
3
- Version: 1.0.12
4
- Summary: Tesla Fleet API library for Python
5
- Home-page: https://github.com/Teslemetry/python-tesla-fleet-api
6
- Author: Brett Adams
7
- Author-email: hello@teslemetry.com
8
- Classifier: Development Status :: 5 - Production/Stable
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: License :: OSI Approved :: Apache Software License
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.10
13
- Description-Content-Type: text/markdown
14
- License-File: LICENSE
15
- Requires-Dist: aiohttp
16
- Requires-Dist: aiofiles
17
- Requires-Dist: aiolimiter
18
- Requires-Dist: cryptography
19
- Requires-Dist: protobuf
20
- Requires-Dist: bleak
21
- Requires-Dist: bleak-retry-connector
22
- Dynamic: author
23
- Dynamic: author-email
24
- Dynamic: classifier
25
- Dynamic: description
26
- Dynamic: description-content-type
27
- Dynamic: home-page
28
- Dynamic: requires-dist
29
- Dynamic: requires-python
30
- Dynamic: summary
31
-
32
- # Tesla Fleet Api
33
- Python library for Tesla Fleet API and Tesla Command Protocol, including signed commands and encrypted local Bluetooth (BLE). Also provides interfaces for Teslemetry and Tessie.
34
-
35
- Based on [Tesla Developer documentation](https://developer.tesla.com/docs/fleet-api) and [Tesla Command Protocol](https://github.com/teslamotors/vehicle-command/blob/main/pkg/protocol/protocol.md)
36
-
37
- **Documentation is currently outdated for V1.0.X**
38
-
39
- ## TeslaFleetApi
40
- This is the base class, however can also be used directly if you have a valid user access_token.
41
-
42
- ```
43
- import asyncio
44
- import aiohttp
45
-
46
- from tesla_fleet_api import TeslaFleetApi
47
- from tesla_fleet_api.exceptions import TeslaFleetError
48
-
49
-
50
- async def main():
51
- async with aiohttp.ClientSession() as session:
52
- api = TeslaFleetApi(
53
- access_token="<access_token>",
54
- session=session,
55
- region="na",
56
- )
57
-
58
- try:
59
- data = await api.vehicle.list()
60
- print(data)
61
- except TeslaFleetError as e:
62
- print(e)
63
-
64
- asyncio.run(main())
65
- ```
66
-
67
- ## TeslaFleetOAuth
68
- This extends TeslaFleetApi to support OAuth, and requires a client_id, and either a refresh_token or initial authentication code.
69
-
70
- ```
71
- from tesla_fleet_api import TeslaFleetOAuth
72
- from tesla_fleet_api.exceptions import TeslaFleetError
73
- import json
74
-
75
- async def main():
76
- with open("auth.json", "r") as f:
77
- auth = json.load(f)
78
- async with aiohttp.ClientSession() as session:
79
- api = TeslaFleetOAuth(
80
- session,
81
- client_id=<client_id>,
82
- access_token=auth["access_token"],
83
- refresh_token=auth["refresh_token"],
84
- expires=auth["expires"],
85
- region="na",
86
- )
87
- try:
88
- data = await api.vehicle.list()
89
- print(data)
90
- except TeslaFleetError as e:
91
- print(e)
92
-
93
- with open("auth.json", "w") as f:
94
- json.dump(
95
- {
96
- "access_token": api.access_token,
97
- "refresh_token": api.refresh_token,
98
- "expires": api.expires,
99
- },
100
- f,
101
- )
102
-
103
- asyncio.run(main())
104
- ```
105
-
106
- ## Teslemetry
107
- This extends TeslaFleetApi to send requests through Teslemetry, which manages all aspects of Tesla OAuth. This class only requires an access_token from the Teslemetry console.
108
-
109
- ```
110
- import asyncio
111
- import aiohttp
112
-
113
- from tesla_fleet_api import Teslemetry
114
- from tesla_fleet_api.exceptions import TeslaFleetError
115
-
116
-
117
- async def main():
118
- async with aiohttp.ClientSession() as session:
119
- api = Teslemetry(
120
- access_token="<access_token>",
121
- session=session,
122
- )
123
-
124
- try:
125
- data = await api.vehicle.list()
126
- print(data)
127
- except TeslaFleetError as e:
128
- print(e)
129
-
130
- asyncio.run(main())
131
- ```
132
-
133
- ## Tessie
134
- This extends TeslaFleetApi to send requests through Tessie, which manages all aspects of Tesla OAuth. This class only requires an access_token from [Tessie](https://dash.tessie.com/settings/api).
135
-
136
- ```
137
- import asyncio
138
- import aiohttp
139
-
140
- from tesla_fleet_api import Tessie
141
- from tesla_fleet_api.exceptions import TeslaFleetError
142
-
143
-
144
- async def main():
145
- async with aiohttp.ClientSession() as session:
146
- api = Tessie(
147
- access_token="<access_token>",
148
- session=session,
149
- )
150
-
151
- try:
152
- data = await api.vehicle.list()
153
- print(data)
154
- except TeslaFleetError as e:
155
- print(e)
156
-
157
- asyncio.run(main())
158
- ```