Skip to content

Commit

Permalink
Tessie
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Jun 17, 2024
1 parent 250e199 commit 71544ce
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 31 deletions.
6 changes: 3 additions & 3 deletions config.schema.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"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": {
"name": {
"title": "Name",
"type": "string",
"required": true,
"default": "Teslemetry"
"default": "Tessie"
},
"accessToken": {
"title": "Access Token",
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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.",
"version": "0.1.0",
"license": "Apache-2.0",
"type": "module",
Expand Down
6 changes: 3 additions & 3 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<VehicleContext>[] = [];
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -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;
25 changes: 6 additions & 19 deletions src/vehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,7 @@ export class VehicleAccessory {
}

async refresh(): Promise<void> {
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;
Expand All @@ -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");
});
}
}

0 comments on commit 71544ce

Please sign in to comment.