arraylabs / pymyq

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

API Changed Again? #38

Closed NickNothom closed 4 years ago

NickNothom commented 4 years ago

Started getting this error today.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/myq/config_flow.py", line 50, in async_step_user
    info = await validate_input(self.hass, user_input)
  File "/usr/src/homeassistant/homeassistant/components/myq/config_flow.py", line 30, in validate_input
    await pymyq.login(data[CONF_USERNAME], data[CONF_PASSWORD], websession)
  File "/usr/local/lib/python3.7/site-packages/pymyq/api.py", line 170, in login
    await api.authenticate(username, password)
  File "/usr/local/lib/python3.7/site-packages/pymyq/api.py", line 119, in authenticate
    self._security_token = auth_resp["SecurityToken"]
TypeError: 'NoneType' object is not subscriptable
dseven commented 4 years ago

Same here. Curiously, I cannot reproduce it outside HA, though - even using the same same python environment. The "To get all MyQ devices associated with an account" example code is (still) working for me.

dseven commented 4 years ago

It appears that this is not actually fixed :( It was working for a while, but then stopped again (in home assistant, and with a manual test - same symptom (error logged))...

bash-5.0# pip3 show pymyq
Name: pymyq
Version: 2.0.3
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.7/site-packages
Requires: aiohttp, aiodns, async-timeout
Required-by:
bash-5.0# python3
Python 3.7.7 (default, Apr 28 2020, 13:57:57)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio, pymyq
>>> from aiohttp import ClientSession
>>> async def foo() -> None:
...     async with ClientSession() as websession:
...         myq = await pymyq.login('myq@mydomain.com', 'mypasswd', websession)
...
>>> asyncio.get_event_loop().run_until_complete(foo())
Device update failed; trying again in 1 seconds
Device update failed; trying again in 5 seconds
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "<stdin>", line 3, in foo
  File "/usr/local/lib/python3.7/site-packages/pymyq/api.py", line 172, in login
    await api.authenticate(username, password)
  File "/usr/local/lib/python3.7/site-packages/pymyq/api.py", line 121, in authenticate
    self._security_token = auth_resp["SecurityToken"]
TypeError: 'NoneType' object is not subscriptable
>>>
dseven commented 4 years ago

Hold that thought - just noticed that there's a 2.0.4 - testing now

update: 2.0.4 seems to have aligned us with the goal-posts for another while ;) HA PR seems to be under way too: https://github.com/home-assistant/core/pull/36666

jfrux commented 4 years ago

Not sure if it's related... but the native iOS app is actually what lead me here... The native iOS app throws an error during authentication when I'm connected to the same wifi network as the device, but works when on LTE. I was going to use pymyq to test if it was something with my network blocking the API calls... I know it sounds like its unrelated, but who knows... just figured I'd throw this out there.