Tutorial for Migrating from MyQ to ESPHome

Disclaimer

I do not have a background in electronics and take no responsibility for damages, but damn this was a fun project. I also like to write way too much, so this will end up longer than it needs to be. Unfortunately I didn’t take many pictures of the process but will provide a wiring diagram. My terminology is likely incorrect in a few places too, so feel free to correct me in the comments.

Background

I’ve noticed there’s quite a few MyQ garage cover users, along with a corresponding number of complaints about their ever-buggy APIs and servers. Consider me part of that list. It worked great about a year ago, but over the last few months my HA logs have been filled with “500 Internal Server” errors, API changes, incorrect statuses, etc. The issues mostly appear to be on MyQ’s end. The other assumption is that you already have MQTT and HA integrated since MQTT is awesome. Best of all, variations of this should work with just about every garage door cover.

Summary

I’ve already got an ESP8266 module in the garage running the excellent esphomeyaml. It reports temperature, humidity, brightness, and most importantly, has a magnetic reed switch connected to the garage cover to let me know if’s open or closed. The wiring for that is outside the scope of this tutorial but there’s plenty of descriptions online. This is feeding MQTT events into Mosquitto and the purpose will become clear in a bit, the primary being the “open” and “closed” status. On top of that, I’m basically out of room on the bread board and can’t add anything else. Plus I’m lazy and don’t feel like disconnecting everything.

The First Problem

Anyways, I’ve got a Chamberlain MyQ Garage Cover Opener. My first though was just using a ESP8266 with a relay to short the terminals found on most garage cover openers. This will typically cause them to open and close. However, I realized this isn’t possible with the new-fangled fancy openers: you can randomly get the light to turn on and off but that’s about it. Further research indicated the opener button on the wall actually passes signal operations to the garage cover opener, not just a simple open or close circuit.

My next thought was to wire an ESP8266 to the wall button itself. Short the button on the opener, make it believe it was pressed, and the garage will open and close. Perfect! Except for the fact there’s no power outlet remotely near that for the ESP8266. The second idea is now DOA.

Potential Solution

I was walking back inside from the garage and attempting to evaluate my options, and noticed the garage remote sitting unused on the shelf. They look something like this. Well, I did use it once to program the garage cover opener in my vehicle, but then it went back on the shelf. Pressed the button, the garage door opened, and I realized I might be able to hack it to work with the ESP8266.

The Prototype

This is the fun part. I’d never worked with relays, let alone solid state relays, and only had a minimal idea of what I was doing. I seriously apologize for not taking a picture of the internals of the remote, but it should be self-explanatory once you see the diagram. Here’s the parts list for what I used:

The Garage Cover Remote

Follow the instructions to pop that bad boy open like you’re changing the battery. You’ll notice 3 momentary switches on the board. The only one that should be a concern is the switch that’s located under the largest physical button. It’ll look something like this:

28

See those two boots that are circled? You can short it by touching them with either end of the same wire. The remote thinks the button has been pushed. You should see the LED on the remote light up and the garage cover should open or close. At this point you’ll want to solder a 6-8" wire on each boot of that particular momentary switch. Please note: this was a pain in the ass. I was using thin wire and ended up putting the solder on the end of the wire, heating up the boot, and touching the wire to it so they attached. You can now run the two wires outside of the remote and snap the cover back on. I made a small cut-out in the remote plastic so they went through unobstructed.

The ESP8266 and Relay

Here’s something I learned about solid state relays: they don’t like to turn off. Even if you disable the relay control, it’ll stay open if there’s any type of current bleeding through. My semi-ghetto solution was to put a resistor inline with each side to prevent this from happening. I’m sure there’s more elegant ways, but it worked for the intended purpose. The end result looks something like this:

The Esphomeyaml Code

Assuming you keep the pins the same as the diagram, you shouldn’t need to make too many modifications to this. There’s a ton of documentation on esphomeyaml. I saved this as nodemcu-garage-remote.yaml and compiled it with esphomeyaml nodemcu-garage-remote.yaml compile. Once it’s compiled, you should see it generate a firmware.bin at the end. You can use WinSCP to copy the file over to Windows and flash it to the ESP8266 with something like PyFlasher.

esphomeyaml:
  name: nodemcu_garage_remote
  platform: ESP8266
  board: nodemcuv2
  arduino_version: dev

wifi:
  ssid: 'WirelessName'
  password: 'WirelessPassword'

mqtt:
  broker: 'mqtt.hostname.local'
  username: 'username'
  password: 'password'

# Enable logging
logger:

ota:

sensor:
  - platform: wifi_signal
    name: "NodeMCU Garage Remote WiFi"

