arraylabs / pymyq

Python wrapper for MyQ API
MIT License
112 stars 42 forks source link

Intermittent Connection failures due to Chamberlain MyQ API transition #60

Closed GaryOkie closed 3 years ago

GaryOkie commented 3 years ago

The latest connection failures are no longer related to V5.1 user agent changes but are evidently due to Chamberlain transitioning to a new V6 infrastructure and API. Please refer to https://github.com/home-assistant/core/issues/44851 for further description of the connection errors.

Work on reverse engineering V6 has already been started by the Homebridge-myq developer (which does not use pymyq). He is encouraging discussion on Homebridge Discord so please consider a collaboration on this effort.

https://github.com/hjdhjd/homebridge-myq/issues/226 ...

we’re aware there’s been yet another change in the myQ API and infrastructure. They seem to be transitioning to a new infrastructure and the errors we’re seeing are a result of the transition process and that they are deprecating the prior APIs we’ve used. I’ve gotten some good logs of the new protocol...now it’s a function of implementing it over the coming days. Stay tuned.

michaelpayne02 commented 3 years ago

Sounds about right. My instance still spits out a 'Server Error' intermittently even with the user agent reverted back to 'pymyq.'

brbeaird commented 3 years ago

This is actually a relief - my SmartThings integration has also been seeing intermittent 500 errors for the last several days. Was waiting to see if an issue would pop up here. Very glad to see someone has already started on V6.

haffi78 commented 3 years ago

Any chanse that someone might look to see if we can support the now one year later the lockitron locks wich show up on the app also ? Its just show as another type of door?

wpnelson commented 3 years ago

Thanks to any and all who contributed to the quick fix.

FreeWillyB commented 3 years ago

To whoever can help... I’m trying to reverse engineering this new API, but I’m stuck at the starting blocks. It appears you can only control the devices from an app, so I can’t use chromes inspection tools. I’ve tried a MITM attack, and after ALL NIGHT, I was finally able to get it somewhat working with mitmproxy and adding a trusted CA on my iPhone. But even though that worked on somethings, others like MyQ still didn’t work properly. Any ideas on how I can dig into this and grab some of the info on this new API?

SweVictor commented 3 years ago

Thought I'd help but got to the same place as you @FreeWillyB. Basically most apps today seem to use certificate pinning, and to capture that traffic you need a certificate (MITM cert for example) in the SYSTEM store, not USER store (user store is disregarded for apps since v7 of Android but used by apps explicitly opting in, chrome for example).

App traffic can probably be captured in an ADB environment or (for sure) on a rooted device, but I have neither up and running so can't help unfortunately.

Edit: Aaaand after re-reading first post work on gathering API calls has probably already been done in the homebridge repo....

michaelpayne02 commented 3 years ago

Today around 9:15 AM CST the intermittent errors and unavailability un Home Assistant stopped happening. MyQ may have fixed a bug or changed something, but it seems to be working okay for now. V6 api definitely needs to come asap because who knows how long this will keep working.

GaryOkie commented 3 years ago

Are you from the future? It's 8:45AM CST here in Central US now :)

Anyway, I concur that these errors have stopped for me as well - but as of yesterday @ 9:08PM CST.

garyak commented 3 years ago

My last disconnect was at 11:54 pm MST.

michaelpayne02 commented 3 years ago

Not a time traveler my bad, I meant 9:15 PM CST, which matches up with what you noticed as well.

juched78 commented 3 years ago

Same here, disconnects stopped for me around 9:45PM EST yesterday.

ds7771 commented 3 years ago

Same here, my logs show disconnects stopped at 9:57PM EST Jan 12.

If you are following the Homebridge project, they just released a patch to repair v5 API as a temporary measure. But it is unclear to me if the success of their patch is really due to MyQ API working again as of last night.

Anyway, just pointing out, if you want to run HB in parallel with HA, then you can bring the working Homekit devices from HB into HA and use those entities in your automations (assuming their patch is a real fix).

brbeaird commented 3 years ago

But it is unclear to me if the success of their patch is really due to MyQ API working again as of last night.

I have reviewed their commit and from what I can tell, it does not actually change the way it calls the API. I do believe changes on the MyQ side are the real difference-maker.

brbeaird commented 3 years ago

I have reviewed their commit and from what I can tell, it does not actually change the way it calls the API

I stand corrected - one potentially significant change it does make is to stop sending the ApiVersion header value altogether. The actual MYQ_API_VERSION_MINOR setting change can probably be ignored, though.

yetdog commented 3 years ago

So I'm a bit confused - I realize this is the pymyq repository, but I'm leveraging it via HomeAssistant, and I'm still seeing connection issues.

2021-01-13 15:15:23 ERROR (MainThread) [pymyq.api] Error requesting data from https://api.myqdevice.com/api/v5.1/Accounts/<id>/Devices: 400, message='Bad Request', url=URL('https://api.myqdevice.com/api/v5.1/Accounts/<id>/Devices')

@michaelpayne02 specifically called out HA as working again; I wonder if it's only the aforementioned HB -> HA configs that are working and not "native" HA, due to it depending solely on pymyq, whereas HB might be making their own changes?

dseven commented 3 years ago

@yetdog what versions of Home Assistant and pymyq are you running?

yetdog commented 3 years ago

@yetdog what versions of Home Assistant and pymyq are you running?

HA 2021.1.0 pymyq 2.0.12

juched78 commented 3 years ago

HA 2021.1.1 is working for me my pymyq 2.0.13 with no disconnects. HA direction, no customizations.

dseven commented 3 years ago

Yes, update to HA 2021.1.1 / pymyq 2.0.13. There are multiple issues going on, and the one you're (@yetdog) seeing is already addressed (for the moment).

yetdog commented 3 years ago

HA 2021.1.1 is working for me my pymyq 2.0.13 with no disconnects. HA direction, no customizations.

Thank you for that confirmation. I've updated my HA (and by extension pymyq) and things look golden now. I guess I didn't hop to upgrade as I hadn't seen the latest releases referencing pymyq as updated. (And we don't even seem sure that it's related to a lib change or just a server-side thing from MyQ)

ratsputin commented 3 years ago

I'll throw a "me too" in here. Just upgraded to 2021.1.1 and my gate has shown back up.

ds7771 commented 3 years ago

The Homebridge project has just released an update to properly interface with MyQ's new V6 API.

What happens next to get this into Home Assistant?

GaryOkie commented 3 years ago

There is a recent "MyQ API Update" #67 for pymq graciously opened by the Homebridge-myq dev to offer assistance and code snippets for the new MyQ v6 authentication that they solved. @ehendrix23 has responded and said he will start working on updating pymyq. That was 11 days ago, so hopefully there has been some progress.

I'll close this issue since the intermittent connection issues have ceased for now, and duplicates the request for a proactive update.

Please follow #67 for tracking the progress of this pymyq update request. We're on thin ice with how much longer the current MyQ legacy authentication will remain stable.

ehendrix23 commented 3 years ago

All just getting notifications on this. As mentioned, follow #67. Test version has been provided with new API.