Cheap and Easy Home Assistant Garage Door Control

Home Assistant is the main method I use for opening my garage (other than the integrated remote in my car). I’ve had this setup for the better part of a year and thought I would share it in case it helps anyone else control their garage door. This hardware has been running with Tasmota firmware for the bulk of that time and recently I’ve discovered ESPHome and have converted this guy. And while there are plenty of DIY tutorials for garage door control, I think this is the simplest to get up and running. The parts list is very basic:

Wemos D1 Mini – The Wemos D1 Mini is an ESP8266 based microcontroller that will handle the heavy lifting of WiFi and communicating to your Home Assistant instance [AliExpress | Amazon] Wemos Relay Shield – The Relay Shield will perform the physical function of closing the circuit on the garage opener to activate it [AliExpress | Amazon ] Wemos DHT shield – I added the DHT to get temperature and humidity data [AliExpress | Amazon ] Wired Reed Switch – A magnetic reed switch that will provide state of the door [AliExpress | Amazon ] LM2596S DC-DC power regulator – It converts garage door’s 12V DC to 5V DC for the Wemos or use a microUSB cable. [AliExpress | Amazon ]

I buy my stuff from AliExpress because it’s so cheap that it’s basically free as long as you can put up with month-long shipping. I think all of these combined were about 10 bucks. When you finally get these parts from China, you will need to solder the Wemos headers together so you can stack them. My relay shield was on GPIO5, the DHT shield was on GPIO2, and I connected the reed switch on GPIO13. My garage door opener has an option for a backup battery, and the connection for this battery provides a 12v DC output when the garage door opener is powered up. So while I could have powered the Wemos thought a micro USB and a wall wart, I just got the DC-DC power regular. I connected it to the garage door and used a multimeter to adjust it’s potentiometer to a 5v output and then connected the ground and 5v to the Wemos.

Installation is pretty straight forward, you connect the garage door opener’s control contact (same ones where your local button is wired) to the common and normally open contacts of the relay. I’ll eventually post some pictures, but I don’t have any right now.

I’m not going to go through the details of setting up ESPHome. You can watch either Rob’s or digiblur’s videos to get a good explanation on it. Once you have it up and running, you will need to create a new device by populating the name and WiFi details. Here is my config:

esphome: name: esphome_garage_door platform: ESP8266 board: d1_mini wifi: ssid: 'insert' password: 'your_own' fast_connect: on api: ota: web_server: port: 80 logger: binary_sensor: - platform: gpio pin: number: GPIO13 mode: INPUT_PULLUP inverted: False name: "Garage Door Sensor" device_class: garage_door filters: - delayed_on: 20ms sensor: - platform: dht pin: GPIO2 temperature: name: "Garage Temperature" filters: - lambda: return x * (9.0/5.0) + 32.0; unit_of_measurement: "°F" humidity: name: "Garage Humidity" update_interval: 60s model: AM2302 switch: - platform: gpio id: relay pin: number: GPIO5 inverted: False restore_mode: ALWAYS_OFF - platform: template name: "Garage Door Switch" icon: "mdi:garage" turn_on_action: - switch.turn_on: relay - delay: 1s - switch.turn_off: relay - platform: restart name: 'Garage Door REBOOT' status_led: id: status_led pin: number: GPIO2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 esphome : name : esphome_garage_door platform : ESP8266 board : d1_mini wifi : ssid : 'insert' password : 'your_own' fast_connect : on api : ota : web_server : port : 80 logger : binary_sensor : - platform : gpio pin : number : GPIO13 mode : INPUT_PULLUP inverted : False name : "Garage Door Sensor" device_class : garage_door filters : - delayed_on : 20ms sensor : - platform : dht pin : GPIO2 temperature : name : "Garage Temperature" filters : - lambda : return x * (9.0/5.0) + 32.0; unit_of_measurement : "°F" humidity : name : "Garage Humidity" update_interval : 60s model : AM2302 switch : - platform : gpio id : relay pin : number : GPIO5 inverted : False restore_mode : ALWAYS_OFF - platform : template name : "Garage Door Switch" icon : "mdi :garage" turn_on_action : - switch . turn_on : relay - delay : 1s - switch . turn_off : relay - platform : restart name : 'Garage Door REBOOT' status_led : id : status_led pin : number : GPIO2

The components above include

A binary sensor component for the reed switch input

A sensor component for the DHT temp and humidity

A switch gpio component for the relay

A switch template for the pulsed output imitating a momentary button press

A switch restart component to reboot the Wemos

A status LED component for indicating networking/error status.

Now can compile the firmware and flash it to your Wemos D1. Again, if you’re not familiar with how to do this, reference the videos linked above. Once it’s flashed, power cycle the device. Now you should be able to open the web gui for the device by either going to it’s IP or going to esphome_garage_door.local in your browser. When the page loads up, you should test out the Garage Door Switch by hitting the button next to it. If when you open the Garage Door Sensor changes state, then everything is working as it should.

Now to integrate it into Home Assistant, you will need to go to configuration > integratios. Assuming you have discovery enabled, you will have a new ESPHome device, click configure and add it to your system. In theory, if you don’t have any existing conflicting entities, your entity names should match the ones I have (If not, post in the comments and I’ll try to help). I’m using lovelace with the following config:

- type: horizontal-stack title: Doors show_header_toggle: false cards: # I have other doors here - type: entity-button name: Garage tap_action: action: call-service service: homeassistant.turn_on service_data: entity_id: switch.garage_door_switch hold_action: action: more-info entity: binary_sensor.garage_door_sensor 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - type : horizontal-stack title : Doors show_header_toggle : false cards : # I have other doors here - type : entity-button name : Garage tap_action : action : call-service service : homeassistant.turn_on service_data : entity_id : switch.garage_door_switch hold_action : action : more-info entity : binary_sensor.garage_door_sensor

This provides you with a simple button who’s icon shows you the state of the door.

Because I’ve forgotten to close the door a few times, I’ve also set up an alert on the door to notify my phone when the door is open for more than 10 minutes:

alert: garage_door: name: Garage is open done_message: Garage is closed entity_id: binary_sensor.garage_door_sensor state: 'on' repeat: 10 can_acknowledge: true skip_first: true notifiers: - your_ios_identifier 1 2 3 4 5 6 7 8 9 10 11 alert : garage_door : name : Garage is open done_message : Garage is closed entity_id : binary_sensor.garage_door_sensor state : 'on' repeat : 10 can_acknowledge : true skip_first : true notifiers : - your _ ios _ identifier

A word about security. This setup means that anyone with access to your WiFi network could open your garage door. This would also assume the intruder is on your WiFi, knows the name or the IP of the device, the fact that it’s running a web server, and could connect to it to open your garage door. Personally, I tightly control the people that have access to my network so it’s not a big concern for me. The likely hood of that happening seems lower than someone breaking a window on my house.