Skip to main content

Dual Garage Door Opener

Using ESPHome

This is code for dual garage door opener and will show red when door is opened

Dashboard

image.png

This is built using a

ESP32

and some magnet switches

REED

The REED is only one per door

substitutions:
  name: sfl-garage-001
  friendly_name: SFL-GARAGE-001

esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}

esp32:
  board: esp32dev
  framework:
    type: esp-idf

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: "Sfl-Garage-001 Fallback Hotspot"
    password: "xxx"

api:
  encryption:
    key: "xxxxxx"

ota:
  - platform: esphome
    password: "xxxxx"

logger:
  level: ERROR

web_server:
  port: 80

bluetooth_proxy:
  active: true

captive_portal:

# --- Relays (momentary button press) ---
switch:
  - platform: gpio
    pin: GPIO25
    inverted: true
    name: "Door 1 Button"
    id: garage_button_1
    on_turn_on:
      - delay: 500ms
      - switch.turn_off: garage_button_1

  - platform: gpio
    pin: GPIO32
    inverted: true
    name: "Door 2 Button"
    id: garage_button_2
    on_turn_on:
      - delay: 500ms
      - switch.turn_off: garage_button_2

# --- Reed Switches ---
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO05
      mode: INPUT_PULLUP
      inverted: false
    name: "Door 1 Sensor"
    id: garage_sensor_1
    device_class: garage_door
    icon: "mdi:garage"
    filters:
      - delayed_on: 100ms
      - delayed_off: 100ms

  - platform: gpio
    pin:
      number: GPIO04
      mode: INPUT_PULLUP
      inverted: false
    name: "Door 2 Sensor"
    id: garage_sensor_2
    device_class: garage_door
    icon: "mdi:garage"
    filters:
      - delayed_on: 100ms
      - delayed_off: 100ms

# --- Garage Door Covers ---
cover:
  - platform: template
    name: "Door 1"
    device_class: garage
    optimistic: false
    lambda: |-
      if (id(garage_sensor_1).state) {
        return COVER_CLOSED;
      } else {
        return COVER_OPEN;
      }
    open_action:
      - switch.turn_on: garage_button_1
    close_action:
      - switch.turn_on: garage_button_1
    stop_action:
      - switch.turn_on: garage_button_1

  - platform: template
    name: "Door 2"
    device_class: garage
    optimistic: false
    lambda: |-
      if (id(garage_sensor_2).state) {
        return COVER_CLOSED;
      } else {
        return COVER_OPEN;
      }
    open_action:
      - switch.turn_on: garage_button_2
    close_action:
      - switch.turn_on: garage_button_2
    stop_action:
      - switch.turn_on: garage_button_2