diff --git a/src/index.ts b/src/index.ts index 11597ac..0d4fb68 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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; } diff --git a/src/types/vehicle.d.ts b/src/types/vehicle.d.ts index 619c79c..1123148 100644 --- a/src/types/vehicle.d.ts +++ b/src/types/vehicle.d.ts @@ -55,7 +55,7 @@ export interface VehicleInfo { alarm: Status; PrmtAlarmEvent: Status; odometer: Status; - fuel: Fuel; + fuel?: Fuel; gps: GPS; remoteStart: RemoteStart; remoteStartStatus: RemoteStartStatus; @@ -67,7 +67,7 @@ export interface VehicleInfo { lastRefresh: string; lastModifiedDate: string; serverTime: string; - batteryFillLevel: any; + batteryFillLevel?: RemoteStartStatus; elVehDTE: any; hybridModeStatus: any; chargingStatus: any;