tesla-fleet-api 0.0.3__py3-none-any.whl → 0.0.5__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 +3 -4
- tesla_fleet_api/charging.py +57 -0
- tesla_fleet_api/const.py +235 -1
- tesla_fleet_api/energy.py +130 -0
- tesla_fleet_api/exceptions.py +21 -21
- tesla_fleet_api/partner.py +21 -0
- tesla_fleet_api/teslafleetapi.py +116 -0
- tesla_fleet_api/{TeslaFleetOAuth.py → teslafleetoauth.py} +1 -1
- tesla_fleet_api/teslemetry.py +47 -0
- tesla_fleet_api/user.py +29 -0
- tesla_fleet_api/vehicle.py +833 -0
- tesla_fleet_api/vehiclespecific.py +415 -0
- {tesla_fleet_api-0.0.3.dist-info → tesla_fleet_api-0.0.5.dist-info}/METADATA +1 -1
- tesla_fleet_api-0.0.5.dist-info/RECORD +17 -0
- tesla_fleet_api/TeslaFleetApi.py +0 -1065
- tesla_fleet_api/Teslemetry.py +0 -27
- tesla_fleet_api-0.0.3.dist-info/RECORD +0 -11
- {tesla_fleet_api-0.0.3.dist-info → tesla_fleet_api-0.0.5.dist-info}/LICENSE +0 -0
- {tesla_fleet_api-0.0.3.dist-info → tesla_fleet_api-0.0.5.dist-info}/WHEEL +0 -0
- {tesla_fleet_api-0.0.3.dist-info → tesla_fleet_api-0.0.5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
import aiohttp
|
2
|
+
from .teslafleetapi import TeslaFleetApi
|
3
|
+
from .vehicle import Vehicle
|
4
|
+
from .vehiclespecific import VehicleSpecific
|
5
|
+
from .const import Methods
|
6
|
+
|
7
|
+
|
8
|
+
class TeslemetryVehicle(Vehicle):
|
9
|
+
"""Tesla Fleet API Vehicle."""
|
10
|
+
|
11
|
+
async def create(self, only_subscribed=True) -> [VehicleSpecific]:
|
12
|
+
"""Creates a class for each vehicle."""
|
13
|
+
if only_subscribed:
|
14
|
+
return [VehicleSpecific(self, vin) for vin in await self._parent.vehicles()]
|
15
|
+
return await super().create()
|
16
|
+
|
17
|
+
|
18
|
+
class Teslemetry(TeslaFleetApi):
|
19
|
+
def __init__(
|
20
|
+
self,
|
21
|
+
session: aiohttp.ClientSession,
|
22
|
+
access_token: str,
|
23
|
+
raise_for_status: bool = True,
|
24
|
+
):
|
25
|
+
"""Initialize the Teslemetry API."""
|
26
|
+
super().__init__(
|
27
|
+
session,
|
28
|
+
access_token,
|
29
|
+
use_command_protocol=False,
|
30
|
+
server="https://teslemetry.com",
|
31
|
+
raise_for_status=raise_for_status,
|
32
|
+
partner_scope=False,
|
33
|
+
user_scope=False,
|
34
|
+
vehicle_scope=False,
|
35
|
+
)
|
36
|
+
self.vehicle = TeslemetryVehicle(self)
|
37
|
+
|
38
|
+
async def vehicles(self):
|
39
|
+
"""Get the subscribed vehicles."""
|
40
|
+
return await self._request(
|
41
|
+
Methods.GET,
|
42
|
+
"/meta/vehicles",
|
43
|
+
)
|
44
|
+
|
45
|
+
async def find_server(self):
|
46
|
+
"""Find the server URL for the Tesla Fleet API."""
|
47
|
+
raise NotImplementedError("Do not use this function for Teslemetry.")
|
tesla_fleet_api/user.py
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from .const import Methods
|
3
|
+
|
4
|
+
|
5
|
+
class User:
|
6
|
+
"""Class describing the Tesla Fleet API user endpoints"""
|
7
|
+
|
8
|
+
def __init__(self, parent):
|
9
|
+
self._request = parent._request
|
10
|
+
|
11
|
+
async def backup_key(self) -> dict[str, Any]:
|
12
|
+
"""Returns the public key associated with the user."""
|
13
|
+
return await self._request(Methods.GET, "api/1/users/backup_key")
|
14
|
+
|
15
|
+
async def feature_config(self) -> dict[str, Any]:
|
16
|
+
"""Returns any custom feature flag applied to a user."""
|
17
|
+
return await self._request(Methods.GET, "api/1/users/feature_config")
|
18
|
+
|
19
|
+
async def me(self) -> dict[str, Any]:
|
20
|
+
"""Returns a summary of a user's account."""
|
21
|
+
return await self._request(Methods.GET, "api/1/users/me")
|
22
|
+
|
23
|
+
async def orders(self) -> dict[str, Any]:
|
24
|
+
"""Returns the active orders for a user."""
|
25
|
+
return await self._request(Methods.GET, "api/1/users/orders")
|
26
|
+
|
27
|
+
async def region(self) -> dict[str, Any]:
|
28
|
+
"""Returns a user's region and appropriate fleet-api base URL. Accepts no parameters, response is based on the authentication token subject."""
|
29
|
+
return await self._request(Methods.GET, "api/1/users/region")
|