tesla-fleet-api 0.4.9__tar.gz → 0.5.1__tar.gz

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.
Files changed (24) hide show
  1. {tesla_fleet_api-0.4.9/tesla_fleet_api.egg-info → tesla_fleet_api-0.5.1}/PKG-INFO +29 -1
  2. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/README.md +28 -0
  3. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/setup.py +1 -1
  4. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/__init__.py +1 -0
  5. tesla_fleet_api-0.5.1/tesla_fleet_api/tessie.py +75 -0
  6. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/vehicle.py +2 -2
  7. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/vehiclespecific.py +5 -3
  8. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1/tesla_fleet_api.egg-info}/PKG-INFO +29 -1
  9. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api.egg-info/SOURCES.txt +1 -0
  10. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/LICENSE +0 -0
  11. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/setup.cfg +0 -0
  12. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/charging.py +0 -0
  13. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/const.py +0 -0
  14. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/energy.py +0 -0
  15. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/energyspecific.py +0 -0
  16. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/exceptions.py +0 -0
  17. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/partner.py +0 -0
  18. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/teslafleetapi.py +0 -0
  19. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/teslafleetoauth.py +0 -0
  20. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/teslemetry.py +0 -0
  21. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api/user.py +0 -0
  22. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api.egg-info/dependency_links.txt +0 -0
  23. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api.egg-info/requires.txt +0 -0
  24. {tesla_fleet_api-0.4.9 → tesla_fleet_api-0.5.1}/tesla_fleet_api.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tesla_fleet_api
3
- Version: 0.4.9
3
+ Version: 0.5.1
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
@@ -119,3 +119,31 @@ async def main():
119
119
 
120
120
  asyncio.run(main())
121
121
  ```
122
+
123
+ ## Tessie
124
+ This extends TeslaFleetApi to send requests through Tessie, which manages all aspects of Tesla OAuth. This class only requires an access_token from [Tessie](https://dash.tessie.com/settings/api).
125
+
126
+ ```
127
+ import asyncio
128
+ import aiohttp
129
+
130
+ from tesla_fleet_api import Tessie
131
+ from tesla_fleet_api.exceptions import TeslaFleetError
132
+
133
+
134
+ async def main():
135
+ async with aiohttp.ClientSession() as session:
136
+ api = Tessie(
137
+ access_token="<access_token>",
138
+ session=session,
139
+ raise_for_status=True,
140
+ )
141
+
142
+ try:
143
+ data = await api.vehicle.list()
144
+ print(data)
145
+ except TeslaFleetError as e:
146
+ print(e)
147
+
148
+ asyncio.run(main())
149
+ ```
@@ -102,3 +102,31 @@ async def main():
102
102
 
103
103
  asyncio.run(main())
104
104
  ```
105
+
106
+ ## Tessie
107
+ This extends TeslaFleetApi to send requests through Tessie, which manages all aspects of Tesla OAuth. This class only requires an access_token from [Tessie](https://dash.tessie.com/settings/api).
108
+
109
+ ```
110
+ import asyncio
111
+ import aiohttp
112
+
113
+ from tesla_fleet_api import Tessie
114
+ from tesla_fleet_api.exceptions import TeslaFleetError
115
+
116
+
117
+ async def main():
118
+ async with aiohttp.ClientSession() as session:
119
+ api = Tessie(
120
+ access_token="<access_token>",
121
+ session=session,
122
+ raise_for_status=True,
123
+ )
124
+
125
+ try:
126
+ data = await api.vehicle.list()
127
+ print(data)
128
+ except TeslaFleetError as e:
129
+ print(e)
130
+
131
+ asyncio.run(main())
132
+ ```
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="tesla_fleet_api",
8
- version="0.4.9",
8
+ version="0.5.1",
9
9
  author="Brett Adams",
10
10
  author_email="hello@teslemetry.com",
11
11
  description="Tesla Fleet API library for Python",
@@ -1,6 +1,7 @@
1
1
  from .teslafleetapi import TeslaFleetApi
2
2
  from .teslafleetoauth import TeslaFleetOAuth
3
3
  from .teslemetry import Teslemetry
4
+ from .tessie import Tessie
4
5
  from .charging import Charging
5
6
  from .energy import Energy
6
7
  from .energyspecific import EnergySpecific
@@ -0,0 +1,75 @@
1
+ import aiohttp
2
+ from typing import Any
3
+ from .teslafleetapi import TeslaFleetApi
4
+ from .const import Method
5
+ from .vehiclespecific import VehicleSpecific
6
+
7
+
8
+ class Tessie(TeslaFleetApi):
9
+ def __init__(
10
+ self,
11
+ session: aiohttp.ClientSession,
12
+ access_token: str,
13
+ raise_for_status: bool = True,
14
+ ):
15
+ """Initialize the Tessie API."""
16
+ super().__init__(
17
+ session,
18
+ access_token,
19
+ server="https://api.tessie.com",
20
+ raise_for_status=raise_for_status,
21
+ partner_scope=False,
22
+ user_scope=False,
23
+ energy_scope=False,
24
+ )
25
+
26
+ async def find_server(self):
27
+ """Find the server URL for the Tesla Fleet API."""
28
+ raise NotImplementedError("Do not use this function for Tessie.")
29
+
30
+ async def vehicles(self, only_active: bool = False) -> Any:
31
+ """Get vehicles."""
32
+ return await self._request(
33
+ Method.GET, "vehicles", params={"only_active": only_active}
34
+ )
35
+
36
+ async def state(self, vin: str) -> Any:
37
+ """Get vehicle data."""
38
+ return await self._request(Method.GET, f"{vin}/state")
39
+
40
+ async def battery(self, vin: str) -> Any:
41
+ """Get battery data."""
42
+ return await self._request(Method.GET, f"{vin}/battery")
43
+
44
+ async def battery_health(
45
+ self,
46
+ vin: str,
47
+ start: int | None = None,
48
+ end: int | None = None,
49
+ distance_format: str | None = None,
50
+ ) -> Any:
51
+ """Get battery health data."""
52
+ return await self._request(
53
+ Method.GET,
54
+ f"{vin}/battery_health",
55
+ params={"from": start, "to": end, "distance_format": distance_format},
56
+ )
57
+
58
+ async def all_battery_health(
59
+ self,
60
+ start: int | None = None,
61
+ end: int | None = None,
62
+ distance_format: str | None = None,
63
+ only_active: bool = False,
64
+ ) -> Any:
65
+ """Get battery health data."""
66
+ return await self._request(
67
+ Method.GET,
68
+ "battery_health",
69
+ params={
70
+ "from": start,
71
+ "to": end,
72
+ "distance_format": distance_format,
73
+ "only_active": only_active,
74
+ },
75
+ )
@@ -189,7 +189,7 @@ class Vehicle:
189
189
  )
