Myq failing post 0.47 upgrade

I’m getting the following error from the myq component since the 0.47 upgrade. I haven’t tried 47.1 yet, I’ll try it when I get home tonight, but I wanted to see if anyone had any insights.

2017-06-22 10:22:46 ERROR (MainThread) [homeassistant.helpers.entity] Update for cover.single_car fails
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 224, in async_update_ha_state
    yield from self.hass.async_add_job(self.update)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/myq.py", line 99, in update
    self._status = self.myq.get_status(self.device_id)
  File "/home/homeassistant/.homeassistant/deps/pymyq/__init__.py", line 153, in get_status
    devices = self.get_devices()
  File "/home/homeassistant/.homeassistant/deps/pymyq/__init__.py", line 124, in get_devices
    devices = devices.json()['Devices']
KeyError: 'Devices'

section of configuration.yaml

cover:
  platform: myq
  name: Garage door Opener
  username: !secret myquser
  password: !secret myqpassword
  type: liftmaster

It has been working fine for months, so this is a new error.

does it work after an HA restart?

nope, still coming up about once every minute. I’m on 0.47.1 now.

Hmm, i’ve been running it on 0.47.0 and now 0.47.1 without issue. Does everything work in the Chamberlain/Liftmaster mobile app? The error message seems to show that authentication worked but its not getting any devices returned.

Also the “name” parameter is no longer needed/used, its gathered from the myq cloud based on the settings in the myq mobile app.

Ok, just commented that out, restarted and same problem.

I just added the following two info log entries around the json reformat. I wanted to see what Devices was before the format and after.

    self.logger.info("Devices={}".format(devices))
    devices = devices.json()['Devices']
    self.logger.info("Devices after json conversion={}".format(devices))

It seems to be blowing up on the json() conversion I think because it’s getting a successful message and not the json string.

2017-06-23 17:34:22 INFO (Thread-10) [pymyq] Devices=<Response [200]>
2017-06-23 17:34:22 ERROR (MainThread) [homeassistant.helpers.entity] Update for cover.two_car fails
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 224, in async_update_ha_state
    yield from self.hass.async_add_job(self.update)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/myq.py", line 99, in update
    self._status = self.myq.get_status(self.device_id)
  File "/home/homeassistant/.homeassistant/deps/pymyq/__init__.py", line 155, in get_status
    devices = self.get_devices()
  File "/home/homeassistant/.homeassistant/deps/pymyq/__init__.py", line 125, in get_devices
    devices = devices.json()['Devices']
KeyError: 'Devices'

I’ll try and format the request and see what I get back as a response.

The “200” code is the status of the return but not the content(body). I manually did a connection using postman to validate, then get device details. Got a 200 return code with the devices json in the body.

POST /api/v4/User/Validate HTTP/1.1
Host: myqexternal.myqdevice.com
MyQApplicationId: OA9I/hgmPHFp9RYKJqCKfwnhh28uqLJzZ9KOJf1DXoo8N2XAaVX6A1wcLYyWsnnv
Content-Type: application/json
Cache-Control: no-cache

{
	"username":"[email protected]",
	"password":"secret"
}
GET /api/v4/UserDeviceDetails/Get HTTP/1.1
Host: myqexternal.myqdevice.com
SecurityToken: bfgd43868-h63j-fr45-f5ew-5424y26r7521
MyQApplicationId: OA9I/hgmPHFp9RYKJqCKfwnhh28uqLJzZ9KOJf1DXoo8N2XAaVX6A1wcLYyWsnnv
Cache-Control: no-cache

fyi, security token changed for the example. Basically running the validate to get the security token to use in the get device details. In the validate the MyQApplicationId is in the header, the username and password are in the body. In the device details both the security token and MyQApplicationId are in the headers. You may know all that but putting it out there anyway.

The body of the devices return should be about 5-8KB in size containing the details in json.

Understood. But my question is, was is it something I need to fix in my config, or is a patch needed to the pymyq component?

Ok, I got a little further. I seem to be getting a -3333 error logging in.

http://support.chamberlain.com/articles/How_To/What-are-the-MyQ-Error-Codes-1484145672363

Does everything work in the mobile app? I can’t replicate that error in postman no matter how badly i muck up the method, id, username or password. Can you ping myqexternal.myqdevice.com from the HA system?

Yes everything works in the mobile app. I can ping myqexternal.myqdevice.com from the HA system. I’ve tried resetting my password and saying forgot password and having chamberlain do it for me. Still no luck.

Try adding a “cover” folder in “custom_components” and create a myq.py file with the contents from the gist below:

EDIT: File removed as it has known problems

then restart HA.

This has a few updates that I haven’t committed to HA yet, mostly an update interval so the endpoints aren’t getting hit as often, interval defaults to 120 seconds but can be changed in the config by adding a “scan_interval: 300” in the myq config.

Ok, give me a few, I’m updating all my appdaemon apps to account for Not having the zwave node_id after them and printing a new knob for my 3d printer. So I don’t want to restart HA at the moment, but I’ll get to it shortly.

No problem, I did my appdaemon update yesterday for both the beta4 and zwave nodes.

Ok, here is what I get using the myq.py in custom_components/cover. At least this is a Python error and not some strange random error being thrown by chamberlain.

2017-06-24 16:08:45 ERROR (MainThread) [homeassistant.helpers.entity] Update for cover.two_car fails
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 224, in async_update_ha_state
    yield from self.hass.async_add_job(self.update)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/util/__init__.py", line 302, in wrapper
    if force or utcnow() - throttle[1] > self.min_time:
TypeError: unorderable types: datetime.timedelta() > NoneType()
2017-06-24 16:08:45 ERROR (MainThread) [homeassistant.helpers.entity] Update for cover.single_car fails
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 224, in async_update_ha_state
    yield from self.hass.async_add_job(self.update)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/util/__init__.py", line 302, in wrapper
    if force or utcnow() - throttle[1] > self.min_time:
TypeError: unorderable types: datetime.timedelta() > NoneType()

Oh and I’m happy to help debug this anyway you need.

Interesting, wonder if some of those functions are new to Python 3.5 or 3.6. I’m on 3.6 in the docker image. I’m obviously not a Python expert but will see if I can setup a 3.4 install of HA and check out those errors.

Ok, let me know when you have something to test and I’ll give it a try.

Not sure I have any answers for you. Tried the official component on python 3.4.x and 3.5.x and it starts up and controls the door without issue. The custom component (from the gist) does not work in 3.4.x as I get the same errors as you. Probably not going to worry about it as its not published yet and seems HA is pushing for getting on 3.6 soon anyway.

You should probably remove the custom version.

I will put some more thought into your -3333 error with the official component. If you could try hitting the endpoints manually with postman or something similar that may be helpful. Also did you try the username and password directly in config without using !secret? I at a loss for the moment otherwise. Will keep an eye on the forums for others possibly having similar issues.

What’s the impact of upgrading to python 3.6? Will I have to re-create my virtual environment and re-install everything?