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:
- (x1) A breadboard. I like to solder but a standard push-pin one should work just fine. You just need a small one.
- (x1) An ESP8266 module.
- (x1) A 5v Solid State Relay. A mechanical one should work just fine too.
- (x1) A remote, which you should already have.
- (x1) Box o’ Resistors. Please note that you actually only need two resistors. I used 220 ohms because I’m horrible at math and they worked as expected. I read somewhere else to use 10K but it didn’t seem to make a difference.
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:
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 :).