From 41d29cc5a4c88779451845308ed50e1c987995de Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 14 Jun 2024 19:41:30 +1000 Subject: [PATCH] Use tessie endpoints --- src/vehicle.ts | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/vehicle.ts b/src/vehicle.ts index 308ba6e..2bd617f 100644 --- a/src/vehicle.ts +++ b/src/vehicle.ts @@ -64,14 +64,7 @@ export class VehicleAccessory { } async refresh(): Promise { - this.vehicle - .vehicle_data([ - "charge_state", - "climate_state", - "drive_state", - "location_data", - "vehicle_state", - ]) + this.platform.TeslaFleetApi.state(this.accessory.context.vin) .then(({ charge_state, climate_state, drive_state, vehicle_state }) => { this.accessory.context.state = "online"; this.accessory.context.charge_state = charge_state; @@ -90,18 +83,12 @@ export class VehicleAccessory { if (this.accessory.context.state === "online") { return Promise.resolve(); } - await this.vehicle.wake_up(); - - let interval = 2000; - for (let x = 0; x < 5; x++) { - await new Promise((resolve) => setTimeout(resolve, interval)); - const { state } = await this.vehicle.vehicle(); - this.accessory.context.state = state; - if (state === "online") { + return this.platform.TeslaFleetApi.wake(this.accessory.context.vin).then(awake => { + if (awake) { + this.accessory.context.state = "online"; return Promise.resolve(); } - interval = interval + 2000; - } - return Promise.reject("Vehicle didn't wake up"); + return Promise.reject("Vehicle did not wake up"); + }); } }