Skip to content

Commit 09297db

Browse files
committed
Add new Teslemetry endpoints and vehicle_data endpoints
1 parent 7fb5dd1 commit 09297db

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="tesla_fleet_api",
8-
version="0.8.5",
8+
version="0.9.0",
99
author="Brett Adams",
1010
author_email="hello@teslemetry.com",
1111
description="Tesla Fleet API library for Python",

tesla_fleet_api/const.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from enum import Enum
44
import logging
55

6-
VERSION = "0.8.5"
6+
VERSION = "1.0.0"
77
LOGGER = logging.getLogger(__package__)
88
SERVERS = {
99
"na": "https://fleet-api.prd.na.vn.cloud.tesla.com",
@@ -88,11 +88,14 @@ class VehicleDataEndpoint(StrEnum):
8888
DRIVE_STATE = "drive_state"
8989
GUI_SETTINGS = "gui_settings"
9090
LOCATION_DATA = "location_data"
91+
CHARGE_SCHEDULE_DATA = "charge_schedule_data"
92+
PRECONDITIONING_SCHEDULE_DATA = "preconditioning_schedule_data"
9193
VEHICLE_CONFIG = "vehicle_config"
9294
VEHICLE_STATE = "vehicle_state"
9395
VEHICLE_DATA_COMBO = "vehicle_data_combo"
9496

9597

98+
9699
class SunRoofCommand(StrEnum):
97100
"""Sunroof options"""
98101

tesla_fleet_api/teslemetry.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1+
from typing import Any
2+
13
import aiohttp
24
from aiolimiter import AsyncLimiter
3-
from typing import Any
4-
from .teslafleetapi import TeslaFleetApi
5-
from .charging import Charging
6-
from .energy import Energy
7-
from .partner import Partner
8-
from .user import User
9-
from .vehicle import Vehicle
10-
from .vehiclespecific import VehicleSpecific
115

12-
from .const import Method, LOGGER, Scope
6+
from .const import LOGGER, Method, VehicleDataEndpoint
7+
from .teslafleetapi import TeslaFleetApi
138

149
# Rate limit should be global, even if multiple instances are created
1510
rate_limit = AsyncLimiter(5, 10)
@@ -101,6 +96,22 @@ async def server_side_polling(
10196
)
10297
).get("response")
10398

99+
async def vehicle_force_refresh(self, vin: str) -> dict[str, Any]:
100+
"""Force a refresh of the vehicle data."""
101+
return await self._request(
102+
Method.GET,
103+
f"api/force/{vin}",
104+
)
105+
106+
async def vehicle_data_cached(self, vin: str, endpoints: list[VehicleDataEndpoint | str] | None = None,) -> dict[str, Any]:
107+
"""Get cached vehicle data."""
108+
endpoint_payload = ";".join(endpoints) if endpoints else None
109+
return await self._request(
110+
Method.GET,
111+
f"api/x/vehicles/{vin}/vehicle_data",
112+
{"endpoints": endpoint_payload}
113+
)
114+
104115
async def _request(
105116
self,
106117
method: Method,

tesla_fleet_api/vehicle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ async def vehicle(self, vehicle_tag: str | int) -> dict[str, Any]:
737737
async def vehicle_data(
738738
self,
739739
vehicle_tag: str | int,
740-
endpoints: List[VehicleDataEndpoint | str] | None = None,
740+
endpoints: list[VehicleDataEndpoint | str] | None = None,
741741
) -> dict[str, Any]:
742742
"""Makes a live call to the vehicle. This may return cached data if the vehicle is offline. For vehicles running firmware versions 2023.38+, location_data is required to fetch vehicle location. This will result in a location sharing icon to show on the vehicle UI."""
743743
endpoint_payload = ";".join(endpoints) if endpoints else None

0 commit comments

Comments
 (0)