11import aiohttp
22from .TeslaFleetApi import TeslaFleetApi
3+ from .const import Methods
34
45
56class Teslemetry (TeslaFleetApi ):
@@ -18,12 +19,11 @@ def __init__(
1819 raise_for_status = raise_for_status ,
1920 )
2021
21- async def subscriptions (self ):
22- """Get the subscriptions."""
23- raise NotImplementedError ("Not implemented yet" )
24- return await self .get (
25- "/meta/subscriptions" ,
26- {"headers" : {"Authorization" : f"Bearer { self .access_token } " }},
22+ async def vehicles (self ):
23+ """Get the subscribed vehicles."""
24+ return await self ._request (
25+ Methods .GET ,
26+ "/meta/vehicles" ,
2727 )
2828
2929 async def find_server (self ):
@@ -38,8 +38,11 @@ class Vehicle(TeslaFleetApi.Vehicle):
3838 """Tesla Fleet API Vehicle."""
3939
4040 async def create (
41- self , only_subscribed = False
41+ self , only_subscribed = True
4242 ) -> [TeslaFleetApi .Vehicle .Specific ]:
4343 """Creates a class for each vehicle."""
44- list = await self .list ()
45- return [self .Specific (self , x ["vin" ]) for x in list ["response" ]]
44+ if only_subscribed :
45+ return [
46+ self .Specific (self , vin ) for vin in await self ._parent .vehicles ()
47+ ]
48+ return await super ().create ()
0 commit comments