Myq componenet issues

@captainnaplam The myq-garage.py script will run as user ‘homeassistant’. It needs to be able to access the “config.ini” file and its “logs” sub-directory. Make sure (with chown and chmod) that these are both accessible.

I placed the myq scripts and config in a directory called ‘myq-garage’ and used something like the following:

chown -hR homeassistant:homeassistant /home/homeassistant/myq-garage

Secondly, you will probably need to edit the myq-garage.py script itself to specify the full path to the config.ini file (around line 50):

config.read(‘/home/homeassistant/myq-garage/config.ini’)

In my configuration.yaml, I set it up as a switch with the following:

switch:
  platform: command_line
  scan_interval: 120
  switches:
    garage_door:
      friendly_name: Garage Door
      command_on: '/home/homeassistant/myq-garage/myq-garage.py open Garage'
      command_off: '/home/homeassistant/myq-garage/myq-garage.py close Garage'
      command_state: '/home/homeassistant/myq-garage/myq-garage.py status | awk "/Garage is Closed/ {exit 1} {exit 0}"'

Note this changes the polling of the garage door to every 2 minutes, and moves the template processing of the state result to the awk script. The myq-garage script writes a log entry in its “logs” directory every time it is run, so be prepared to deal with this (or disable the feature somehow by editing the myq-garage.py script).

In the on/off commands, the ID ‘Garage’ came from the myq-garage.py status command and is the name you assigned to the garage door on the MyQ site. The ID is also included as part of the regex used in the awk script, so be sure to update that as well.

HTH.

2 Likes

thanks. not sure which step exactly I was screwing up on, but this seems to have worked. i already had it configured through wink, but trying to move out of Wink as much as possible, so this is a big help.

I’ve set it up as a cover like @rajivram did as opposed to a switch, and it seems to be working, but I also see errors in my logs that commands failed, which I find a bit odd.

17-01-13 22:46:19 homeassistant.components.cover.command_line: Command failed: /home/homeassistant/myq-garage/myq-garage.py open "Garage Door Opener" 17-01-13 22:46:41 homeassistant.components.cover.command_line: Command failed: /home/homeassistant/myq-garage/myq-garage.py close "Garage Door Opener"

In both cases, the commands did execute properly.

There have been times when the myq commands have stopped working for me and the homeassistant logs showed errors. I then made changes to the myq-garage.py file and these changes seem to have remedied the errors. I have included the file here. If you wish to use this file, backup your old myq-garage.py file in the myq-garage directory and replace it with the file included here. Be sure to rename this file to myq-garage.py

http://community-assets.home-assistant.io/original/2X/2/2f84153f06f2e1cbd11c2d69906f7cf39c74d60d.xml

Still seem to be getting errors with your updated myq-garage.py file. I’ll have to dig further, but this is the error I’m receiving. Again, the command is executing properly, but says it’s failing.

17-01-15 10:26:42 homeassistant.components.cover.command_line: Command failed: /home/homeassistant/myq-garage/myq-garage.py open "Garage Door Opener" 17-01-15 10:26:47 homeassistant.core: Error doing job: Future exception was never retrieved Traceback (most recent call last): 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/core.py", line 1054, in execute_service service_handler.func(service_call) File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/__init__.py", line 150, in handle_cover_service cover.update_ha_state(True) File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 187, in update_ha_state self.update() File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/command_line.py", line 142, in update self._state = int(payload) ValueError: invalid literal for int() with base 10: '' 17-01-15 10:26:51 homeassistant.core: Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step result = coro.throw(exc) File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 386, in _update_entity_states yield from update_coro File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 216, in async_update_ha_state yield from self.hass.loop.run_in_executor(None, 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/command_line.py", line 142, in update self._state = int(payload) ValueError: invalid literal for int() with base 10: ''

What version of python are you using? Mine is Python 2.7.10.

python --version says 2.7.9.

Edit: is that the issue? Home Assistant is running the script with version 3.4 (likely the version within the virtual_env), but the script it written for version 2.7? Curious that you wouldn’t also be seeing similar errors.

With the scan interval set to 120, does this mean that if the door is opened by a standard wireless remote or wall mounted button that you wouldn’t see that in Hass for up to 2 minutes?

Yes. The scan interval is the time in seconds between state updates.

You could always shebang the .py file and force it to run in 2.7.9.

#!/usr/bin/python2.7.9

Yes, it means there could be up to a 2 minute delay in detecting door changes – although the average will be 60 seconds. You can set this to what ever you are comfortable with, or leave it out and simply use the built in Hass default.

I believe HASS also forces a state check before any open/close so it will not attempt to open/close unnecessarily.

As an FYI, the author of the myq-garage.py script points out the scripts are using the Chamberlain API “unofficially”, and if the MyQ servers are hammered by a bunch script users, Chamberlain might not be happy - ie. do something to block unlicensed API users.

I wonder how often the homebridge plugin for MyQ is updating the status? I’m getting a lot of traffic to their servers when I use that plugin so I feel like it’s more often that 2 minutes or the default 5. I wanted to switch to this to have it integrated into hass though. I’ll give it a try and see how it works for me. Thanks for the reply.

I suggest to rely on the component in https://github.com/arraylabs/myq

It worked flawlessly right “out of the box” (in this case, upon install). Just pay attention that the custom_component directory is where the configuration file for HASS is. My garage door is a Liftmaster 8550W.

It is frustrating that Chamberlain/Liftmaster communicate so little information through their API, but oh well…

I’d love to use this component but I simply cannot get it to work with any of the above tips. I have the MyQ Chamberlain add-on model and it never connects. Works fine with the homebridge-Chamberlain plugin

I have the same add-on model and after some tweaking, I have it working perfectly. The MyQDeviceTypeName has to be VGDO for some reason. Here’s the .py from my github:

https://github.com/Bahnburner/myq/blob/master/myq.py

Thanks! I did try the VGDO change earlier but still couldn’t get it to work. I’ll give it another shot with this exact MyQ.py. When it doesn’t work I don’t even get any logs showing me what might be wrong. Shows that I’ve loaded cover.myq and that’s the extent of it.

That’s the same problem I was running into when I first tried to set it up as well. The file I posted should work. I pulled it straight off my pi.

This is the add-on I’m using.

That’s it! Let me try it now

still nothing. Config below. Any quotes needed around username or password? This didn’t paste in very well but I have the correct spacing in my actual config.

cover:
platform: myq
name: Garage Door Opener
username: username
password: password
brand: chamberlain

Here’s my config:

platform: myq
name: Garage Door
username: !secret myq_user
password: !secret myq_pass
brand: chamberlain

Also, I’m not sure what your setup is, but I’m no a RPi3 with a manual install and rather than put the myq.py in the custom_components folder, I put it directly into /srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/cover

Is there a reason why the myq component from https://github.com/arraylabs/myq is not an official component? It would be easier for folks to install if they would not have to create a custom component.