Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 155 additions & 0 deletions tesla_fleet_api/tessie/tessie.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,158 @@ async def all_battery_health(
"only_active": only_active,
},
)

async def states(
self,
vin: str,
start: int | None = None,
end: int | None = None,
results: int | None = None,
page: int | None = None,
exclude: str | None = None,
fields: str | None = None,
) -> Any:
"""Get historical vehicle states within timeframe."""
return await self._request(
Method.GET,
f"{vin}/states",
params={
"from": start,
"to": end,
"results": results,
"page": page,
"exclude": exclude,
"fields": fields,
},
)

async def location(self, vin: str) -> Any:
"""Get coordinates, address, and saved location."""
return await self._request(Method.GET, f"{vin}/location")

async def firmware_alerts(self, vin: str) -> Any:
"""Get list of firmware-generated alerts."""
return await self._request(Method.GET, f"{vin}/firmware_alerts")

async def map(
self,
vin: str,
width: int | None = None,
height: int | None = None,
zoom: int | None = None,
) -> Any:
"""Get map image of vehicle location."""
return await self._request(
Method.GET,
f"{vin}/map",
params={"width": width, "height": height, "zoom": zoom},
)

async def consumption_since_charge(self, vin: str) -> Any:
"""Get energy use data since last charge."""
return await self._request(Method.GET, f"{vin}/consumption_since_charge")

async def weather(self, vin: str) -> Any:
"""Get weather forecast around vehicle."""
return await self._request(Method.GET, f"{vin}/weather")

async def drives(
self,
vin: str,
start: int | None = None,
end: int | None = None,
results: int | None = None,
page: int | None = None,
timezone: str | None = None,
distance_format: str | None = None,
) -> Any:
"""Get historical drive records."""
return await self._request(
Method.GET,
f"{vin}/drives",
params={
"from": start,
"to": end,
"results": results,
"page": page,
"timezone": timezone,
"distance_format": distance_format,
},
)

async def path(
self,
vin: str,
start: int,
end: int,
timezone: str | None = None,
) -> Any:
"""Get driving route during specified timeframe."""
return await self._request(
Method.GET,
f"{vin}/path",
params={"from": start, "to": end, "timezone": timezone},
)

async def charges(
self,
vin: str,
start: int | None = None,
end: int | None = None,
results: int | None = None,
page: int | None = None,
timezone: str | None = None,
distance_format: str | None = None,
) -> Any:
"""Get charging history."""
return await self._request(
Method.GET,
f"{vin}/charges",
params={
"from": start,
"to": end,
"results": results,
"page": page,
"timezone": timezone,
"distance_format": distance_format,
},
)

async def charging_invoices(
self,
start: int | None = None,
end: int | None = None,
only_active: bool = False,
) -> Any:
"""Get charging costs for all vehicles (fleet)."""
return await self._request(
Method.GET,
"charging_invoices",
params={"from": start, "to": end, "only_active": only_active},
)

async def idles(
self,
vin: str,
start: int | None = None,
end: int | None = None,
results: int | None = None,
page: int | None = None,
timezone: str | None = None,
) -> Any:
"""Get idle periods when vehicle inactive."""
return await self._request(
Method.GET,
f"{vin}/idles",
params={
"from": start,
"to": end,
"results": results,
"page": page,
"timezone": timezone,
},
)

async def last_idle_state(self, vin: str) -> Any:
"""Get latest idle period data."""
return await self._request(Method.GET, f"{vin}/last_idle_state")
Loading