Myq componenet issues

Awesome,
Now I have the wink doors and the HA doors. How do I tell which one is which? Will this accept customizations to allow for renaming the doors in HA?

several users have posted this above.

although i didnt need it since the script was able to read my names from MyQ. This is how you would do it.

Yea, the main problem was figuring out which was which. I have two doors, so when I loaded this, I had 4 covers showing up, two with single_door for a name and two with two_door for a name. The _2 at the end didn’t really help tell me which one was which. So I renamed one set and then tried to see which one opened the door and which ones were from Wink and just showed the status. Got it now. On to other problems. :slight_smile:
Thanks for chasing this down. It made it much easier for me to get it working.

For anyone interested, if you use the following in your Wink config you will be able to control your garage door. The limitation was put in place by Wink at the request of Chamberlain to restrict control of third party applications. By using the following client_id and client_secret all requests going to the Wink API will appear to be coming form the official Wink Android application.

*Note: Wink could make a change at any time to “break” this.

    client_id: quirky_wink_android_app
    client_secret: e749124ad386a5a35c0ab554a4f2c045
2 Likes

The component should use the name you have configured in the MyQ app, change it there and it should update the next time you restart HA.

Hi folks,
I found an easy way to integrate liftmaster with homeassistant. Assuming you have the Liftmaster Internet bridge and have configured it on the liftmaster site with a username and password, you can use this simple but awesome program(https://github.com/Einstein42/myq-garage/) by Einstein42 to connect to home assistant. No need to dabble with wink or suffer the grief described here. Here is a brief summary of what I did.

  1. Install the program code as described on the link on your home assistant server.
  2. Configure the username and password in config.ini. NOTE: Leave the brand as Chamberlin. (Do not change it to Liftmaster)
  3. Test the program. You should be able to run the command

myq-garage.py status

to get the ID of your garage door and

myq-garage.py start
myq-garage.py stop
4. Now add the following configuration to your YAML

cover:

  • platform: command_line
    covers:
    garage_door:
    friendly_name: Garage Door myq-garage
    command_open: /myq-garage.py open
    command_close: /myq-garage.py close
    command_state: /myq-garage.py status | awk ‘{print $5}’
    value_template: >
    {% if value == ‘Open.’ %}
    100
    {% else %}
    0
    {% endif %}
  1. Reboot and test. You should now be able to work your liftmaster garage door with HomeAssistant.

Special thanks to James Milne (https://github.com/Einstein42) for this awesome program. Hope this help all of you.

1 Like

Great job rajivram! I have followed your steps, but cannot get Home Assistant to locate the may-garage.py app. It works in terminal to open and close the doors, but gives me the message: “/bin/sh: 1: /myq-garage.py: not found”. I’ve searched the Home Assistant docs, but can’t seem to find a reference to where the .py files are to be located. I am using the (homeassistant_venv) installation. Thanks for any help you can provide!

Apologies. My bad. Please include the whole absolute path to your myq-garage(The path where you installed myq-garage on your system). These are my commands.

/home/rajivram/myq-garage/myq-garage.py open “My Garage Door”
/home/rajivram/myq-garage/myq-garage.py close “My Garage Door”
/home/rajivram/myq-garage/myq-garage.py status | awk ‘{print $5}’

Thanks for setting me straight! I am just getting started with hass and am trying to find my way around.

@rajivram I’m trying to set up this command_line cover as you’ve laid out. I can get everything working from the command line in the location where I’ve configured the script (/home/pi/myq-garage), but I seem to need to run it like sudo python /home/pi/myq-garage/myq-garage.py open "Garage Door Opener" for it to work. This does not however seem to work in hass, as nothing happens. I get the following error in hass:

homeassistant.components.cover.command_line: Command failed: sudo python /home/pi/myq-garage/myq-garage.py open "Garage Door Opener"

This is my config:

cover:
  - platform: command_line
    covers:
      garage_door:
        friendly_name: Garage Door myq-garage
        command_open: sudo python /home/pi/myq-garage/myq-garage.py open "Garage Door Opener"
        command_close: sudo python /home/pi/myq-garage/myq-garage.py close "Garage Door Opener"
        command_state: sudo python /home/pi/myq-garage/myq-garage.py status | awk '{print $5}' 
        value_template: >
          {% if value == 'Open.' %}
          100
          {% else %}
          0
          {% endif %}

@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.