Skip to content

Commit

Permalink
use EV battery if available
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandawg93 committed Jul 24, 2021
1 parent a928a8d commit a68917d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,18 @@ class FordPassPlatform implements DynamicPlatformPlugin {
.getCharacteristic(hap.Characteristic.BatteryLevel)
.on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
// Return cached value immediately then update properly
let level = vehicle?.info?.fuel.fuelLevel || 100;
const fuel = vehicle?.info?.fuel?.fuelLevel;
const battery = vehicle?.info?.batteryFillLevel?.value;
let level = fuel || battery || 100;
if (level > 100) {
level = 100;
}
callback(undefined, level);
const status = await vehicle.status();
if (status) {
let level = status.fuel.fuelLevel;
const fuel = status.fuel?.fuelLevel;
const battery = status.batteryFillLevel?.value;
let level = fuel || battery || 100;
if (level > 100) {
level = 100;
}
Expand Down
4 changes: 2 additions & 2 deletions src/types/vehicle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface VehicleInfo {
alarm: Status;
PrmtAlarmEvent: Status;
odometer: Status;
fuel: Fuel;
fuel?: Fuel;
gps: GPS;
remoteStart: RemoteStart;
remoteStartStatus: RemoteStartStatus;
Expand All @@ -67,7 +67,7 @@ export interface VehicleInfo {
lastRefresh: string;
lastModifiedDate: string;
serverTime: string;
batteryFillLevel: any;
batteryFillLevel?: RemoteStartStatus;
elVehDTE: any;
hybridModeStatus: any;
chargingStatus: any;
Expand Down

0 comments on commit a68917d

Please sign in to comment.