This setup was used to replace the code on my GarHage garage door open setup that I have used for 2 years. That project has not been support and OTA never worked. I got sick of pulling it off the ceiling in my garage to flash it if I made changes.
In comes ESPHome. I am super happy with how easy ESPHome is to use and how well it works. I use it inside of Home Assistant which makes adding to my smart home a breeze.
I will add a description of my build of the the hardware later, but for now my code is below.
My use case for this device is I control two seperate garage doors from the same NodeMcu. My openers are also Security+ 2.0, so I wired my relays into a remote opener. You could also wire into the key pad if you dare.
Note: I am using secrets in HA and substitutions in ESPHome.
ubstitutions:
friendly_name: Shop Garage Doors
esphome:
name: shop_garage_doors
platform: ESP8266
board: nodemcuv2
wifi:
ssid: !secret Not_Wifi_SSID
password: !secret Not_Wifi_Password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Shop Gargae Doors Hotspot"
password: !secret Main_Wifi_Password
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret esphome_api_password
ota:
password: !secret esphome_api_password
# The door contact sensor.
# Not exposed to HA, instead used to set the
# state of the cover.
binary_sensor:
- platform: gpio
pin:
number: D5
mode: INPUT_PULLUP
name: "Middle Stall Garage Door Contact Sensor"
id: contact_sensor
internal: true
- platform: gpio
pin:
number: D6
mode: INPUT_PULLUP
name: "End Stall Garage Door Contact Sensor"
id: contact_sensor_2
internal: true
# The relay that will deliver the pulse to
# the garage door opener (not exposed to HA)
switch:
- platform: gpio
pin: D2
name: "Middle Stall Door Relay"
id: relay
internal: true
- platform: gpio
pin: D1
name: "End Stall Door Relay"
id: relay_2
internal: true
# This creates the actual garage door in HA. The state is based
# on the contact sensor. Opening/closing the garage door simply
# turns the relay on/off with a 0.5s delay in between.
cover:
- platform: template
device_class: garage
name: "Middle Stall Garage Door"
id: template_cov
lambda: |-
if (id(contact_sensor).state) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
open_action:
- switch.turn_on: relay
- delay: 0.3s
- switch.turn_off: relay
close_action:
- switch.turn_on: relay
- delay: 0.3s
- switch.turn_off: relay
- platform: template
device_class: garage
name: "End Stall Garage Door"
id: template_cov_2
lambda: |-
if (id(contact_sensor_2).state) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
open_action:
- switch.turn_on: relay_2
- delay: 0.3s
- switch.turn_off: relay_2
close_action:
- switch.turn_on: relay_2
- delay: 0.3s
- switch.turn_off: relay_2
sensor:
# Send WiFi signal strength & uptime to HA
- platform: wifi_signal
name: $friendly_name WiFi Strength
update_interval: 60s
- platform: uptime
name: $friendly_name "Uptime"
# Send IP Address to HA
text_sensor:
- platform: wifi_info
ip_address:
name: $friendly_name IP Address