Skip to content

Commit

Permalink
Finish Teslemetry implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Jan 6, 2024
1 parent 6678bea commit 20bc582
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions tesla_fleet_api/TeslaFleetApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class Vehicle:
"""Class describing the Tesla Fleet API vehicle endpoints and commands."""

def __init__(self, parent):
self._parent = parent
self._request = parent._request
self.use_command_protocol = parent.use_command_protocol

Expand Down
21 changes: 12 additions & 9 deletions tesla_fleet_api/Teslemetry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import aiohttp
from .TeslaFleetApi import TeslaFleetApi
from .const import Methods


class Teslemetry(TeslaFleetApi):
Expand All @@ -18,12 +19,11 @@ def __init__(
raise_for_status=raise_for_status,
)

async def subscriptions(self):
"""Get the subscriptions."""
raise NotImplementedError("Not implemented yet")
return await self.get(
"/meta/subscriptions",
{"headers": {"Authorization": f"Bearer {self.access_token}"}},
async def vehicles(self):
"""Get the subscribed vehicles."""
return await self._request(
Methods.GET,
"/meta/vehicles",
)

async def find_server(self):
Expand All @@ -38,8 +38,11 @@ class Vehicle(TeslaFleetApi.Vehicle):
"""Tesla Fleet API Vehicle."""

async def create(
self, only_subscribed=False
self, only_subscribed=True
) -> [TeslaFleetApi.Vehicle.Specific]:
"""Creates a class for each vehicle."""
list = await self.list()
return [self.Specific(self, x["vin"]) for x in list["response"]]
if only_subscribed:
return [
self.Specific(self, vin) for vin in await self._parent.vehicles()
]
return await super().create()

0 comments on commit 20bc582

Please sign in to comment.