tesla-fleet-api 1.0.15__py3-none-any.whl → 1.0.16__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,7 +1,7 @@
1
1
  """Tesla Fleet API"""
2
2
 
3
3
  __author__ = "hello@teslemetry.com"
4
- __version__ = "1.0.15"
4
+ __version__ = "1.0.16"
5
5
 
6
6
  from tesla_fleet_api.tesla.fleet import TeslaFleetApi
7
7
  from tesla_fleet_api.tesla.bluetooth import TeslaBluetooth
@@ -110,7 +110,7 @@ class ReassemblingBuffer:
110
110
  if self.expected_length is None and len(self.buffer) >= 2:
111
111
  self.expected_length = struct.unpack(">H", self.buffer[:2])[0] + 2
112
112
 
113
- LOGGER.info(f"Buffer length: {len(self.buffer)}, Packet starts: {self.packet_starts}, Expected length: {self.expected_length}")
113
+ LOGGER.debug(f"Buffer length: {len(self.buffer)}, Packet starts: {self.packet_starts}, Expected length: {self.expected_length}")
114
114
 
115
115
  if self.expected_length is not None and self.expected_length > 1024:
116
116
  LOGGER.warning(f"Expected length too large: {self.expected_length}")
@@ -270,7 +270,7 @@ class VehicleBluetooth(Commands):
270
270
  if resp.HasField(requires):
271
271
  return resp
272
272
  else:
273
- LOGGER.warning(f"Ignoring message since it does not contain the required field {requires}, {resp.HasField(requires)}")
273
+ LOGGER.debug(f"Ignoring message since it does not contain the required field {requires}, {resp.HasField(requires)}")
274
274
 
275
275
  async def query_display_name(self, max_attempts=5) -> str | None:
276
276
  """Read the device name via GATT characteristic if available"""
@@ -158,24 +158,20 @@ CopActivationTemps = (
158
158
  class Session:
159
159
  """A connect to a domain"""
160
160
 
161
- domain: Domain
162
- parent: Commands
163
- key: bytes
164
- counter: int
165
- epoch: bytes
166
- delta: int
167
- sharedKey: bytes
168
- hmac: bytes
169
- publicKey: bytes
170
- lock: Lock
171
- ready: bool
172
-
173
161
  def __init__(self, parent: Commands, domain: Domain):
174
- self.parent = parent
175
- self.domain = domain
162
+ self.parent: Commands = parent
163
+ self.domain: Domain = domain
164
+ self.counter: int = 0
165
+ self.epoch: bytes | None = None
166
+ self.delta: int = 0
167
+ self.sharedKey: bytes | None = None
168
+ self.hmac: bytes | None = None
169
+ self.publicKey: bytes | None = None
176
170
  self.lock = Lock()
177
- self.counter = 0
178
- self.ready = False
171
+
172
+ @property
173
+ def ready(self) -> bool:
174
+ return self.epoch is not None and self.hmac is not None and self.delta > 0
179
175
 
180
176
  def update(self, sessionInfo: SessionInfo):
181
177
  """Update the session with new information"""
@@ -187,7 +183,6 @@ class Session:
187
183
  self.publicKey = sessionInfo.publicKey
188
184
  self.sharedKey = self.parent.shared_key(sessionInfo.publicKey)
189
185
  self.hmac = hmac.new(self.sharedKey, "authenticated command".encode(), hashlib.sha256).digest()
190
- self.ready = True
191
186
 
192
187
  def hmac_personalized(self) -> HMAC_Personalized_Signature_Data:
193
188
  """Sign a command and return session metadata"""
@@ -195,6 +190,7 @@ class Session:
195
190
  return HMAC_Personalized_Signature_Data(
196
191
  epoch=self.epoch,
197
192
  counter=self.counter,
193
+ # Expire command in 10 seconds
198
194
  expires_at=int(time.time()) - self.delta + 10,
199
195
  )
200
196
 
@@ -205,7 +201,8 @@ class Session:
205
201
  epoch=self.epoch,
206
202
  nonce=randbytes(12),
207
203
  counter=self.counter,
208
- expires_at=int(time.time()) - self.delta + 10,
204
+ # Expire command in 30 seconds (BLE can be slow)
205
+ expires_at=int(time.time()) - self.delta + 30,
209
206
  )
210
207
 
211
208
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tesla_fleet_api
3
- Version: 1.0.15
3
+ Version: 1.0.16
4
4
  Summary: Tesla Fleet API library for Python
5
5
  Home-page: https://github.com/Teslemetry/python-tesla-fleet-api
6
6
  Author: Brett Adams