binary_sensor:
  - platform: status
    name: "NodeMCU Garage Remote Status"

switch:
  - platform: gpio
    pin: D5
    name: "NodeMCU Garage Remote Button"
    id: garage_switch

time:
  - platform: sntp
    id: sntp_time
    servers:
      - 0.pool.ntp.org
      - 1.pool.ntp.org
      - 2.pool.ntp.org

You should see the switch appear automagically in HA once the ESP8266 is rebooted. If everything was correct, flipping the switch in HA should cause the remote to trigger. Flipping it again will turn it off. You only need the button enabled for a second or two for the garage cover to open or close.

The HA Scripts

At this point we’re going to use a cover template to turn the esphomeyaml switch into a cover component in HA. We’ll first start with the scripts that are used in the cover template. Please note this is specific to my environment so you might need to customize it a bit. This will go in your scripts.yaml file:

open_garage_door:
  alias: Open Garage Door
  sequence:
  - data:
      entity_id: switch.nodemcu_garage_remote_button
    service: switch.turn_off
  - data:
      entity_id: switch.nodemcu_garage_remote_button
    service: switch.turn_on
  - delay: '00:00:01'
  - data:
      entity_id: switch.nodemcu_garage_remote_button
    service: switch.turn_off
close_garage_door:
  alias: Close Garage Door
  sequence:
  - data:
      entity_id: switch.nodemcu_garage_remote_button
    service: switch.turn_off
  - data:
      entity_id: light.garage
      flash: long
    service: light.turn_on
  - delay: '00:00:05'
  - data:
      entity_id: switch.nodemcu_garage_remote_button
    service: switch.turn_on
  - delay: '00:00:01'
  - data:
      entity_id: switch.nodemcu_garage_remote_button
    service: switch.turn_off
stop_garage_door:
  alias: Stop Garage Door
  sequence:
  - data:
      entity_id: switch.nodemcu_garage_remote_button
    service: switch.turn_off
  - data:
      entity_id: switch.nodemcu_garage_remote_button
    service: switch.turn_on
  - delay: '00:00:05'
  - data:
      entity_id: switch.nodemcu_garage_remote_button
    service: switch.turn_off

That delay and light flash in the close script is just an alert that the garage cover is about to close.

The HA Cover Template

Almost done! This creates the cover component in the UI. Please remember that I have another ESP8266 connected to the garage cover with a magnetic reed switch: that’s the binary_sensor.nodemcu_garage_door in the code. This lets the cover template know if the garage is actually open or close. You could also use something like a tilt sensor and change the values accordingly. There’s lots of options with the cover template.

cover:
  - platform: template
    covers:
      nodemcu_garage_cover:
        friendly_name: "NodeMCU Garage Door"
        open_cover:
          service: script.open_garage_door
        close_cover:
          service: script.close_garage_door
        stop_cover:
          service: script.stop_garage_door
        icon_template: >-
          {% if is_state("binary_sensor.nodemcu_garage_door", "off") %}
            mdi:garage
          {% elif is_state("binary_sensor.nodemcu_garage_door", "on") %}
            mdi:garage-open
          {% else %}
            mdi:help-circle
          {% endif %}
        value_template: >-
          {% if is_state("binary_sensor.nodemcu_garage_door", "off") %}
            Closed
          {% elif is_state("binary_sensor.nodemcu_garage_door", "on") %}
            Open
          {% else %}
            Unknown
          {% endif %}

Again, binary_sensor.nodemcu_garage_door is a separate ESP8266. The value off means the door is closed while the value on means it’s open.

The Final Result!

Hopefully someone finds this useful! Writing this took longer than the actual project :).

5 Likes

I’ll definitely have to try something like this.

I haven’t had many problems with MyQ connectivity but I have had a few (and getting worse recently) and the thought of losing the ability to remotely operate my door due to some external operating requirement that can’t be reliably maintained leaves a bad taste in my mouth.

But, again, I just have to find the time to get it done. Hopefully I get there before the MyQ service goes completely down.

Thanks for the inspiration!

Is there any specific reason you went with an SSR instead of a mechanical relay?

I’d never used a relay before and ordered a few SSRs because they were discounted :). Hell, at first I didn’t even realize it just closes the circuit and doesn’t actually supply power via the 5v connection. It seems to work just fine with the resistors inline though. It was definitely a learning experience but I’m super happy with the end result.

I did have to add a few conditions to my Node-RED automations. In MyQ, if you told the garage to close and it was already closed, then nothing would happen. On the other hand, with the ESP8266 it’ll open or close regardless, e.g. triggering a “close” event when it’s already closed with cause it to open since it’s just pushing the button.

