tesla-fleet-api 0.7.7__py3-none-any.whl → 0.8.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
tesla_fleet_api/const.py CHANGED
@@ -3,7 +3,7 @@
3
3
  from enum import Enum
4
4
  import logging
5
5
 
6
- VERSION = "0.7.7"
6
+ VERSION = "0.8.0"
7
7
  LOGGER = logging.getLogger(__package__)
8
8
  SERVERS = {
9
9
  "na": "https://fleet-api.prd.na.vn.cloud.tesla.com",
tesla_fleet_api/energy.py CHANGED
@@ -32,10 +32,10 @@ class Energy:
32
32
  async def backup_history(
33
33
  self,
34
34
  energy_site_id: int,
35
- start_date: str,
36
- end_date: str,
37
- period: TeslaEnergyPeriod | str,
38
- time_zone: str,
35
+ period: TeslaEnergyPeriod | str | None,
36
+ start_date: str | None = None,
37
+ end_date: str | None = None,
38
+ time_zone: str | None = None,
39
39
  ) -> dict[str, Any]:
40
40
  """Returns the backup (off-grid) event history of the site in duration of seconds."""
41
41
  return await self._request(
@@ -55,7 +55,7 @@ class Energy:
55
55
  energy_site_id: int,
56
56
  start_date: str,
57
57
  end_date: str,
58
- time_zone: str,
58
+ time_zone: str | None = None,
59
59
  ) -> dict[str, Any]:
60
60
  """Returns the charging history of a wall connector."""
61
61
  return await self._request(
@@ -72,10 +72,10 @@ class Energy:
72
72
  async def energy_history(
73
73
  self,
74
74
  energy_site_id: int,
75
- start_date: str,
76
- end_date: str,
77
- period: TeslaEnergyPeriod | str,
78
- time_zone: str,
75
+ period: TeslaEnergyPeriod | str | None,
76
+ start_date: str | None = None,
77
+ end_date: str | None = None,
78
+ time_zone: str | None = None,
79
79
  ) -> dict[str, Any]:
80
80
  """Returns the energy measurements of the site, aggregated to the requested period."""
81
81
  return await self._request(
@@ -29,17 +29,17 @@ class EnergySpecific:
29
29
 
30
30
  async def backup_history(
31
31
  self,
32
- start_date: str,
33
- end_date: str,
34
32
  period: TeslaEnergyPeriod | str,
35
- time_zone: str,
33
+ start_date: str | None = None,
34
+ end_date: str | None = None,
35
+ time_zone: str | None = None,
36
36
  ) -> dict[str, Any]:
37
37
  """Returns the backup (off-grid) event history of the site in duration of seconds."""
38
38
  return await self._parent.backup_history(
39
39
  self.energy_site_id,
40
+ period,
40
41
  start_date,
41
42
  end_date,
42
- period,
43
43
  time_zone,
44
44
  )
45
45
 
@@ -47,7 +47,7 @@ class EnergySpecific:
47
47
  self,
48
48
  start_date: str,
49
49
  end_date: str,
50
- time_zone: str,
50
+ time_zone: str | None = None,
51
51
  ) -> dict[str, Any]:
52
52
  """Returns the charging history of a wall connector."""
53
53
  return await self._parent.charge_history(
@@ -59,17 +59,17 @@ class EnergySpecific:
59
59
 
60
60
  async def energy_history(
61
61
  self,
62
- start_date: str,
63
- end_date: str,
64
62
  period: TeslaEnergyPeriod | str,
65
- time_zone: str,
63
+ start_date: str | None = None,
64
+ end_date: str | None = None,
65
+ time_zone: str | None = None,
66
66
  ) -> dict[str, Any]:
67
67
  """Returns the energy measurements of the site, aggregated to the requested period."""
68
68
  return await self._parent.energy_history(
69
69
  self.energy_site_id,
70
+ period,
70
71
  start_date,
71
72
  end_date,
72
- period,
73
73
  time_zone,
74
74
  )
75
75
 
@@ -293,6 +293,169 @@ class LibraryError(Exception):
293
293
  """Errors related to this library."""
294
294
 
295
295
 
296
+ class TeslaFleetSigningError(TeslaFleetError):
297
+ """Vehicle has responded with an error when sending a signed command"""
298
+
299
+ message = "Vehicle has responded with an error when sending a signed command"
300
+
301
+
302
+ class UnknownFault(TeslaFleetSigningError):
303
+ """Unknown fault on signed command."""
304
+
305
+ message = "Unknown fault on signed command."
306
+ code = 1
307
+
308
+
309
+ class NotOnWhitelistFault(TeslaFleetSigningError):
310
+ """Not on whitelist fault on signed command."""
311
+
312
+ message = "Not on whitelist fault on signed command."
313
+ code = 2
314
+
315
+
316
+ class IVSmallerThanExpectedFault(TeslaFleetSigningError):
317
+ """IV smaller than expected fault on signed command."""
318
+
319
+ message = "IV smaller than expected fault on signed command."
320
+ code = 3
321
+
322
+
323
+ class InvalidTokenFault(TeslaFleetSigningError):
324
+ """Invalid token fault on signed command."""
325
+
326
+ message = "Invalid token fault on signed command."
327
+ code = 4
328
+
329
+
330
+ class TokenAndCounterInvalidFault(TeslaFleetSigningError):
331
+ """Token and counter invalid fault on signed command."""
332
+
333
+ message = "Token and counter invalid fault on signed command."
334
+ code = 5
335
+
336
+
337
+ class AESDecryptAuthFault(TeslaFleetSigningError):
338
+ """AES decrypt auth fault on signed command."""
339
+
340
+ message = "AES decrypt auth fault on signed command."
341
+ code = 6
342
+
343
+
344
+ class ECDSAInputFault(TeslaFleetSigningError):
345
+ """ECDSA input fault on signed command."""
346
+
347
+ message = "ECDSA input fault on signed command."
348
+ code = 7
349
+
350
+
351
+ class ECDSASignatureFault(TeslaFleetSigningError):
352
+ """ECDSA signature fault on signed command."""
353
+
354
+ message = "ECDSA signature fault on signed command."
355
+ code = 8
356
+
357
+
358
+ class LocalEntityStartFault(TeslaFleetSigningError):
359
+ """Local entity start fault on signed command."""
360
+
361
+ message = "Local entity start fault on signed command."
362
+ code = 9
363
+
364
+
365
+ class LocalEntityResultFault(TeslaFleetSigningError):
366
+ """Local entity result fault on signed command."""
367
+
368
+ message = "Local entity result fault on signed command."
369
+ code = 10
370
+
371
+
372
+ class CouldNotRetrieveKeyFault(TeslaFleetSigningError):
373
+ """Could not retrieve key fault on signed command."""
374
+
375
+ message = "Could not retrieve key fault on signed command."
376
+ code = 11
377
+
378
+
379
+ class CouldNotRetrieveTokenFault(TeslaFleetSigningError):
380
+ """Could not retrieve token fault on signed command."""
381
+
382
+ message = "Could not retrieve token fault on signed command."
383
+ code = 12
384
+
385
+
386
+ class SignatureTooShortFault(TeslaFleetSigningError):
387
+ """Signature too short fault on signed command."""
388
+
389
+ message = "Signature too short fault on signed command."
390
+ code = 13
391
+
392
+
393
+ class TokenIsIncorrectLengthFault(TeslaFleetSigningError):
394
+ """Token is incorrect length fault on signed command."""
395
+
396
+ message = "Token is incorrect length fault on signed command."
397
+ code = 14
398
+
399
+
400
+ class IncorrectEpochFault(TeslaFleetSigningError):
401
+ """Incorrect epoch fault on signed command."""
402
+
403
+ message = "Incorrect epoch fault on signed command."
404
+ code = 15
405
+
406
+
407
+ class IVIncorrectLengthFault(TeslaFleetSigningError):
408
+ """IV incorrect length fault on signed command."""
409
+
410
+ message = "IV incorrect length fault on signed command."
411
+ code = 16
412
+
413
+
414
+ class TimeExpiredFault(TeslaFleetSigningError):
415
+ """Time expired fault on signed command."""
416
+
417
+ message = "Time expired fault on signed command."
418
+ code = 17
419
+
420
+
421
+ class NotProvisionedWithIdentityFault(TeslaFleetSigningError):
422
+ """Not provisioned with identity fault on signed command."""
423
+
424
+ message = "Not provisioned with identity fault on signed command."
425
+ code = 18
426
+
427
+
428
+ class CouldNotHashMetadataFault(TeslaFleetSigningError):
429
+ """Could not hash metadata fault on signed command."""
430
+
431
+ message = "Could not hash metadata fault on signed command."
432
+ code = 19
433
+
434
+
435
+ SIGNING_EXCEPTIONS = [
436
+ None,
437
+ UnknownFault,
438
+ NotOnWhitelistFault,
439
+ IVSmallerThanExpectedFault,
440
+ InvalidTokenFault,
441
+ TokenAndCounterInvalidFault,
442
+ AESDecryptAuthFault,
443
+ ECDSAInputFault,
444
+ ECDSASignatureFault,
445
+ LocalEntityStartFault,
446
+ LocalEntityResultFault,
447
+ CouldNotRetrieveKeyFault,
448
+ CouldNotRetrieveTokenFault,
449
+ SignatureTooShortFault,
450
+ TokenIsIncorrectLengthFault,
451
+ IncorrectEpochFault,
452
+ IVIncorrectLengthFault,
453
+ TimeExpiredFault,
454
+ NotProvisionedWithIdentityFault,
455
+ CouldNotHashMetadataFault,
456
+ ]
457
+
458
+
296
459
  async def raise_for_status(resp: aiohttp.ClientResponse) -> None:
297
460
  """Raise an exception if the response status code is >=400."""
298
461
  # https://developer.tesla.com/docs/fleet-api#response-codes
File without changes
File without changes