brbeaird / SmartThings-MyQ-Edge

SmartThings/MyQ Integration via Edge
62 stars 16 forks source link

MyQ Controller status going offline frequently #37

Closed aerie91 closed 1 year ago

aerie91 commented 1 year ago

Hello! First, thanks for your work developing this awesome tool. It's made my home automations much better!

I've upgraded to the new Edge driver. For some time it seemed to be working fine. In the last few days though, I noticed that sometimes it works fine and other times the status of a garage door doesn't change. I looked in SmartThings, and found that the status of the MyQ Controller (and the doors) is Offline pretty frequently. Sometimes it will be online, but a few minutes later offline again. I am running the bridge on an Ubuntu 22.04 machine that I use as a Plex server as well. It is on the same network and subnet as the SmartThings hub. I tried restarting the Docker container, rebooting the server, power-cycling the SmartThings hub but the issue persists. I found your comment on another thread about making a request to the bridge by entering the IP and port into a browser: http://192.168.1.18:8090/status . This returns a good result consistently, as tested from various devices on different ports and switches on the LAN.

So my question is, what would cause the SmartThings hub to indicate the MyQ devices are offline even though the server is accessible? Are there any logs or further troubleshooting you can recommend? I'm pasting below the response from the server when I hit the URL above. It shows Online = True.

  |   -- | -- 0 |   href | "/accounts/a5b1c15f-969b-48f3-966a-e49a3537264b/devices/gateway/GW030004C5A8" serial_number | "GW030004C5A8" device_family | "gateway" device_platform | "myq" device_type | "hub" device_model | "hub" name | "Home" account_id | "a5b1c15f-969b-48f3-966a-e49a3537264b" created_date | "2015-12-27T18:02:23.587" state |   allow_bluetooth_lock | false firmware_version | "9.4" homekit_capable | false homekit_enabled | false learn_mode | false updated_date | "2023-09-11T15:27:41.3156973Z" physical_devices |   0 | "CG0843098B50" 1 | "CG0843098B51" pending_bootload_abandoned | false wifi_rssi_decibel_milliwatts | -35 wifi_signal_strength | "excellent" supports_dealer_diagnostics | false mandatory_update_required | false online | true last_status | "2023-09-11T15:27:37.3119311Z" 1 |   href | "/accounts/a5b1c15f-969b-48f3-966a-e49a3537264b/devices/garagedoor/CG0843098B50" serial_number | "CG0843098B50" device_family | "garagedoor" device_platform | "myq" device_type | "virtualgaragedooropener" device_model | "virtualgaragedooropener" name | "Large Garage Door" account_id | "a5b1c15f-969b-48f3-966a-e49a3537264b" parent_device_id | "GW030004C5A8" created_date | "2015-12-27T18:02:23.6" state |   dps_battery_critical | false dps_no_communication | false dps_low_battery_mode | false monitor_only_mode | false number_of_learned_dps_devices | 1 sensor_comm_error | false is_scheduling_allowed | false door_state | "closed" last_update | "2023-09-10T23:44:44.7557988Z" is_unattended_open_allowed | true is_unattended_close_allowed | true service_cycle_count | 0 absolute_cycle_count | 0 online | true last_status | "2023-09-11T15:27:37.7312794Z" 2 |   href | "/accounts/a5b1c15f-969b-48f3-966a-e49a3537264b/devices/garagedoor/CG0843098B51" serial_number | "CG0843098B51" device_family | "garagedoor" device_platform | "myq" device_type | "virtualgaragedooropener" device_model | "virtualgaragedooropener" name | "Small Garage Door" account_id | "a5b1c15f-969b-48f3-966a-e49a3537264b" parent_device_id | "GW030004C5A8" created_date | "2019-11-09T22:00:26.947" state |   dps_battery_critical | false dps_no_communication | false dps_low_battery_mode | false monitor_only_mode | false number_of_learned_dps_devices | 1 sensor_comm_error | false is_scheduling_allowed | false door_state | "closed" last_update | "2023-09-11T17:15:33.8988613Z" is_unattended_open_allowed | true is_unattended_close_allowed | true service_cycle_count | 0 absolute_cycle_count | 0 online | true last_status | "2023-09-11T17:15:33.8989177Z"
