DEPRECATED. I've now moved to using ESPHome for my garage door controller. See here for my ESPHome configs (specifically look at garage_door.yaml
.
Control and monitor your garage door over MQTT with Home Assistant with an ESP8266, a relay, and a magnetic reed switch.
Uses:
- NodeMCU 1.0 ESP8266 Wifi microcontroller (though I'd probably use a Wemos D1 Mini if I started over.
- 5V relay to trigger the door
- Magnetic reed switch to detect whether the door is open or closed.
- MQTT protocol for communication
- HomeAssistant and Homebridge running on a Raspberry Pi 3 to make it available to HomeKit (Siri)
The electronics are very simple. The relay is switched by a digital output from the microcontroller (the relay board linked above has a transistor to supply the necessary current to the relay). The reed switch is connected to ground and one of the digital inputs (because the ESP8266 has internal pullups, no extra resistor is necessary). Just connect to the normally disconnected side of your relay to the same two wires running to your existing garage door button.
First off you'll need to create a src/secrets.h
. This file is .gitignore
'd so you don't put your passwords on Github.
cp src/secrets.example.h src/secrets.h
Then edit your src/secrets.h
file to reflect your wifi ssid/password and Home Assistant password.
The easiest way to build and upload the code is with the PlatformIO IDE.
The first time you program your board you'll want to do it over USB. After that, programming can be done over wifi. To program over USB, change the upload_port
in the platformio.ini
file to point to the USB-serial device for your board. Probably something like the following will work if you're on a Mac.
upload_port = /dev/tty.cu*
If you're not using the NodeMCU board, you'll also want to update the board
line with your board. See here for other PlatformIO supported ESP8266 board. For example, for the Wemos D1 Mini:
board = d1_mini
After that, from the PlatformIO Atom IDE, you should be able to go to PlatformIO->Upload in the menu.
Configuring Home Assistant
Add the following to your Home Assistant configuration.yaml
file
cover:
- platform: mqtt
name: Garage Door
friendly_name: Garage
state_topic: "garage/door"
command_topic: "garage/button"
payload_open: "OPEN"
payload_close: "OPEN"
payload_stop: "OPEN"
state_open: "OPENED"
state_closed: "CLOSED"
optimistic: false
retain: false
value_template: '{{ value }}'
- Thanks to automatedhome.party's blog post about building something like this. This repo is largely based on that blog post.