Closed luisiam closed 3 years ago
What pymyq / Home Assistant versions are you running?
I am running Home Assistant 2021.1.0 and pymyq 2.0.12
Same issue (below error); and same versions 2021.1.0 and pymyq 2.0.12. Looking at my history (screen shot below) it looks like it has been disconnecting and reconnecting dozens of times a day for the last couple days, before it just stopped working at all a couple hours ago.
Logger: pymyq.api
Source: /usr/local/lib/python3.8/site-packages/pymyq/api.py:118
First occurred: 9:01:44 AM (118 occurrences)
Last logged: 12:26:48 PM
Error requesting data from https://api.myqdevice.com/api/v5.1/Accounts/4b397bde-fbd4-4171-b50f-f39af001705d/Devices: Server Error
Error requesting data from https://api.myqdevice.com/api/v5.1/Accounts/4b397bde-fbd4-4171-b50f-f39af001705d/Devices: 400, message='Bad Request', url=URL('https://api.myqdevice.com/api/v5.1/Accounts/4b397bde-fbd4-4171-b50f-f39af001705d/Devices')
This is just a binary sensor view of myQ connection status.
I'm seeing the exact same behavior and have for a bit over a week. Same version of pymyq.
I'm seeing these:
2021-01-08 11:32:28 ERROR (MainThread) [pymyq.api] Error requesting data from https://api.myqdevice.com/api/v5.1/Accounts/9ae0865e-c3a8-49ce-ad2c-1d8721850987/Devices: 400, message='Bad Request', url=URL('https://api.myqdevice.com/api/v5.1/Accounts/9ae0865e-c3a8-49ce-ad2c-1d8721850987/Devices')
Running 2020.12.7 MyQ app on my phone is working fine.
Same problem here: 2021-01-08 11:31:42 WARNING (MainThread) [pymyq.api] Device update failed; trying again in 5 seconds 2021-01-08 11:31:47 ERROR (MainThread) [pymyq.api] Error requesting data from https://api.myqdevice.com/api/v5.1/Accounts/0083625f-a681-46b8-8fab-16918536944c/Devices: 400, message='Bad Request', url=URL('https://api.myqdevice.com/api/v5.1/Accounts/0083625f-a681-46b8-8fab-16918536944c/Devices') 2021-01-08 11:31:47 ERROR (MainThread) [homeassistant.components.myq] Unexpected error fetching myq devices data: Error requesting data from https://api.myqdevice.com/api/v5.1/Accounts/0083625f-a681-46b8-8fab-16918536944c/Devices: 400, message='Bad Request', url=URL('https://api.myqdevice.com/api/v5.1/Accounts/0083625f-a681-46b8-8fab-16918536944c/Devices') Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 144, in async_refresh self.data = await self._async_update_data() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 132, in _async_update_data return await self.update_method() File "/usr/local/lib/python3.8/site-packages/pymyq/api.py", line 223, in update_device_info devices_resp = await self.request( File "/usr/local/lib/python3.8/site-packages/pymyq/api.py", line 154, in request return await self._send_request( File "/usr/local/lib/python3.8/site-packages/pymyq/api.py", line 119, in _send_request raise RequestError(message) pymyq.errors.RequestError: Error requesting data from https://api.myqdevice.com/api/v5.1/Accounts/0083625f-a681-46b8-8fab-16918536944c/Devices: 400, message='Bad Request', url=URL('https://api.myqdevice.com/api/v5.1/Accounts/0083625f-a681-46b8-8fab-16918536944c/Devices')
I have the issue too running Home Assistant 2021.1.0 on a Rpi 3B and Home Assistant OS 5.10. The latest version of pymyq as well. Everything was working fine until a few days ago when my garage door would go 'unavailable' periodically until it finally stopped working completely today (Friday). Hope we can get this fixed for good some day where this doesn't keep happening with like a local API or something.
Hmm. Interesting. My "production" home assistant deployment is still working, but it's still on 0.108.x (with a manual hack to the pymyq user-agent), but I was able to reproduce your issue as below. I'll take a closer look later (at work now) if someone else doesn't beat me to it.
# docker run -ti -v /system/homeassistant/config:/config homeassistant/home-assistant:2021.1.0 bash
bash-5.0# pip3 show pymyq
Name: pymyq
Version: 2.0.12
Summary: Python package for controlling MyQ-Enabled Garage Door
Home-page: https://github.com/arraylabs/pymyq
Author: Chris Campbell
Author-email: None
License: MIT
Location: /usr/local/lib/python3.8/site-packages
Requires: async-timeout, aiohttp, aiodns
Required-by:
bash-5.0# python3 /config/testmyq.py
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:pymyq.api:Sending authentication request to MyQ
DEBUG:pymyq.api:Sending myq api request https://api.myqdevice.com/api/v5/Login
DEBUG:pymyq.api:Retrieving account information
DEBUG:pymyq.api:Sending myq api request https://api.myqdevice.com/api/v5/My
DEBUG:pymyq.api:Retrieving MyQ information
DEBUG:pymyq.api:Retrieving accounts
DEBUG:pymyq.api:Sending myq api request https://api.myqdevice.com/api/v5/Accounts
DEBUG:pymyq.api:Retrieving devices for account xxx
DEBUG:pymyq.api:Sending myq api request https://api.myqdevice.com/api/v5.1/Accounts/xxx/Devices
DEBUG:pymyq.api:Attempt 1 request failed with exception: 400, message='Bad Request', url=URL('https://api.myqdevice.com/api/v5.1/Accounts/xxx/Devices')
where testmyq.py contains:
import asyncio
from aiohttp import ClientSession
import pymyq
import logging
logging.basicConfig(level=logging.DEBUG)
async def main() -> None:
async with ClientSession() as websession:
myq = await pymyq.login('xxx@mydomain.com', 'xxx', websession)
devices = myq.devices
for dev, info in devices.items():
print('%(device_family)s: %(name)s' % info.device_json)
asyncio.get_event_loop().run_until_complete(main())
Well so much for randomising the user-agent. Changing it back to "pymyq" makes it work again:
bash-5.0# diff api.py.orig api.py
--- api.py.orig
+++ api.py
@@ -20,7 +20,7 @@
DEFAULT_APP_ID = "JVM/G9Nwih5BwKgNCjLxiFUQxQijAebyyg8QUHr7JOrP+tuPb8iHfRHKwTmDzHOu"
# Generate random string for User Agent.
-DEFAULT_USER_AGENT = "".join(choices(string.ascii_letters + string.digits, k=10))
+DEFAULT_USER_AGENT = "pymyq"
DEFAULT_BRAND_ID = 2
DEFAULT_REQUEST_RETRIES = 5
DEFAULT_CULTURE = "en"
bash-5.0#
Manually patched mine and it's working again (for now). Thanks for the tips.
@luisiam How did you patch it? Did you change the library with the ssh add-on or did you add it to a custom_components folder?
@michaelpayne02 I am running Home Assistant docker and I manually modify the /usr/local/lib/python3.8/site-packages/pymyq/api.py
file.
Is this related? https://community.home-assistant.io/t/myq-change-user-agent-to-pymyq/258049
Also - I can confirm that changing the DEFAULT_USER_AGENT to "pymyq" resolved the issue.
Is this related? https://community.home-assistant.io/t/myq-change-user-agent-to-pymyq/258049
Also - I can confirm that changing the DEFAULT_USER_AGENT to "pymyq" resolved the issue.
It won't resolve it long term, the issue will come back, based on what I've noted in this thread:
https://community.home-assistant.io/t/myq-not-working-again/193086/159?u=austin-2021
It's a whack-a-mole game. Unless we can get some sort of commitment from "the myQ people" (which seems unlikely), we can never be sure of any fix.
2.0.13 just pushed to set user agent. This also has change allowing user agent to be provided so it is not hardcoded. Opened pull request #44961 for Home Assistant to get version of pymyq updated. This request does not contain changes to supply a user agent though. That would still need to be coded within home assistant
I modified api.py changed the user_agent, restarted HA and it's currently working again, temporarily. :)
@michaelpayne02 , if you need help adjusting private message me and I can assist.
@MaikaiLife I got it fixed too. Thanks for asking, though. You guys are the best.
2.0.13 just pushed to set user agent. This also has change allowing user agent to be provided so it is not hardcoded. Opened pull request #44961 for Home Assistant to get version of pymyq updated. This request does not contain changes to supply a user agent though. That would still need to be coded within home assistant
Related discussion in HA forums: https://community.home-assistant.io/t/allow-the-end-user-to-specify-myq-user-agent/207858 Related issue for HA: https://github.com/home-assistant/core/issues/44348
FYI, the PR to allow for user setting user agent (https://github.com/home-assistant/core/pull/44972) is not being accepted. Next time it breaks due to user agent will result in this integration not working anymore unless it is deployed as a custom integration in HASS.
Note, I will be seeing to update pymyq to V6 API once information is available on how it works.
Happy new year! Looks like we are greeted with another API update. I am running Home Assistant and it stopped working from 8:20AM. Following error is logged.