Brandawg93 / homebridge-fordpass

Control your Ford vehicle in HomeKit using Homebridge.
GNU General Public License v3.0
61 stars 15 forks source link

[Bug]: Battery Level Error on Mustang Mach-E #143

Closed itsthenewdc closed 3 years ago

itsthenewdc commented 3 years ago

Describe the bug

I purchased my Mach-E a couple days ago and was excited to see a FordPass plugin for Homebridge. I'm currently using HOOBS 4.0.87 / Node 14.17.2 / Homebridge 1.3.4. I added my credentials and vehicle name/VIN to the config file, but I get the following error when the plugin boots up.

7/15/2021, 2:04:03 AM Fordpass Bridge ERROR [Fordpass Bridge DA99@Kona@Kona Fuel Level@Battery Level] The read handler for the characteristic 'Battery Level' didn't respond at all!. Please check that you properly call the callback!

When I ask Siri for the battery level, it'll say:

Sorry, I didn't hear back from your devices. Kona's battery is at a normal level.

Obviously, for an electric vehicle "normal level" isn't helpful, lol.

Debug Output

7/15/2021, 2:04:03 AM Fordpass Bridge ERROR [Fordpass Bridge DA99@Kona@Kona Fuel Level@Battery Level] The read handler for the characteristic 'Battery Level' didn't respond at all!. Please check that you properly call the callback!

Steps to reproduce

  1. Run plugin. Error generates on every boot.

Device Type

HOOBS

iOS Version

14.6

Bug Persistence

Consistently

Last Working Version

No response

Brandawg93 commented 3 years ago

This is a known issue. The newer EVs do not use the "batteryLevel" flag like the gas powered vehicles. Unfortunately, I do not have an EV to test with. Others have attempted to get this working with their EVs but I haven't heard back from anyone.

authguardian commented 3 years ago

I also have a Mach E and know little about Typescript. @Brandawg93 I would be happy to do any testing for you. Also, Does Ford has rest API that can be access? Do you mind sharing any link to documentation?

Thanks in advance, Andy

Brandawg93 commented 3 years ago

Ford does not have an open API yet. I used mitmproxy to reverse engineer the api calls used in this plugin. You can see some of the api calls in the code. If you can figure out which property contains the correct battery level input for your EV, I can update the code accordingly and push out a beta for testing.

authguardian commented 3 years ago

It will be a learning for me however in any case I will clone this repo on my local machine and play around with this. I will update if I found anything.

authguardian commented 3 years ago

Is there a file where can i insert my username/password and vin for running test within the code which will prints out the flags programmatically?

Brandawg93 commented 3 years ago

Here's how I would do it:

  1. Clone the repo
  2. Add a few console.log statements in the aforementioned file
  3. Run npm run build
  4. Copy the dist folder into your current working plugin.
  5. Restart Homebridge.
authguardian commented 3 years ago

