Skip to content

Commit 24a28de

Browse files
committed
Change to products endpoint
1 parent 2d59f3a commit 24a28de

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/TWCManager/Vehicle/TeslaAPI.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,14 @@ def car_api_available(
219219

220220
if self.getCarApiBearerToken() != "":
221221
if self.getVehicleCount() < 1:
222-
url = "https://owner-api.teslamotors.com/api/1/vehicles"
222+
url = "https://owner-api.teslamotors.com/api/1/products"
223223
headers = {
224224
"accept": "application/json",
225225
"Authorization": "Bearer " + self.getCarApiBearerToken(),
226226
}
227227
try:
228228
req = requests.get(url, headers=headers)
229-
logger.log(logging.INFO8, "Car API cmd vehicles " + str(req))
229+
logger.log(logging.INFO8, "Car API cmd products " + str(req))
230230
apiResponseDict = json.loads(req.text)
231231
except requests.exceptions.RequestException:
232232
logger.info("Failed to make API call " + url)
@@ -241,7 +241,9 @@ def car_api_available(
241241
logger.debug("Car API vehicle list" + str(apiResponseDict) + "\n")
242242

243243
for i in range(0, apiResponseDict["count"]):
244-
self.addVehicle(apiResponseDict["response"][i])
244+
product = apiResponseDict["response"][i]
245+
if product.vehicle_id:
246+
self.addVehicle(product)
245247
self.resetCarApiLastErrorTime()
246248
except (KeyError, TypeError):
247249
# This catches cases like trying to access

0 commit comments

Comments
 (0)