I have two garage door openers (an old school one with no security and the new MyQ one) and I had to do the same with my old style garage door opener. And when I was programming the Echo to respond to ‘open’ or ‘close’ (versus having to use the very awkward ‘on’ or ‘off’) I had to put the condition in that script as well.

Thanks for sharing, coincidentally yesterday I started on the same project! Thanks to your code I was up/running in 45 minutes. I used ESP8266 + 2 relay board + 2 Garage Sensors (previously installed). All working on the breadboard, next step to move it and wire it into the garage doors!

I was originally going to try the esphomelib Cover Template approach (since both sensor / relay-control) are on the same board. Though tempting to stop here since your code is working perfectly. If I do, I’ll post.

Also now that I will have an esp in the Garage I’m also thinking of experimenting with Bluetooth low energy (iBeacons) to do initial presence detection since we always approach the house from the driveway/garage.

Thanks again for taking the time!

1 Like

Glad to help. I started with the cover template in esphomeyaml which worked just fine, but ended up doing it as a template in HA since the open/close reed switch was on another ESP8266. The HA template combines both of them. If it was all on one ESP8266 then I just would have used the esphomeyaml cover template instead.

Funny enough I just ordered two ESP32 boards to try out the BT LE tracking component in esphomeyaml. I might swap out one of the ESP8266 for an ESP32 if I’m happy with the result, seeing that everything is right in the garage and it should see my phone as soon as I get near the house. The Life360 custom component has been working extremely well for that too, although it’s GPS.

Nice job, thanks for sharing. I have a similar setup with a 2 channel MHCOZY listed here. I soldered lines from both channels to two of the three buttons on my Chamberlain remote. See photo here.

The problem is, while it is compatible with Alexa, its not really compatible with HA; therefore, I want to try your solution. On the link you gave for the relay, there is also a two channel relay.

How difficult would you anticipate it would be for me to adapt your design to use that two channel relay to use with my two garage doors?

Dead simple. You’d just duplicate with a different name. In esphomeyaml it’d be something like this:

switch:
  - platform: gpio
    pin: D5
    name: "NodeMCU Garage Remote Button 1"
    id: garage_switch_1
  - platform: gpio
    pin: D6
    name: "NodeMCU Garage Remote Button 2"
    id: garage_switch_2

…with each relay connected to an individual button. Hope this helps.

1 Like

Just to drop back in and say I finally got my garage door project done.

I ended up using a modified Sonoff Basic flashed with Tasmota to trigger the remote control. Since I already had one laying around and it already included a working relay it was a no-brainer. And for the garage door position sensor I used a NodeMCU with an Ulta-sonic sensor connected. And I already had both of those too.

At least all of those “dead end” projects finally paid off by providing me with the spare parts I needed for this project! :laughing:

The most expensive part of the whole project was having to buy a new Chamberlain remote control to butcher up. It ended up costing around $50 total - $30 dollars for the remote, $6 for the sonoff, $6 for the NodeMCU, $2 for the Ultra-sonic sensor and a few bucks for the USB cable & power supply.

Now I just need to find a box to put the sensor in. I’ll probably end up putting it inside of a plastic soap bar box. I used one of those for another NodeMCU project and it works great. And it’s dirt cheap. :wink:

Thanks again for the inspiration.

1 Like

I might try this, but instead use an ESP32 and put it near my Liftmaster gate opener and another esp32 in the car, and use it for presence detection to open the gate!

I did have to add a few conditions to my Node-RED automations. In MyQ, if you told the garage to close and it was already closed, then nothing would happen. On the other hand, with the ESP8266 it’ll open or close regardless, e.g. triggering a “close” event when it’s already closed with cause it to open since it’s just pushing the button.

Any way you could share the Node Red rules/flows?

Yep, here you go.

