tesla-fleet-api 1.2.2__py3-none-any.whl → 1.2.4__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 +1 -1
- tesla_fleet_api/tesla/fleet.py +6 -6
- tesla_fleet_api/tesla/oauth.py +9 -6
- tesla_fleet_api/teslemetry/teslemetry.py +4 -2
- {tesla_fleet_api-1.2.2.dist-info → tesla_fleet_api-1.2.4.dist-info}/METADATA +1 -1
- {tesla_fleet_api-1.2.2.dist-info → tesla_fleet_api-1.2.4.dist-info}/RECORD +9 -9
- {tesla_fleet_api-1.2.2.dist-info → tesla_fleet_api-1.2.4.dist-info}/WHEEL +0 -0
- {tesla_fleet_api-1.2.2.dist-info → tesla_fleet_api-1.2.4.dist-info}/licenses/LICENSE +0 -0
- {tesla_fleet_api-1.2.2.dist-info → tesla_fleet_api-1.2.4.dist-info}/top_level.txt +0 -0
tesla_fleet_api/__init__.py
CHANGED
tesla_fleet_api/tesla/fleet.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"""Tesla Fleet API for Python."""
|
2
2
|
|
3
3
|
from json import dumps
|
4
|
-
from typing import Any, Awaitable, Callable
|
4
|
+
from typing import Any, Awaitable, Callable, Literal
|
5
5
|
import aiohttp
|
6
6
|
|
7
7
|
from tesla_fleet_api.tesla.tesla import Tesla
|
@@ -14,7 +14,6 @@ class TeslaFleetApi(Tesla):
|
|
14
14
|
"""Class describing the Tesla Fleet API."""
|
15
15
|
|
16
16
|
access_token: str | None = None
|
17
|
-
region: str | None = None
|
18
17
|
server: str | None = None
|
19
18
|
session: aiohttp.ClientSession
|
20
19
|
headers: dict[str, str]
|
@@ -24,7 +23,7 @@ class TeslaFleetApi(Tesla):
|
|
24
23
|
self,
|
25
24
|
session: aiohttp.ClientSession,
|
26
25
|
access_token: str | None = None,
|
27
|
-
region:
|
26
|
+
region: Literal["na", "eu", "cn"] | None = None,
|
28
27
|
server: str | None = None,
|
29
28
|
charging_scope: bool = True,
|
30
29
|
energy_scope: bool = True,
|
@@ -41,10 +40,11 @@ class TeslaFleetApi(Tesla):
|
|
41
40
|
|
42
41
|
if server is not None:
|
43
42
|
self.server = server
|
44
|
-
elif region
|
45
|
-
|
46
|
-
raise ValueError(f"Region must be one of {', '.join(SERVERS.keys())}")
|
43
|
+
elif region in SERVERS:
|
44
|
+
self.region = region
|
47
45
|
self.server = SERVERS.get(region)
|
46
|
+
else:
|
47
|
+
raise ValueError(f"Region must be one of {', '.join(SERVERS.keys())}")
|
48
48
|
|
49
49
|
LOGGER.debug("Using server %s", self.server)
|
50
50
|
|
tesla_fleet_api/tesla/oauth.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
from
|
1
|
+
from pickle import INT
|
2
|
+
from typing import Any, Literal
|
2
3
|
import aiohttp
|
3
4
|
import time
|
4
5
|
|
@@ -17,14 +18,13 @@ class TeslaFleetOAuth(TeslaFleetApi):
|
|
17
18
|
def __init__(
|
18
19
|
self,
|
19
20
|
session: aiohttp.ClientSession,
|
21
|
+
region: Literal["na", "eu", "cn"],
|
20
22
|
client_id: str,
|
21
23
|
client_secret: str | None = None,
|
22
24
|
redirect_uri: str | None = None,
|
23
25
|
access_token: str | None = None,
|
24
26
|
refresh_token: str | None = None,
|
25
27
|
expires: int = 0,
|
26
|
-
region: str | None = None,
|
27
|
-
server: str | None = None,
|
28
28
|
):
|
29
29
|
self.client_id = client_id
|
30
30
|
self._client_secret = client_secret
|
@@ -37,14 +37,18 @@ class TeslaFleetOAuth(TeslaFleetApi):
|
|
37
37
|
session,
|
38
38
|
access_token="",
|
39
39
|
region=region,
|
40
|
-
server=server,
|
41
40
|
)
|
42
41
|
|
43
42
|
def get_login_url(self, scopes: list[Scope], state: str = "login") -> str:
|
44
43
|
"""Get the login URL."""
|
45
44
|
if self.redirect_uri is None:
|
46
45
|
raise ValueError("Redirect URI is missing")
|
47
|
-
|
46
|
+
if self.region == "cn":
|
47
|
+
domain = "auth.tesla.cn"
|
48
|
+
else:
|
49
|
+
domain = "auth.tesla.com"
|
50
|
+
|
51
|
+
return f"https://{domain}/oauth2/v3/authorize?response_type=code&client_id={self.client_id}&redirect_uri={self.redirect_uri}&scope={'+'.join(scopes)}&state={state}"
|
48
52
|
|
49
53
|
async def get_refresh_token(self, code: str) -> None:
|
50
54
|
"""Get the refresh token."""
|
@@ -56,7 +60,6 @@ class TeslaFleetOAuth(TeslaFleetApi):
|
|
56
60
|
raise ValueError("Redirect URI is missing")
|
57
61
|
|
58
62
|
if self.server is None:
|
59
|
-
self.region = code.split("_")[0].lower()
|
60
63
|
self.server = SERVERS.get(self.region)
|
61
64
|
|
62
65
|
async with self.session.post(
|
@@ -8,18 +8,20 @@ from tesla_fleet_api.tesla import TeslaFleetApi
|
|
8
8
|
|
9
9
|
class Teslemetry(TeslaFleetApi):
|
10
10
|
|
11
|
-
|
11
|
+
|
12
12
|
Vehicles = TeslemetryVehicles
|
13
13
|
|
14
14
|
def __init__(
|
15
15
|
self,
|
16
16
|
session: aiohttp.ClientSession,
|
17
17
|
access_token: str,
|
18
|
+
server: str = "https://api.teslemetry.com"
|
18
19
|
):
|
19
20
|
"""Initialize the Teslemetry API."""
|
20
21
|
|
21
22
|
self.session = session
|
22
23
|
self.access_token = access_token
|
24
|
+
self.server = server
|
23
25
|
|
24
26
|
self.charging = self.Charging(self)
|
25
27
|
self.energySites = self.EnergySites(self)
|
@@ -56,7 +58,7 @@ class Teslemetry(TeslaFleetApi):
|
|
56
58
|
)
|
57
59
|
if update_region and "region" in resp:
|
58
60
|
self.region = resp["region"].lower()
|
59
|
-
|
61
|
+
self.server = f"https://{self.region}.teslemetry.com"
|
60
62
|
LOGGER.debug("Using server %s", self.server)
|
61
63
|
return resp
|
62
64
|
|
@@ -1,12 +1,12 @@
|
|
1
|
-
tesla_fleet_api/__init__.py,sha256=
|
1
|
+
tesla_fleet_api/__init__.py,sha256=siyAEludaE4uQJm8V0svOQIDtGkWsTJHnMauvHd6Szc,474
|
2
2
|
tesla_fleet_api/const.py,sha256=CMux_Tju1Qu8Zz3xIenazMU3Vbse94ChYyz5QfrUzHI,4180
|
3
3
|
tesla_fleet_api/exceptions.py,sha256=39O76jiybiAQSjfVnp4KMJz7z9TP1WYBZ1zovN_Aock,36435
|
4
4
|
tesla_fleet_api/tesla/__init__.py,sha256=ahqqQigZbXfysOpo28qUudUfWrQfKRpD_1az368Sjr0,823
|
5
5
|
tesla_fleet_api/tesla/bluetooth.py,sha256=lyPRVf1YdcElrYBsKOMCaLwMPE9rO7Iw1a6nE7VUZ94,2369
|
6
6
|
tesla_fleet_api/tesla/charging.py,sha256=D7I7cAf-3-95sIjyP6wpVqCq9Cppj6U-VPFQGpQQ8bs,1704
|
7
7
|
tesla_fleet_api/tesla/energysite.py,sha256=vStffklBQfQNAO_1wrHLFu7BlBCTVVbLh7_IrAUL3wg,6131
|
8
|
-
tesla_fleet_api/tesla/fleet.py,sha256=
|
9
|
-
tesla_fleet_api/tesla/oauth.py,sha256=
|
8
|
+
tesla_fleet_api/tesla/fleet.py,sha256=T3ofpxmctY7Kv_2gTnQGnTQAl2934eXY7bOX1WGDfYQ,7027
|
9
|
+
tesla_fleet_api/tesla/oauth.py,sha256=NhbwjhEW3uhKuYM5EXOlwtsBDtCitSsqgxDr50WugzY,4183
|
10
10
|
tesla_fleet_api/tesla/partner.py,sha256=e-l6sEP6-IupjFEQieSUjhhvRXF3aL4ebPNahcGFRCE,1238
|
11
11
|
tesla_fleet_api/tesla/tesla.py,sha256=JVDHDh-D_8JAp74ji2p2d1EfrWEO9hCo6kjjh6qa2EY,3189
|
12
12
|
tesla_fleet_api/tesla/user.py,sha256=w8rwiAOIFjuDus8M0RpZ0wucJtw8kYFKtJfYVk7Ekr0,1194
|
@@ -38,13 +38,13 @@ tesla_fleet_api/tesla/vehicle/proto/vcsec_pb2.pyi,sha256=tXsoZtCtKjxu7WayydmFBip
|
|
38
38
|
tesla_fleet_api/tesla/vehicle/proto/vehicle_pb2.py,sha256=psmlpmURBaVO45hMbtmfVvIAhEdWEnrkVYk2H5kOZoI,44888
|
39
39
|
tesla_fleet_api/tesla/vehicle/proto/vehicle_pb2.pyi,sha256=HKiB-RdmRH80PGq8EII3KKPEknMhmKOF9xQqD5sf5aE,74636
|
40
40
|
tesla_fleet_api/teslemetry/__init__.py,sha256=BFi16_y-1wRF8XhtgHsYM22eT8T1hTAGJ10S3Q9rWHI,464
|
41
|
-
tesla_fleet_api/teslemetry/teslemetry.py,sha256=
|
41
|
+
tesla_fleet_api/teslemetry/teslemetry.py,sha256=atRW5RL-EDBU8UYkVuKHGZwfrRe7IXfYAoUhwTd99-c,3018
|
42
42
|
tesla_fleet_api/teslemetry/vehicles.py,sha256=73xWsLP0iGml1DAw13mKnpG1Spb-NwkE4aD1rZ-2_N4,10410
|
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.2.
|
47
|
-
tesla_fleet_api-1.2.
|
48
|
-
tesla_fleet_api-1.2.
|
49
|
-
tesla_fleet_api-1.2.
|
50
|
-
tesla_fleet_api-1.2.
|
46
|
+
tesla_fleet_api-1.2.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
47
|
+
tesla_fleet_api-1.2.4.dist-info/METADATA,sha256=o_O1SdarmbMyUUVM2JD89IiuB-RFJwfEVBufSrDDEjU,6720
|
48
|
+
tesla_fleet_api-1.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
49
|
+
tesla_fleet_api-1.2.4.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
|
50
|
+
tesla_fleet_api-1.2.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|