I added following line (after line#62) in fordpass.ts console.log(result.data) After running the build copied files from dist folder over to working plugin directory and receiving below error. Do you know what i am doing wrong here?

====================

[7/22/2021, 4:21:29 PM] ERROR LOADING PLUGIN homebridge-fordpass:
[7/22/2021, 4:21:29 PM] Error: Cannot find module './types/vehicle'
Require stack:
- /homebridge/node_modules/homebridge-fordpass/dist/fordpass.js
- /homebridge/node_modules/homebridge-fordpass/dist/index.js
- /usr/local/lib/node_modules/homebridge/lib/plugin.js
- /usr/local/lib/node_modules/homebridge/lib/pluginManager.js
- /usr/local/lib/node_modules/homebridge/lib/server.js
- /usr/local/lib/node_modules/homebridge/lib/cli.js
- /usr/local/lib/node_modules/homebridge/bin/homebridge
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/homebridge/node_modules/homebridge-fordpass/src/fordpass.ts:4:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
Brandawg93 commented 3 years ago

It's possible that I've changed a few extra files but haven't published a new plugin version. You may need to replace every file in the working plugin directory and rerun npm install there and try again.

authguardian commented 3 years ago

So here is what i did instead of cloning the repo i downloaded last stable release source code. Added console log for vehicle data. Replace the dist folders and restart HB. Here is the flag that you may be interested in probably.

batteryFillLevel: { value: 58, status: 'CURRENT', timestamp: '07-23-2021 00:31:08' }

let me know if there is anything else you may need from me at this time

also, there was battery specific key-value returned but has a nested objects type so i may have to add additional logging to get how its spitting the value. Will provide some info on that once i try that.

battery: { batteryHealth: [Object], batteryStatusActual: [Object] }

authguardian commented 3 years ago

here is the full export, VIN and GPS location have been masked

vehiclestatus: {
    vin: '################',
    lockStatus: {
      value: 'LOCKED',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    alarm: {
      value: 'SET',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    PrmtAlarmEvent: {
      value: 'NULL',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    odometer: {
      value: 3873,
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    fuel: null,
    gps: {
      latitude: '00.000000',
      longitude: '-11.111111',
      gpsState: 'UNSHIFTED',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    remoteStart: {
      remoteStartDuration: 0,
      remoteStartTime: 0,
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    remoteStartStatus: { value: 0, status: 'CURRENT', timestamp: '07-23-2021 00:31:08' },
    battery: { batteryHealth: [Object], batteryStatusActual: [Object] },
    oil: {
      oilLife: 'STATUS_GOOD',
      oilLifeActual: 100,
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    tirePressure: { value: 'STATUS_GOOD', timestamp: '07-23-2021 00:31:05' },
    authorization: 'AUTHORIZED',
    TPMS: {
      tirePressureByLocation: [Object],
      tirePressureSystemStatus: [Object],
      dualRearWheel: [Object],
      leftFrontTireStatus: [Object],
      leftFrontTirePressure: [Object],
      rightFrontTireStatus: [Object],
      rightFrontTirePressure: [Object],
      outerLeftRearTireStatus: [Object],
      outerLeftRearTirePressure: [Object],
      outerRightRearTireStatus: [Object],
      outerRightRearTirePressure: [Object],
      innerLeftRearTireStatus: [Object],
      innerLeftRearTirePressure: [Object],
      innerRightRearTireStatus: [Object],
      innerRightRearTirePressure: [Object],
      recommendedFrontTirePressure: [Object],
      recommendedRearTirePressure: [Object]
    },
    firmwareUpgInProgress: { value: false, timestamp: '07-02-2021 00:50:16' },
    deepSleepInProgress: { value: false, timestamp: '07-22-2021 23:44:26' },
    ccsSettings: {
      timestamp: '06-27-2021 18:58:27',
      location: 1,
      vehicleConnectivity: 1,
      vehicleData: 1,
      drivingCharacteristics: 1,
      contacts: 0
    },
    lastRefresh: '07-23-2021 00:31:05',
    lastModifiedDate: '07-23-2021 00:31:08',
    serverTime: '07-23-2021 00:31:31',
    batteryFillLevel: { value: 58, status: 'CURRENT', timestamp: '07-23-2021 00:31:08' },
    elVehDTE: {
      value: 186.800003,
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    hybridModeStatus: {
      value: 'Auto Charge Deplete Mode',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    chargingStatus: {
      value: 'ChargingAC',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    plugStatus: { value: 1, status: 'CURRENT', timestamp: '07-23-2021 00:31:08' },
    chargeStartTime: {
      value: '07-22-2021 19:52:00',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    chargeEndTime: {
      value: '07-22-2021 22:59:00',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    preCondStatusDsply: {
      value: 'Not Scheduled',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    chargerPowertype: null,
    batteryPerfStatus: {
      value: 'Ok no message displayed',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    outandAbout: {
      value: 'PwPckOffTqNotAvailable',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    batteryChargeStatus: {
      value: 'NoReportRequest',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    dcFastChargeData: { fstChrgBulkTEst: [Object], fstChrgCmpltTEst: [Object] },
    windowPosition: {
      driverWindowPosition: [Object],
      passWindowPosition: [Object],
      rearDriverWindowPos: [Object],
      rearPassWindowPos: [Object]
    },
    doorStatus: {
      rightRearDoor: [Object],
      leftRearDoor: [Object],
      driverDoor: [Object],
      passengerDoor: [Object],
      hoodDoor: [Object],
      tailgateDoor: [Object],
      innerTailgateDoor: [Object]
    },
    ignitionStatus: {
      value: 'Off',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    batteryTracLowChargeThreshold: {
      value: 'Thres50mi80km',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    battTracLoSocDDsply: {
      value: 'Null',
      status: 'CURRENT',
      timestamp: '07-23-2021 00:31:08'
    },
    dieselSystemStatus: null
  }
Brandawg93 commented 3 years ago

I've created a new beta (1.4.0-beta.0 1.4.0-test.0). You can install it via the wrench icon > Install Previous Versions in the UI. Let me know if this works for you!

Brandawg93 commented 3 years ago

Whoops. The package version is 1.4.0-test.0.

itsthenewdc commented 3 years ago

After installing 1.4.0-test.0 I get the following error after restarting plugin.

7/22/2021, 10:33:53 PMFordpass Bridge starting 7/22/2021, 10:33:59 PMFordpass BridgeERRORError loading plugin "homebridge-fordpass" 7/22/2021, 10:34:00 PMFordpass BridgeWARNINGNo plugins installed. 7/22/2021, 10:34:00 PMFordpass BridgeLoading 1 platforms... 7/22/2021, 10:34:00 PMFordpass BridgeFailed to find plugin to handle accessory Mustang Mach-E 7/22/2021, 10:34:00 PMFordpass BridgeBridge is running on port 57826.

Brandawg93 commented 3 years ago

You may need to delete your vehicle from the Homebridge cache under "Homebridge Settings" and restart.

authguardian commented 3 years ago

Receiving this error:

7/23/2021, 9:51:46 AM] ====================
[7/23/2021, 9:51:46 AM] ERROR LOADING PLUGIN homebridge-fordpass:
[7/23/2021, 9:51:46 AM] Error: Cannot find module './types/vehicle'
Require stack:
- /homebridge/node_modules/homebridge-fordpass/dist/fordpass.js
- /homebridge/node_modules/homebridge-fordpass/dist/index.js
- /usr/local/lib/node_modules/homebridge/lib/plugin.js
- /usr/local/lib/node_modules/homebridge/lib/pluginManager.js
- /usr/local/lib/node_modules/homebridge/lib/server.js
- /usr/local/lib/node_modules/homebridge/lib/cli.js
- /usr/local/lib/node_modules/homebridge/bin/homebridge
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/homebridge/node_modules/homebridge-fordpass/src/fordpass.ts:4:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
[7/23/2021, 9:51:46 AM] ====================

Followed steps:

Please let me know if what I am doing wrong here, Thanks in advanced

Brandawg93 commented 3 years ago

This looks like maybe a cache issue? Try manually deleting the homebridge-fordpass folder and reinstalling the test version of the plugin.

The only change I may was to check if fuelLevel was null then use batteryFillLevel. Otherwise, the test version should be the same as 1.3.X.

itsthenewdc commented 3 years ago

I've cleared both HOOBS and the plugin's cache, uninstalled/installed multiple times, and still have the same error in Terminal.

7/24/2021, 12:18:23 AMFordpass BridgeERRORError loading plugin "homebridge-fordpass" 7/24/2021, 12:18:23 AMFordpass BridgeWARNINGNo plugins installed. 7/24/2021, 12:18:23 AMFordpass BridgeLoading 1 platforms... 7/24/2021, 12:18:24 AMFordpass BridgeBridge is running on port 57826.

When I install the live version, the plugin works.

Brandawg93 commented 3 years ago

HOOBS 4 doesn't show the actual error. It's on their roadmap for a future fix. Without knowing where something is going wrong, it's difficult for me to debug.

Brandawg93 commented 3 years ago

I've found the issue. I'll create a new test when I get a chance and update here.

Brandawg93 commented 3 years ago

New test is up. v1.4.0-test.1.

itsthenewdc commented 3 years ago

Yay, it works!

Mustang Mach-E's battery level is at 87%

:D

Brandawg93 commented 3 years ago

1.4.0 is now live. Thanks for all the help debugging!

jcharnet commented 2 years ago

Yay, it works!

Mustang Mach-E's battery level is at 87%

:D

I see the battery level in homebridge but I don’t see it in the Home App. Do I need to enable something ?

Brandawg93 commented 2 years ago

It should be in the lock's setting page.

jcharnet commented 2 years ago

Yep. That was it. Had to drill down to the group and go to the lock. Thank you.