Assuming you have a regular garage door opener and want to upgrade it with smart capabilities. For example to open and close the garage door from your smart phone, check the state if it is open or closed, and get a notification when it opens when you are away. Just add an ESP node with a relay and some magnet sensors and program it to do that.
Work in progress below.
Hardware
This project is based on the following components:
- Lolin D1 mini
- USB charger and cable
- Relay module 5 V (link
)
- Magnet sensor, 2 sets (link
)
- Resistor 100 ohm, 2 pieces
- Resistor 10k ohm, 2 pieces
- Signal cable with 4 leads (link
)
Programming of the ESP node is done with ESPHome.
Wiring
The components are connected to the ESP node according to the following wiring diagram.

Programming
Adapt the following program to suit your installation and upload to the ESP node. Replace the listed strings in the code to suit your specific setup:
- NODE_NAME
- NODE_NAME_API_KEY
- NODE_NAME_OTA_PASSWORD
- WIFI_NAME
- WIFI_PASSWORD
- NODE_NAME_FALLBACK_WIFI
- NODE_NAME_FALLBACK_PASSWORD
# Garage Door Control
# Version 0.1
esphome:
name: NODE_NAME
platform: ESP8266
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "NODE_NAME_API_KEY"
# Enable Over the Air updates
ota:
- platform: esphome
password: "NODE_NAME_OTA_PASSWORD"
# Configure primary and fallback WiFi
wifi:
ssid: "WIFI_NAME"
password: "WIFI_PASSWORD"
ap:
ssid: "NODE_NAME_FALLBACK_WIFI"
password: "NODE_NAME_FALLBACK_PASSWORD"
captive_portal:
# Web server settings
web_server:
port: 80
ota: false
# Remote board switches
switch:
- platform: restart
name: "NODE_NAME reboot node"
# - platform: shutdown
# name: "NODE_NAME shutdown node"
# Relay definition
- platform: gpio
pin:
number: GPIO4
mode:
output: true
id: gd_relay
name: "Garage Door Relay"
icon: "mdi:gate"
on_turn_on:
- delay: 800ms
- switch.turn_off: gd_relay
# System sensors
text_sensor:
- platform: wifi_info
ip_address:
name: "NODE_NAME IP"
icon: "mdi:ip-network-outline"
mac_address:
name: "NODE_NAME MAC"
icon: "mdi:network-outline"
# End stop definitions
binary_sensor:
- platform: gpio
pin:
number: GPIO12
mode:
input: true
id: gd_open_sensor
name: "Garage Door Open"
filters:
- delayed_on_off: 400ms
- platform: gpio
pin:
number: GPIO13
mode:
input: true
id: gd_closed_sensor
name: "Garage Door Closed"
filters:
- delayed_on_off: 400ms
Integration
Finally adapt the following to integrate the new smart garage door opener with your Home Assistant installation.