aerie91 commented 1 year ago

Here are the last 10 records in the event log from SmartThings. You can see how often it's happening. image

brbeaird commented 1 year ago

What do your Docker bridge server logs show? Does it show Version 1.0.4 on startup?

aerie91 commented 1 year ago

Hi Brian,

Thanks, I never used Docker before this and didn't know it keeps logs. But this morning I am seeing a different error, it shows the login failed, while yesterday it was saying it's offline. Checking the docker logs today as you suggested, I found the following messages repeating every couple of minutes, which seems to reinforce the authentication problem:

myQ API: https://partner-identity.myq-cloud.com/connect/authorize?client_id=IOS_CGI_MYQ&code_challenge=nMJga0srj5qWqQjCVIQ27ESKjgr7ZSUyVx9M2fm1hT0&code_challenge_method=S256&redirect_uri=com.myqops%3A%2F%2Fios&response_type=code&scope=MyQ_Residential+offline_access Error: 403 Forbidden myQ API: Unable to access the OAuth authorization endpoint. 9/12/2023, 3:38:34 PM | Refresh failed 9/12/2023, 3:39:15 PM | Refresh failed 9/12/2023, 3:39:58 PM | Refresh failed myQ API: https://partner-identity.myq-cloud.com/connect/authorize?client_id=IOS_CGI_MYQ&code_challenge=MEs6rBw2tx1cHzelkRNA1MznyOU5l4EMUq8xlbOBGns&code_challenge_method=S256&redirect_uri=com.myqops%3A%2F%2Fios&response_type=code&scope=MyQ_Residential+offline_access Error: 403 Forbidden myQ API: Unable to access the OAuth authorization endpoint. 9/12/2023, 3:40:40 PM | Refresh failed 9/12/2023, 3:41:22 PM | Refresh failed 9/12/2023, 3:42:04 PM | Refresh failed myQ API: Successfully connected to the myQ API. myQ API: https://devices.myq-cloud.com/api/v5.2/Accounts/a5b1c15f-969b-48f3-966a-e49a3537264b/Devices Error: 403 Forbidden myQ API: Unable to update device status from the myQ API. Acquiring a new access token. 9/12/2023, 3:43:07 PM | Refresh failed 9/12/2023, 3:43:49 PM | Refresh failed

I actually had a similar issue shortly after upgrading to the Edge version where it started showing bad password even though the password hadn't changed. Back then I reset my password with MyQ and updated the bridge to use the new password, and then it worked fine. I thought it was a fluke so I didn't think too much about it, but now a similar issue is happening. The MyQ app on my phone is still working fine using the same password, and I even logged out and back in, it works.

Regarding the version, I restarted the container to see what it shows in the log at startup. It shows some startup messages but not the version. Where do I find that?

9/12/2023, 3:46:40 PM | HTTP server listening on port 8090 9/12/2023, 3:46:40 PM | SSDP server up and listening for broadcasts: urn:SmartThingsCommunity:device:MyQController 9/12/2023, 3:47:19 PM | Got new username/password from hub. Initializing connection. myQ API: https://partner-identity.myq-cloud.com/connect/authorize?client_id=IOS_CGI_MYQ&code_challenge=sO7aubxPefRS-ACtRA0JMpZ55dfqyp8NREjaKIRQtLY&code_challenge_method=S256&redirect_uri=com.myqops%3A%2F%2Fios&response_type=code&scope=MyQ_Residential+offline_access Error: 403 Forbidden myQ API: Unable to access the OAuth authorization endpoint. 9/12/2023, 3:47:19 PM | Refresh failed

aerie91 commented 1 year ago

I tried resetting the MyQ password and updated the controller with the new one. It is still showing login failed. Here is the log since then:

