Brandawg93 / homebridge-fordpass

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

[Bug]: Lock notification spam #152

Open shad0wca7 opened 2 years ago

shad0wca7 commented 2 years ago

Describe the bug

Things might be quiet for a day or two and then I'll get hit with tens of notifications at the same time about the vehicle being locked / unlocked (and bouncing between the two). I've gone to the point of disabling lock notifications within the home application but I wonder if it's something I'm doing wrong?

Debug Output

Frequently see 'EAI_AGAIN' in the logs

Steps to reproduce

  1. Follow instructions in the setup - use normally.

Device Type

Intel Xeon server

iOS Version

15

Bug Persistence

Consistently

Last Working Version

No response

Brandawg93 commented 2 years ago

Are you using the auto refresh feature? This may resolve your issue. Without this, the Ford API uses cached data that may not always be up-to-date.

shad0wca7 commented 2 years ago

I turned on the auto refresh feature (wasn't using it) but I'm still seeing this in the logs: [10/8/2021, 9:53:14 AM] [homebridge-fordpass] Status failed with error: EAI_AGAIN

Brandawg93 commented 2 years ago

Here's some info I found on EAI_AGAIN. It looks to be a DNS issue.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 3 days

shad0wca7 commented 2 years ago

Here's some info I found on EAI_AGAIN. It looks to be a DNS issue.

hm that's odd - shouldn't be any DNS issues unless it's calling to something that's being blocked by my DNS ad blocking - though I can't see anything in the logs

JeffGoldner commented 2 years ago

I am seeing this as well. Several times a day I get a lock or unlock notification. I can correlate the "real" events, but the middle of the night - and even this AM - just did not happen. I have disabled the plug-in for now as it was driving my wife crazy.

iamkhris commented 2 years ago

I tried to set this up in the past but was frustrated with the inaccurate lock/unlock indicator. I gave it another try today and from what I can see, when issuing commands to lock and unlock my vehicle, it is working. When I lock my vehicle, it indeed locks, but then within 30 seconds or so, HomeKit shouts that the vehicle is unlocked.

I really want this to work, but the uncertainty of whether my vehicle is really locked is making it hard to keep the plugin enabled. How can I help test/debug this?

Brandawg93 commented 2 years ago

The issue is with how Ford built their API. It uses cached data instead of live data to determine the state of the vehicle. So if you lock your vehicle and then get its state some time later, it may be inaccurate. You cannot see the state of the vehicle in the official fordpass app either because of this issue. I've tried to circumvent this in the plugin by adding the refresh ability, but this can potentially drain your vehicle's battery.

iamkhris commented 2 years ago

Thanks for the info and explanation. Forgive me if my questions have already been asked at some point along the way.

Is it possible to have Homebridge "assume" that if I used it to lock the doors, it should continue showing the doors are locked for at least X minutes before refreshing? This may be the way you've designed the refresh, but from what I saw earlier when I was testing it, the doors would always go unlocked a short time after locking them through Homebridge.

When the data is pulled from the Ford API, is it timestamped at all as to when it was last pulled? I assume no, but if it was, you could then look at the state of the data at the timestamp from Ford and compare it with the Homebridge version. If Ford is showing the vehicle unlocked at 2pm and Homebridge is showing the vehicle locked at 2:30pm, with it now being 4pm, I would assume the doors are still locked.

Forgive my ramblings as I honestly have no idea how the actual Ford API works, and am just thinking/wishing out loud. lol Thanks for your effort on this. :)

Brandawg93 commented 2 years ago

I spent a decent amount of time looking into this and actually spoke with one of the developers of the fordpass app. They have some great features coming to the app in the future, but these issues that this plugin is facing is what they are trying to resolve now. It's "kill the battery and have up-to-date info" or "have stale info with a working vehicle" 😜

Hopefully Ford will have a proper solution soon to this.

iamkhris commented 2 years ago

Thanks Brandon. I appreciate you taking the time to respond.

Given those choices, I GUESS I'll take stale info and a working vehicle! lol 🤣

Have a great day!

Razeeer commented 2 years ago

Are you using the auto refresh feature? This may resolve your issue. Without this, the Ford API uses cached data that may not always be up-to-date.

@Brandawg93 Hello can you explain me what exactly I have to enter in the config so that I can use the auto refresh feature? Thank you!

Brandawg93 commented 2 years ago

You can add autoRefresh: true to your config to have it refresh automatically.

Razeeer commented 2 years ago

Thanks for the answer. Can you tell me exactly where it needs to go in config to make it work?

"platforms": [ { "platform": "FordPass", "username": "", }, "password": "", "vehicles": [ { "name": "", "vin": "" } ] } ] }

Brandawg93 commented 2 years ago

Under the fordpass "platform" add an "options" object with the above line in it.

Razeeer commented 2 years ago

Would be great if you could include it in my config or in the example config of the plugin. I'm there not so experienced in config.json edit.

🙏 Thanks

Brandawg93 commented 2 years ago

No problem. Unfortunately, I'm on a phone since I'm out of town, but I'll be able to add it when I get to a computer. The settings UI should guide you through it depending on if you are using HOOBS or Homebridge.

Razeeer commented 2 years ago

That would be really great if you can make an example later. Thanks!

Brandawg93 commented 2 years ago

I've added an example to the README. Here it is:

{
    "username": "YOUR_USERNAME",
    "password": "YOUR_PASSWORD",
    "vehicles": [
        {
            "name": "VEHICLE NAME",
            "vin": "YOUR_VIN"
        }
    ],
    "options": {
        "autoRefresh": false
    },
    "platform": "FordPass"
}

You would just need to replace false with true.

Razeeer commented 2 years ago

Super many thanks!

HAKrofft commented 2 years ago

I experienced this issue as well and I think I finally understand that is starts occuring after FordPass has determined the vehicle has been idle for a certain amount of time and disables the API. From my experience, the status then reports as default Unlocked, Off. I do not think the auto-refresh fixes this as the disabling of the API is not client side. Once I start my truck with the key, the API is re-enabled and status reports correctly.

blaine07 commented 2 years ago

I experienced this issue as well and I think I finally understand that is starts occuring after FordPass has determined the vehicle has been idle for a certain amount of time and disables the API. From my experience, the status then reports as default Unlocked, Off. I do not think the auto-refresh fixes this as the disabling of the API is not client side. Once I start my truck with the key, the API is re-enabled and status reports correctly.

I think your right; I get the MOST spam about Lock/Unlock after my truck has set several days. I know after two weeks the ford app will send me a notification saying truck has been put to "deep sleep" or something to that effect and the lock spamming seems to stop.