Skip to content

Commit 994a664

Browse files
committed
Add Tessie support
1 parent 187e058 commit 994a664

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,31 @@ async def main():
102102
103103
asyncio.run(main())
104104
```
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+
```

tesla_fleet_api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .teslafleetapi import TeslaFleetApi
22
from .teslafleetoauth import TeslaFleetOAuth
33
from .teslemetry import Teslemetry
4+
from .tessie import Tessie
45
from .charging import Charging
56
from .energy import Energy
67
from .energyspecific import EnergySpecific

tesla_fleet_api/tessie.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import aiohttp
2+
from typing import Any
3+
from .teslafleetapi import TeslaFleetApi
4+
from .const import Method
5+
6+
7+
class Tessie(TeslaFleetApi):
8+
def __init__(
9+
self,
10+
session: aiohttp.ClientSession,
11+
access_token: str,
12+
raise_for_status: bool = True,
13+
):
14+
"""Initialize the Tessie API."""
15+
super().__init__(
16+
session,
17+
access_token,
18+
server="https://api.tessie.com",
19+
raise_for_status=raise_for_status,
20+
partner_scope=False,
21+
user_scope=False,
22+
energy_scope=False,
23+
)
24+
25+
async def find_server(self):
26+
"""Find the server URL for the Tesla Fleet API."""
27+
raise NotImplementedError("Do not use this function for Teslemetry.")

0 commit comments

Comments
 (0)