@@ -1,4 +1,4 @@
1
- tesla_fleet_api/__init__.py,sha256=RvG6SPNWla8OcNsp9xQZBUHoGxWoU2NnnxQdd0lsXyg,475
1
+ tesla_fleet_api/__init__.py,sha256=e4HaWJI7rTX6_WGPqvGvXsjRvo37K4njhUm34fKhMXM,475
2
2
  tesla_fleet_api/const.py,sha256=cu9jvvFTLOw56bL78lIPWJKlb35T9CYACI5pBT6DBQI,3881
3
3
  tesla_fleet_api/exceptions.py,sha256=GvjJBR77xGt2g3vhiAxcNtysj-e1Me7F-9PwO9dyzOo,35430
4
4
  tesla_fleet_api/tesla/__init__.py,sha256=ahqqQigZbXfysOpo28qUudUfWrQfKRpD_1az368Sjr0,823
@@ -11,8 +11,8 @@ tesla_fleet_api/tesla/partner.py,sha256=e-l6sEP6-IupjFEQieSUjhhvRXF3aL4ebPNahcGF
11
11
  tesla_fleet_api/tesla/tesla.py,sha256=Gs8-L3OsEMhs1N_vdDx-E46bOHKGowXTBxmRiP8NKh4,2391
12
12
  tesla_fleet_api/tesla/user.py,sha256=w8rwiAOIFjuDus8M0RpZ0wucJtw8kYFKtJfYVk7Ekr0,1194
13
13
  tesla_fleet_api/tesla/vehicle/__init__.py,sha256=DKQA9lIAGcya5cHj4AsNc04pcQSVHn18htTrsvN_fRs,498
14
- tesla_fleet_api/tesla/vehicle/bluetooth.py,sha256=rMxKOrc8T3Wz_sbuGYFot4ffCbOVP2jFSCd5tVuSWv0,21035
15
- tesla_fleet_api/tesla/vehicle/commands.py,sha256=L3apfGwry-IBuSSLbuoPPjW_q4new2xTr6Iy_kUa2pA,51268
14
+ tesla_fleet_api/tesla/vehicle/bluetooth.py,sha256=CSUOx2rTYHM1iCShtZ3vu7kR-_m8E2dvNSLEksFqe6g,21034
15
+ tesla_fleet_api/tesla/vehicle/commands.py,sha256=CJ_NHJ9bCr5b6mjefxPPHChaUHLB6cVBFgwm6QYl4t4,51470
16
16
  tesla_fleet_api/tesla/vehicle/fleet.py,sha256=K9BVZj6CChJSDSMFroa7Cz0KrsYWj32ILtQumarkLaU,32080
17
17
  tesla_fleet_api/tesla/vehicle/signed.py,sha256=RUzVnZIfykz3YZW2gaxd1iaN1i8LkLaEoiXrbqZn9kg,1339
18
18
  tesla_fleet_api/tesla/vehicle/vehicle.py,sha256=IBvRO6qGkUf4bi-pFongA9fIe9iScvz_wGXtzEJXilY,870
@@ -43,8 +43,8 @@ tesla_fleet_api/teslemetry/vehicles.py,sha256=IJMRKb3jrW9ZSdJrCQ5wOYYZGVbFvSVza2
43
43
  tesla_fleet_api/tessie/__init__.py,sha256=8HiaMLz1RueRoT5PSF1Y7iRr0-RV6ujgOH2RBSSUFk4,436
44
44
  tesla_fleet_api/tessie/tessie.py,sha256=UByX0BmDcqLPiW8ofNuGmMcjXvaWRn3taC68Ji80Yf8,2666
45
45
  tesla_fleet_api/tessie/vehicles.py,sha256=Cdp0pt2Z8bzK5T9wQ8_KubGSZ3Gevx1Q18kqJqEUxfs,1011
46
- tesla_fleet_api-1.0.15.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
47
- tesla_fleet_api-1.0.15.dist-info/METADATA,sha256=td8AWGYdz8eJ-6BwoY4OHOScSonFjsAqcM0zvhQ3KuA,6960
48
- tesla_fleet_api-1.0.15.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
49
- tesla_fleet_api-1.0.15.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
50
- tesla_fleet_api-1.0.15.dist-info/RECORD,,
46
+ tesla_fleet_api-1.0.16.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
47
+ tesla_fleet_api-1.0.16.dist-info/METADATA,sha256=T9nLKyPQMFEmMtAmwOH5DpZR9JVVjAc6sXTIVwbdapw,6960
48
+ tesla_fleet_api-1.0.16.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
49
+ tesla_fleet_api-1.0.16.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
50
+ tesla_fleet_api-1.0.16.dist-info/RECORD,,