tesla-fleet-api 1.0.13__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.
- tesla_fleet_api/__init__.py +5 -0
- tesla_fleet_api/const.py +0 -1
- tesla_fleet_api/tesla/__init__.py +2 -1
- tesla_fleet_api/tesla/fleet.py +2 -2
- tesla_fleet_api/teslemetry/__init__.py +2 -1
- tesla_fleet_api/tessie/__init__.py +2 -1
- {tesla_fleet_api-1.0.13.dist-info → tesla_fleet_api-1.0.14.dist-info}/METADATA +1 -1
- {tesla_fleet_api-1.0.13.dist-info → tesla_fleet_api-1.0.14.dist-info}/RECORD +11 -12
- tesla_fleet_api/ratecalculator.py +0 -60
- {tesla_fleet_api-1.0.13.dist-info → tesla_fleet_api-1.0.14.dist-info}/LICENSE +0 -0
- {tesla_fleet_api-1.0.13.dist-info → tesla_fleet_api-1.0.14.dist-info}/WHEEL +0 -0
- {tesla_fleet_api-1.0.13.dist-info → tesla_fleet_api-1.0.14.dist-info}/top_level.txt +0 -0
tesla_fleet_api/__init__.py
CHANGED
tesla_fleet_api/const.py
CHANGED
@@ -4,7 +4,7 @@ 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
6
|
from tesla_fleet_api.tesla.charging import Charging
|
7
|
-
from tesla_fleet_api.tesla.energysite import EnergySites
|
7
|
+
from tesla_fleet_api.tesla.energysite import EnergySites, EnergySite
|
8
8
|
from tesla_fleet_api.tesla.partner import Partner
|
9
9
|
from tesla_fleet_api.tesla.user import User
|
10
10
|
from tesla_fleet_api.tesla.vehicle import Vehicles, VehiclesBluetooth, VehicleFleet, VehicleSigned, VehicleBluetooth
|
@@ -15,6 +15,7 @@ __all__ = [
|
|
15
15
|
"TeslaFleetOAuth",
|
16
16
|
"Charging",
|
17
17
|
"EnergySites",
|
18
|
+
"EnergySite",
|
18
19
|
"Partner",
|
19
20
|
"User",
|
20
21
|
"Vehicles",
|
tesla_fleet_api/tesla/fleet.py
CHANGED
@@ -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
|
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):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from tesla_fleet_api.teslemetry.teslemetry import Teslemetry
|
2
2
|
from tesla_fleet_api.tesla.charging import Charging
|
3
|
-
from tesla_fleet_api.tesla.energysite import EnergySites
|
3
|
+
from tesla_fleet_api.tesla.energysite import EnergySites, EnergySite
|
4
4
|
from tesla_fleet_api.tesla.user import User
|
5
5
|
from tesla_fleet_api.teslemetry.vehicles import TeslemetryVehicles as Vehicles, TeslemetryVehicle as Vehicle
|
6
6
|
|
@@ -8,6 +8,7 @@ __all__ = [
|
|
8
8
|
"Teslemetry",
|
9
9
|
"Charging",
|
10
10
|
"EnergySites",
|
11
|
+
"EnergySite",
|
11
12
|
"User",
|
12
13
|
"Vehicles",
|
13
14
|
"Vehicle",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from tesla_fleet_api.tessie.tessie import Tessie
|
2
2
|
from tesla_fleet_api.tesla.charging import Charging
|
3
|
-
from tesla_fleet_api.tesla.energysite import EnergySites
|
3
|
+
from tesla_fleet_api.tesla.energysite import EnergySites, EnergySite
|
4
4
|
from tesla_fleet_api.tesla.user import User
|
5
5
|
from tesla_fleet_api.tessie.vehicles import TessieVehicles as Vehicles, TessieVehicle as Vehicle
|
6
6
|
|
@@ -8,6 +8,7 @@ __all__ = [
|
|
8
8
|
"Tessie",
|
9
9
|
"Charging",
|
10
10
|
"EnergySites",
|
11
|
+
"EnergySite",
|
11
12
|
"User",
|
12
13
|
"Vehicles",
|
13
14
|
"Vehicle",
|
@@ -1,12 +1,11 @@
|
|
1
|
-
tesla_fleet_api/__init__.py,sha256=
|
2
|
-
tesla_fleet_api/const.py,sha256=
|
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/
|
5
|
-
tesla_fleet_api/tesla/__init__.py,sha256=1XjIJWgHsYHLw9qgiVRh4FrHVOH9V8tGF0hE92PQhX8,769
|
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=
|
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
|
@@ -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=
|
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
42
|
tesla_fleet_api/teslemetry/vehicles.py,sha256=IJMRKb3jrW9ZSdJrCQ5wOYYZGVbFvSVza24Zpdh4d_0,2067
|
44
|
-
tesla_fleet_api/tessie/__init__.py,sha256=
|
43
|
+
tesla_fleet_api/tessie/__init__.py,sha256=8HiaMLz1RueRoT5PSF1Y7iRr0-RV6ujgOH2RBSSUFk4,436
|
45
44
|
tesla_fleet_api/tessie/tessie.py,sha256=uhg0oOIxpwDvlvdBhKHeF3AGR2PzmdBgzh2-_EkmSq0,2617
|
46
45
|
tesla_fleet_api/tessie/vehicles.py,sha256=Cdp0pt2Z8bzK5T9wQ8_KubGSZ3Gevx1Q18kqJqEUxfs,1011
|
47
|
-
tesla_fleet_api-1.0.
|
48
|
-
tesla_fleet_api-1.0.
|
49
|
-
tesla_fleet_api-1.0.
|
50
|
-
tesla_fleet_api-1.0.
|
51
|
-
tesla_fleet_api-1.0.
|
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,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)
|
File without changes
|
File without changes
|
File without changes
|