9/12/2023, 7:23:05 PM | Got new username/password from hub. Initializing connection. myQ API: Successfully connected to the myQ API. myQ API: Discovered device family gateway: Home [Chamberlain WiFi Hub] (serial number: GW030004C5A8). myQ API: Discovered device family garagedoor: Large Garage Door (serial number: CG0843098B50, gateway: GW030004C5A8). myQ API: Discovered device family garagedoor: Small Garage Door (serial number: CG0843098B51, gateway: GW030004C5A8). myQ API: https://accounts.myq-cloud.com/api/v6.0/accounts Error: 403 Forbidden myQ API: Unable to retrieve account information. 9/12/2023, 7:23:40 PM | Refresh failed 9/12/2023, 7:24:22 PM | Refresh failed 9/12/2023, 7:24:57 PM | Refresh failed myQ API: https://partner-identity.myq-cloud.com/connect/authorize?client_id=IOS_CGI_MYQ&code_challenge=1RY9GG5kJjL8r1H7UKRh4F2yfUxCA4sihMiPRAaFuLw&code_challenge_method=S256&redirect_uri=com.myqops%3A%2F%2Fios&response_type=code&scope=MyQ_Residential+offline_access Error: 403 Forbidden myQ API: Unable to access the OAuth authorization endpoint. 9/12/2023, 7:25:39 PM | Refresh failed

brbeaird commented 1 year ago

If you're running the latest docker image, the first message you will see in the logs is SmartThings MyQ Bridge server: Version: 1.0.4

From your screenshots, I am not seeing that, which means you need to kill your existing Docker container and pull down and start a new instance. Something like this:

docker stop smartthings-myq-edge (or whatever you have it named)
docker rm smartthings-myq-edge (or whatever you have it named)
docker pull brbeaird/smartthings-myq-edge
docker run -d --name='smartthings-myq-edge' -e 'MYQ_SERVER_PORT'='8090' -p '8090:8090/tcp' -p '1900:1900/udp' 'brbeaird/smartthings-myq-edge:latest
aerie91 commented 1 year ago

Thank you! After doing that, it now shows 1.0.4 and the controller is online! I'll monitor but hopefully it means it's fixed, and the cause was that I missed an update :disappointed: Sorry for wasting your time, but thanks a lot for your help!

aerie91 commented 1 year ago

Hi Brian, sorry to say I think it's not fully solved. After running mostly fine for a few days, overnight last night a similar issue started happening. I'm seeing this in the logs every few minutes.

9/16/2023, 2:30:50 PM | Initializing connection to MyQ-east. myQ API error: API call returned error: 429. 9/16/2023, 2:30:50 PM | MyQ login failed

It alternates with MyQ-west, but both fail. I restarted the docker container but same error on startup. I googled error 429 but didn't find anything specific on what it means. Any ideas?

brbeaird commented 1 year ago

Mine is down, too. This is something new. 429 is a throttling error. Will need to see what hjd thinks if his implementation is seeing it.

On Sat, Sep 16, 2023 at 9:35 AM aerie91 @.***> wrote:

Reopened #37 https://github.com/brbeaird/SmartThings-MyQ-Edge/issues/37.

— Reply to this email directly, view it on GitHub https://github.com/brbeaird/SmartThings-MyQ-Edge/issues/37#event-10389803054, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXHM2FTWSRND2N7NXEZO2DX2W2MNANCNFSM6AAAAAA4T74WSE . You are receiving this because you commented.Message ID: @.*** com>

brbeaird commented 1 year ago

I am back up now. I stopped my bridge server for about 10 minutes and then started it back. I also changed the refresh interval up to 60 seconds. This is a setting in the SmartThings app on the MyQ-Controller device.

On Sat, Sep 16, 2023 at 9:40 AM Brian Beaird @.***> wrote:

Mine is down, too. This is something new. 429 is a throttling error. Will need to see what hjd thinks if his implementation is seeing it.

On Sat, Sep 16, 2023 at 9:35 AM aerie91 @.***> wrote:

Reopened #37 https://github.com/brbeaird/SmartThings-MyQ-Edge/issues/37 .

— Reply to this email directly, view it on GitHub https://github.com/brbeaird/SmartThings-MyQ-Edge/issues/37#event-10389803054, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXHM2FTWSRND2N7NXEZO2DX2W2MNANCNFSM6AAAAAA4T74WSE . You are receiving this because you commented.Message ID: @.*** com>

aerie91 commented 1 year ago

Thanks. It solved itself on its own in my case, I left for the day and when I came back it was working fine.