tesla-fleet-api 0.5.1__py3-none-any.whl → 0.5.2__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/const.py +8 -9
- tesla_fleet_api/teslafleetapi.py +3 -1
- tesla_fleet_api/teslemetry.py +20 -12
- {tesla_fleet_api-0.5.1.dist-info → tesla_fleet_api-0.5.2.dist-info}/METADATA +3 -3
- {tesla_fleet_api-0.5.1.dist-info → tesla_fleet_api-0.5.2.dist-info}/RECORD +8 -8
- {tesla_fleet_api-0.5.1.dist-info → tesla_fleet_api-0.5.2.dist-info}/LICENSE +0 -0
- {tesla_fleet_api-0.5.1.dist-info → tesla_fleet_api-0.5.2.dist-info}/WHEEL +0 -0
- {tesla_fleet_api-0.5.1.dist-info → tesla_fleet_api-0.5.2.dist-info}/top_level.txt +0 -0
tesla_fleet_api/const.py
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
from enum import Enum
|
4
4
|
import logging
|
5
5
|
|
6
|
+
VERSION = "0.5.2"
|
7
|
+
LOGGER = logging.getLogger(__package__)
|
8
|
+
SERVERS = {
|
9
|
+
"na": "https://fleet-api.prd.na.vn.cloud.tesla.com",
|
10
|
+
"eu": "https://fleet-api.prd.eu.vn.cloud.tesla.com",
|
11
|
+
"cn": "https://fleet-api.prd.cn.vn.cloud.tesla.cn",
|
12
|
+
}
|
13
|
+
|
6
14
|
|
7
15
|
class IntEnum(int, Enum):
|
8
16
|
"""Integer Enum."""
|
@@ -20,15 +28,6 @@ class Method(StrEnum):
|
|
20
28
|
DELETE = "DELETE"
|
21
29
|
|
22
30
|
|
23
|
-
LOGGER = logging.getLogger(__package__)
|
24
|
-
|
25
|
-
SERVERS = {
|
26
|
-
"na": "https://fleet-api.prd.na.vn.cloud.tesla.com",
|
27
|
-
"eu": "https://fleet-api.prd.eu.vn.cloud.tesla.com",
|
28
|
-
"cn": "https://fleet-api.prd.cn.vn.cloud.tesla.cn",
|
29
|
-
}
|
30
|
-
|
31
|
-
|
32
31
|
class Trunk(StrEnum):
|
33
32
|
"""Trunk options"""
|
34
33
|
|
tesla_fleet_api/teslafleetapi.py
CHANGED
@@ -3,7 +3,7 @@ import aiohttp
|
|
3
3
|
from json import dumps
|
4
4
|
from .exceptions import raise_for_status, InvalidRegion, LibraryError, InvalidToken
|
5
5
|
from typing import Any
|
6
|
-
from .const import SERVERS, Method, LOGGER
|
6
|
+
from .const import SERVERS, Method, LOGGER, VERSION
|
7
7
|
from .charging import Charging
|
8
8
|
from .energy import Energy
|
9
9
|
from .partner import Partner
|
@@ -64,6 +64,7 @@ class TeslaFleetApi:
|
|
64
64
|
response = await (self.user.region()).get("response")
|
65
65
|
if response:
|
66
66
|
self.server = response["fleet_api_base_url"]
|
67
|
+
LOGGER.debug("Using server %s", self.server)
|
67
68
|
return response["region"]
|
68
69
|
except InvalidRegion:
|
69
70
|
continue
|
@@ -100,6 +101,7 @@ class TeslaFleetApi:
|
|
100
101
|
headers={
|
101
102
|
"Authorization": f"Bearer {self.access_token}",
|
102
103
|
"Content-Type": "application/json",
|
104
|
+
"X-Library": f"python tesla_fleet_api ${VERSION}",
|
103
105
|
},
|
104
106
|
json=json,
|
105
107
|
params=params,
|
tesla_fleet_api/teslemetry.py
CHANGED
@@ -2,7 +2,7 @@ import aiohttp
|
|
2
2
|
from aiolimiter import AsyncLimiter
|
3
3
|
from typing import Any
|
4
4
|
from .teslafleetapi import TeslaFleetApi
|
5
|
-
from .const import Method
|
5
|
+
from .const import Method, LOGGER
|
6
6
|
|
7
7
|
# Rate limit should be global, even if multiple instances are created
|
8
8
|
rate_limit = AsyncLimiter(5, 10)
|
@@ -28,28 +28,36 @@ class Teslemetry(TeslaFleetApi):
|
|
28
28
|
|
29
29
|
async def ping(self) -> bool:
|
30
30
|
"""Send a ping."""
|
31
|
-
return
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
return (
|
32
|
+
await self._request(
|
33
|
+
Method.GET,
|
34
|
+
"api/ping",
|
35
|
+
)
|
36
|
+
).get("response", False)
|
35
37
|
|
36
38
|
async def test(self) -> bool:
|
37
39
|
"""Test API Authentication."""
|
38
|
-
return
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
return (
|
41
|
+
await self._request(
|
42
|
+
Method.GET,
|
43
|
+
"api/test",
|
44
|
+
)
|
45
|
+
).get("response", False)
|
42
46
|
|
43
|
-
async def metadata(self) ->
|
47
|
+
async def metadata(self, use_region=True) -> dict[str, Any]:
|
44
48
|
"""Test API Authentication."""
|
45
|
-
|
49
|
+
resp = await self._request(
|
46
50
|
Method.GET,
|
47
51
|
"api/metadata",
|
48
52
|
)
|
53
|
+
if use_region and "region" in resp:
|
54
|
+
self.region = resp["region"].lower()
|
55
|
+
self.server = f"https://{self.region}.teslemetry.com"
|
56
|
+
LOGGER.debug("Using server %s", self.server)
|
49
57
|
|
50
58
|
async def find_server(self):
|
51
59
|
"""Find the server URL for the Tesla Fleet API."""
|
52
|
-
|
60
|
+
await self.metadata(True)
|
53
61
|
|
54
62
|
async def _request(
|
55
63
|
self,
|
@@ -1,11 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: tesla_fleet_api
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.2
|
4
4
|
Summary: Tesla Fleet API library for Python
|
5
5
|
Home-page: https://github.com/Teslemetry/tesla_fleet_api
|
6
6
|
Author: Brett Adams
|
7
|
-
Author-email:
|
8
|
-
Classifier: Development Status ::
|
7
|
+
Author-email: admin@teslemetry.com
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
10
10
|
Classifier: License :: OSI Approved :: Apache Software License
|
11
11
|
Classifier: Operating System :: OS Independent
|
@@ -1,19 +1,19 @@
|
|
1
1
|
tesla_fleet_api/__init__.py,sha256=RL9KGtDjYwbBa5i6Lagzrya-yjvEE1EVfyge2lV49iI,375
|
2
2
|
tesla_fleet_api/charging.py,sha256=N_mc8axrXj3iduqLj_jCt4Vx86tHqe3xqQT4R1R7HvU,1689
|
3
|
-
tesla_fleet_api/const.py,sha256=
|
3
|
+
tesla_fleet_api/const.py,sha256=mTPNQyplwZu98DQD3qPU-tlCpNM4_BdkHrmwm7-bSTs,9277
|
4
4
|
tesla_fleet_api/energy.py,sha256=Fgg4pdYc226WNOXHUnzBHbZoZ3jYLfN3GgjprazYLZA,5283
|
5
5
|
tesla_fleet_api/energyspecific.py,sha256=kICxdeDoWR9JHlgjHvnmjJ1ErLOWJT8bCSESoXo9axU,3732
|
6
6
|
tesla_fleet_api/exceptions.py,sha256=c6i_AegrLzlfrHxht_Z_xLl_kmxcd3DDJaSIcldcUo8,9171
|
7
7
|
tesla_fleet_api/partner.py,sha256=1vIBUaxKLIfqcC0X6VXZN0dMAzj_CLNPUMjA6QVqZ1k,1223
|
8
|
-
tesla_fleet_api/teslafleetapi.py,sha256=
|
8
|
+
tesla_fleet_api/teslafleetapi.py,sha256=ErPfOz4M4WERrOlo_a_1ssVPcOIGeiBpbxd4vFJH_x4,4929
|
9
9
|
tesla_fleet_api/teslafleetoauth.py,sha256=BmRAuwcgFMBo2_3AJzS3QTBm_cP9xt4yoz4vKjwgmsw,3501
|
10
|
-
tesla_fleet_api/teslemetry.py,sha256=
|
10
|
+
tesla_fleet_api/teslemetry.py,sha256=QSKcB4P1RW-b9MDmpa0KF5dAMxVI2bPoOUJPKWzEniU,2075
|
11
11
|
tesla_fleet_api/tessie.py,sha256=3ScOi8RaxHdvp6s5ZdSWYXwHZdey6IkX9SF1oohtSWk,2252
|
12
12
|
tesla_fleet_api/user.py,sha256=TZE2oh-n5zrhKXmGRuiNL9voKVODD7rBhGE_IObYVGA,1179
|
13
13
|
tesla_fleet_api/vehicle.py,sha256=ZFXxXXRsW26gvCEX3JexGZyUnRz7vZh-chYaSCZgXZQ,31983
|
14
14
|
tesla_fleet_api/vehiclespecific.py,sha256=C9gCPGZphzcnDPwyX5HR1ZCEC4IWqdv5ATccHqvFryQ,20817
|
15
|
-
tesla_fleet_api-0.5.
|
16
|
-
tesla_fleet_api-0.5.
|
17
|
-
tesla_fleet_api-0.5.
|
18
|
-
tesla_fleet_api-0.5.
|
19
|
-
tesla_fleet_api-0.5.
|
15
|
+
tesla_fleet_api-0.5.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
16
|
+
tesla_fleet_api-0.5.2.dist-info/METADATA,sha256=e-FDrEevbaLXj_FgV_axEH-SpgU1bzASeOi0KdmNBJk,3961
|
17
|
+
tesla_fleet_api-0.5.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
18
|
+
tesla_fleet_api-0.5.2.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
|
19
|
+
tesla_fleet_api-0.5.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|