[{"id":"984ab8ea.adcb88","type":"server-state-changed","z":"95f403a0.029a6","name":"Dryer Power","server":"744f1fa7.a5248","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.dryer_power_template","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":90,"y":760,"wires":[["7c8f9b44.89b774"],[]]},{"id":"6f7fc753.1f8b78","type":"api-call-service","z":"95f403a0.029a6","name":"Open Garage","server":"744f1fa7.a5248","version":1,"debugenabled":false,"service_domain":"cover","service":"open_cover","entityId":"cover.nodemcu_garage_cover","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":480,"y":760,"wires":[[]]},{"id":"ed2dbc34.44425","type":"comment","z":"95f403a0.029a6","name":"Open Garage Door on Dryer","info":"","x":240,"y":700,"wires":[]},{"id":"7c8f9b44.89b774","type":"api-current-state","z":"95f403a0.029a6","name":"Garage Door Contact","server":"744f1fa7.a5248","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.nodemcu_garage_door","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":280,"y":760,"wires":[["6f7fc753.1f8b78"],[]]},{"id":"4390afd1.71bfa","type":"trigger","z":"95f403a0.029a6","name":"30 Minute Trigger","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"30","extend":false,"units":"min","reset":"reset","bytopic":"all","outputs":1,"x":410,"y":300,"wires":[["bb41aa16.864c98"]]},{"id":"4a3c9654.842c78","type":"change","z":"95f403a0.029a6","name":"Reset","rules":[{"t":"set","p":"payload","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":380,"wires":[["4390afd1.71bfa"]]},{"id":"621162d8.18adbc","type":"api-call-service","z":"95f403a0.029a6","name":"Close Garage","server":"744f1fa7.a5248","version":"1","service_domain":"cover","service":"close_cover","entityId":"cover.nodemcu_garage_cover","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":820,"y":300,"wires":[[]]},{"id":"9585c57b.bac618","type":"comment","z":"95f403a0.029a6","name":"Close Garage Door on Inactivity","info":"","x":370,"y":240,"wires":[]},{"id":"d587ce44.509c3","type":"server-state-changed","z":"95f403a0.029a6","name":"FYC Motion","server":"744f1fa7.a5248","version":1,"entityidfilter":"binary_sensor.fyc_motion","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":390,"y":420,"wires":[["4a3c9654.842c78"],[]]},{"id":"bacbe7f5.d8ce08","type":"server-state-changed","z":"95f403a0.029a6","name":"Laundry Room Contact","server":"744f1fa7.a5248","version":1,"entityidfilter":"binary_sensor.sensor_laundry_room_door_contact","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":420,"y":480,"wires":[["4a3c9654.842c78"],[]]},{"id":"5153327c.ed054c","type":"server-state-changed","z":"95f403a0.029a6","name":"Front Door Contact","server":"744f1fa7.a5248","version":1,"entityidfilter":"binary_sensor.sensor_front_door_contact","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":410,"y":540,"wires":[[],[]]},{"id":"8c78b2d0.33ac8","type":"server-state-changed","z":"95f403a0.029a6","name":"FDC Motion","server":"744f1fa7.a5248","version":1,"entityidfilter":"binary_sensor.fdc_motion","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":390,"y":360,"wires":[["4a3c9654.842c78"],[]]},{"id":"3c1987c3.28b9f8","type":"server-state-changed","z":"95f403a0.029a6","name":"Garage Motion","server":"744f1fa7.a5248","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.hue_garage_motion","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":400,"y":600,"wires":[["4a3c9654.842c78"],[]]},{"id":"bb41aa16.864c98","type":"api-current-state","z":"95f403a0.029a6","name":"Garage Door Contact","server":"744f1fa7.a5248","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.nodemcu_garage_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":620,"y":300,"wires":[["621162d8.18adbc"],[]]},{"id":"9339971a.586b68","type":"api-current-state","z":"95f403a0.029a6","name":"FYC Motion","server":"744f1fa7.a5248","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.fyc_motion","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":110,"y":420,"wires":[["4a53eafc.84b8c4"],[]]},{"id":"4a53eafc.84b8c4","type":"api-current-state","z":"95f403a0.029a6","name":"Laundry Room Contract","server":"744f1fa7.a5248","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.sensor_laundry_room_door_contact","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":150,"y":480,"wires":[["d2f29a9.7d42a68"],[]]},{"id":"d2f29a9.7d42a68","type":"api-current-state","z":"95f403a0.029a6","name":"Garage Door Contact","server":"744f1fa7.a5248","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.nodemcu_garage_door","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":140,"y":540,"wires":[["4390afd1.71bfa"],[]]},{"id":"680015ae.87cd6c","type":"poll-state","z":"95f403a0.029a6","name":"Dryer Power","server":"744f1fa7.a5248","version":1,"updateinterval":"15","updateIntervalUnits":"seconds","outputinitially":true,"outputonchanged":false,"entity_id":"binary_sensor.dryer_power_template","state_type":"str","halt_if":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"x":110,"y":360,"wires":[["9339971a.586b68"],[]]},{"id":"744f1fa7.a5248","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]
1 Like

I know this is an old topic, I just bought a new Chamberlin opener and as mentioned above my ESP32/relay solution stopped working. I’m thinking of trying this solution and was wondering if anyone knows if it will still work with the new openers, my opener only has one button?

Thanks,
Rob

There’s been several discussions about Chamberlin in the last few months. The latest centers around a device known as RATGDO. A thread about the device is here. Details regarding the device are available here.

Thanks, I will take a look.