Skip to content

Commit 0168264

Browse files
committed
Fix navigation_request
1 parent 67890a8 commit 0168264

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

tesla_fleet_api/teslafleetapi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ async def _request(
137137
LOGGER.debug("Retry after: %s", resp.headers.get("Retry-After"))
138138

139139
if not resp.ok:
140+
print(await resp.text())
140141
await raise_for_status(resp)
141142

142143
if not resp.content_type.lower().startswith("application/json"):

tesla_fleet_api/vehicle.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from __future__ import annotations
2+
from time import time
3+
from locale import getlocale
24
from typing import Any, List, TYPE_CHECKING
35
from cryptography.hazmat.primitives.asymmetric import ec
46
from .const import (
@@ -19,6 +21,7 @@
1921
if TYPE_CHECKING:
2022
from .teslafleetapi import TeslaFleetApi
2123

24+
DEFAULT_LOCALE = (getlocale()[0] or "en-US").replace("_","-")
2225

2326
class Vehicle:
2427
"""Class describing the Tesla Fleet API vehicle endpoints and commands."""
@@ -217,13 +220,15 @@ async def navigation_gps_request(
217220
)
218221

219222
async def navigation_request(
220-
self, vehicle_tag: str | int, type: str, locale: str, timestamp_ms: str
223+
self, vehicle_tag: str | int, value: str, type: str = "share_ext_content_raw", locale: str | None = None, timestamp_ms: int | None = None
221224
) -> dict[str, Any]:
222225
"""Sends a location to the in-vehicle navigation system."""
226+
timestamp_ms = timestamp_ms or int(time() * 1000)
227+
locale = locale or DEFAULT_LOCALE
223228
return await self._request(
224229
Method.POST,
225230
f"api/1/vehicles/{vehicle_tag}/command/navigation_request",
226-
json={"type": type, "locale": locale, "timestamp_ms": timestamp_ms},
231+
json={"value": {"android.intent.extra.TEXT":value}, "type": type, "locale": locale, "timestamp_ms": timestamp_ms},
227232
)
228233

229234
async def navigation_sc_request(

tesla_fleet_api/vehiclespecific.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
VehicleDataEndpoint,
88
SunRoofCommand,
99
WindowCommand,
10-
DeviceType,
1110
)
1211

1312
if TYPE_CHECKING:
1413
from .vehicle import Vehicle
1514

16-
1715
class VehicleSpecific:
1816
"""Class describing the Tesla Fleet API vehicle endpoints and commands for a specific vehicle."""
1917

@@ -132,11 +130,11 @@ async def navigation_gps_request(
132130
return await self._parent.navigation_gps_request(self.vin, lat, lon, order)
133131

134132
async def navigation_request(
135-
self, type: str, locale: str, timestamp_ms: str
133+
self, value: str, type: str = "share_ext_content_raw", locale: str | None = None, timestamp_ms: int | None = None
136134
) -> dict[str, Any]:
137135
"""Sends a location to the in-vehicle navigation system."""
138136
return await self._parent.navigation_request(
139-
self.vin, type, locale, timestamp_ms
137+
self.vin, value, type, locale, timestamp_ms
140138
)
141139

142140
async def navigation_sc_request(

0 commit comments

Comments
 (0)