From 5058a6fa07f3fae2f1552c7150b28481446967c5 Mon Sep 17 00:00:00 2001 From: Jesse Sightler Date: Thu, 19 Oct 2023 22:08:18 -0400 Subject: [PATCH] Added a separate retrieval of location data --- lib/tesla_api/vehicle.ex | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/tesla_api/vehicle.ex b/lib/tesla_api/vehicle.ex index 8132032bf1..81bea834d9 100644 --- a/lib/tesla_api/vehicle.ex +++ b/lib/tesla_api/vehicle.ex @@ -51,10 +51,21 @@ defmodule TeslaApi.Vehicle do _global -> "https://owner-api.teslamotors.com" end - TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data", + vehicle_location_data = TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data?endpoints=location_data", opts: [access_token: auth.token] ) |> handle_response(transform: &result/1) + + vehicle_data = TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data", + opts: [access_token: auth.token] + ) + |> handle_response(transform: &result/1) + + { + elem(vehicle_data, 0), + %TeslaApi.Vehicle{elem(vehicle_data, 1) | drive_state: elem(vehicle_location_data, 1).drive_state} + } + end def result(v) do