Skip to content

Commit

Permalink
Change to products endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeBishop committed Feb 25, 2024
1 parent 2d59f3a commit dac28d4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/TWCManager/Vehicle/TeslaAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ def car_api_available(

if self.getCarApiBearerToken() != "":
if self.getVehicleCount() < 1:
url = "https://owner-api.teslamotors.com/api/1/vehicles"
url = "https://owner-api.teslamotors.com/api/1/products"
headers = {
"accept": "application/json",
"Authorization": "Bearer " + self.getCarApiBearerToken(),
}
try:
req = requests.get(url, headers=headers)
logger.log(logging.INFO8, "Car API cmd vehicles " + str(req))
logger.log(logging.INFO8, "Car API cmd products " + str(req))
apiResponseDict = json.loads(req.text)
except requests.exceptions.RequestException:
logger.info("Failed to make API call " + url)
Expand All @@ -241,7 +241,9 @@ def car_api_available(
logger.debug("Car API vehicle list" + str(apiResponseDict) + "\n")

for i in range(0, apiResponseDict["count"]):
self.addVehicle(apiResponseDict["response"][i])
product = apiResponseDict["response"][i]
if "vehicle_id" in product:
self.addVehicle(product)
self.resetCarApiLastErrorTime()
except (KeyError, TypeError):
# This catches cases like trying to access
Expand Down

0 comments on commit dac28d4

Please sign in to comment.