diff --git a/config.schema.json b/config.schema.json index d8999de..de615bc 100644 --- a/config.schema.json +++ b/config.schema.json @@ -1,8 +1,8 @@ { - "pluginAlias": "Teslemetry", + "pluginAlias": "Tessie", "pluginType": "platform", "singular": false, - "headerDisplay": "Requires an active subscription to Teslemetry. Please login and create an access token at teslemetry.com", + "headerDisplay": "Requires an active subscription to Tessie. Please login and create an access token at https://my.tessie.com/settings/api", "schema": { "type": "object", "properties": { @@ -10,7 +10,7 @@ "title": "Name", "type": "string", "required": true, - "default": "Teslemetry" + "default": "Tessie" }, "accessToken": { "title": "Access Token", diff --git a/package.json b/package.json index 3a074e6..b3543ac 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "private": "true", - "displayName": "Development Branch", - "name": "homebridge-teslemetry", - "description": "Connect Homebridge to your Teslemetry account.", + "private": false, + "displayName": "Tessie", + "name": "homebridge-tessie", + "description": "Connect Homebridge to your Tessie account.", "repository": { "type": "git", "url": "git+https://github.com/teslemetry/homebridge.git" diff --git a/src/platform.ts b/src/platform.ts index 3517a59..86d4571 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -12,7 +12,7 @@ import { import { PLATFORM_NAME, PLUGIN_NAME } from "./settings.js"; import { VehicleAccessory, VehicleContext } from "./vehicle.js"; -import { Teslemetry } from "tesla-fleet-api"; +import { Tessie } from "tesla-fleet-api"; /** * HomebridgePlatform @@ -22,7 +22,7 @@ import { Teslemetry } from "tesla-fleet-api"; export class TeslaFleetApiPlatform implements DynamicPlatformPlugin { public readonly Service: typeof Service; public readonly Characteristic: typeof Characteristic; - public readonly TeslaFleetApi: Teslemetry; + public readonly TeslaFleetApi: Tessie; // this is used to track restored cached accessories public readonly accessories: PlatformAccessory[] = []; @@ -35,7 +35,7 @@ export class TeslaFleetApiPlatform implements DynamicPlatformPlugin { this.Service = api.hap.Service; this.Characteristic = api.hap.Characteristic; - this.TeslaFleetApi = new Teslemetry(this.config.accessToken); + this.TeslaFleetApi = new Tessie(this.config.accessToken); this.log.debug("Finished initializing platform:", this.config.accessToken); diff --git a/src/settings.ts b/src/settings.ts index 27a02b7..efcb27e 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,11 +1,11 @@ /** * This is the name of the platform that users will use to register the plugin in the Homebridge config.json */ -export const PLATFORM_NAME = "Teslemetry"; +export const PLATFORM_NAME = "Tessie"; /** * This must match the name of your plugin as defined the package.json */ -export const PLUGIN_NAME = "homebridge-teslemetry"; +export const PLUGIN_NAME = "homebridge-tessie"; export const REFRESH_INTERVAL = 30000; diff --git a/src/vehicle.ts b/src/vehicle.ts index 4c4c91c..108206d 100644 --- a/src/vehicle.ts +++ b/src/vehicle.ts @@ -78,14 +78,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((data) => { this.accessory.context.state = "online"; this.accessory.context.charge_state = data.charge_state; @@ -110,18 +103,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"); + }); } }