190
190
 
191
191
  async def navigation_gps_request(
192
- self, vehicle_tag: str | int, lat: float, lon: float, order: int
192
+ self, vehicle_tag: str | int, lat: float, lon: float, order: int | None = None
193
193
  ) -> dict[str, Any]:
194
194
  """Start navigation to given coordinates. Order can be used to specify order of multiple stops."""
195
195
  return await self._request(
@@ -209,7 +209,7 @@ class Vehicle:
209
209
  )
210
210
 
211
211
  async def navigation_sc_request(
212
- self, vehicle_tag: str | int, id: int, order: int
212
+ self, vehicle_tag: str | int, id: int, order: int | None = None
213
213
  ) -> dict[str, Any]:
214
214
  """Sends a location to the in-vehicle navigation system."""
215
215
  return await self._request(
@@ -114,10 +114,10 @@ class VehicleSpecific:
114
114
  return await self._parent.media_volume_down(self.vin)
115
115
 
116
116
  async def navigation_gps_request(
117
- self, lat: float, lon: float, order: int
117
+ self, lat: float, lon: float, order: int | None = None
118
118
  ) -> dict[str, Any]:
119
119
  """Start navigation to given coordinates. Order can be used to specify order of multiple stops."""
120
- self._parent.navigation_gps_request(self.vin, lat, lon, order)
120
+ return await self._parent.navigation_gps_request(self.vin, lat, lon, order)
121
121
 
122
122
  async def navigation_request(
123
123
  self, type: str, locale: str, timestamp_ms: str
@@ -127,7 +127,9 @@ class VehicleSpecific:
127
127
  self.vin, type, locale, timestamp_ms
128
128
  )
129
129
 
130
- async def navigation_sc_request(self, id: int, order: int) -> dict[str, Any]:
130
+ async def navigation_sc_request(
131
+ self, id: int, order: int | None = None
132
+ ) -> dict[str, Any]:
131
133
  """Sends a location to the in-vehicle navigation system."""
132
134
  return await self._parent.navigation_sc_request(self.vin, id, order)
133
135
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tesla_fleet_api
3
- Version: 0.4.9
3
+ Version: 0.5.1
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
@@ -119,3 +119,31 @@ async def main():
119
119
 
120
120
  asyncio.run(main())
121
121
  ```
122
+
123
+ ## Tessie
124
+ This extends TeslaFleetApi to send requests through Tessie, which manages all aspects of Tesla OAuth. This class only requires an access_token from [Tessie](https://dash.tessie.com/settings/api).
125
+
126
+ ```
127
+ import asyncio
128
+ import aiohttp
129
+
130
+ from tesla_fleet_api import Tessie
131
+ from tesla_fleet_api.exceptions import TeslaFleetError
132
+
133
+
134
+ async def main():
135
+ async with aiohttp.ClientSession() as session:
136
+ api = Tessie(
137
+ access_token="<access_token>",
138
+ session=session,
139
+ raise_for_status=True,
140
+ )
141
+
142
+ try:
143
+ data = await api.vehicle.list()
144
+ print(data)
145
+ except TeslaFleetError as e:
146
+ print(e)
147
+
148
+ asyncio.run(main())
149
+ ```
@@ -11,6 +11,7 @@ tesla_fleet_api/partner.py
11
11
  tesla_fleet_api/teslafleetapi.py
12
12
  tesla_fleet_api/teslafleetoauth.py
13
13
  tesla_fleet_api/teslemetry.py
14
+ tesla_fleet_api/tessie.py
14
15
  tesla_fleet_api/user.py
15
16
  tesla_fleet_api/vehicle.py
16
17
  tesla_fleet_api/vehiclespecific.py
File without changes