Opengarage, anyone has flashed ESPhome?

In case anyone is interested and finds this older post via search I thought I would show my take on converting the same parts used for the OpenGarage DIY to be used for ESPHome. It doesn’t provide a web page frontend but it does pretty much the same job.

esphome:
  name: garageopener
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "yourwifissid"
  password: "yourwifipassword"

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:


sensor:
  - platform: ultrasonic
    trigger_pin: D6
    echo_pin: D5
    update_interval: 5s
    unit_of_measurement: cm
    accuracy_decimals: 0
    name: "Door Position Sensor"
    # apply a filter to change the distance to cm from metre #
    filters:  
      - multiply: 100
    id: door_sensor
    
  - platform: wifi_signal
    name: "Garage Opener Wifi"
    update_interval: 60s      
    
switch:
  - platform: gpio
    pin: D8
    name: "Garage Door Switch"
    id: open_switch
  # restart gives a switch in HA that can be used to reboot the NodeMCU #  
  - platform: restart
    name: garage opener restart
    id: restart_garage
    
# is the output used to create a buzzer # 
output:
  - platform: esp8266_pwm
    pin: D7
    id: 'buzzer'
  
cover:
  - platform: template
    name: "Garage Door"
    # set the value so that it is higher than value when door is in open state. In my case it reads 5cm so set it at 10cm #
    lambda: !lambda |-
      if (id(door_sensor).state < 10) {
        return COVER_OPEN;
      } else {
        return COVER_CLOSED;
      }
    open_action:
      # Cancel any previous action
      - switch.turn_off: open_switch
      # sound buzzer before door opens
      - output.esp8266_pwm.set_frequency:
          id: buzzer
          frequency: 800Hz
      - output.set_level:
          id: buzzer
          level: 50%
      - delay: 5s
      - output.turn_off: buzzer
      # Turn the OPEN/CLOSE switch/relay on briefly
      - switch.turn_on: open_switch
      - delay: 0.2s
      - switch.turn_off: open_switch
    close_action:
      # Cancel any previous action
      - switch.turn_off: open_switch
      # sound buzzer before door closes
      - output.esp8266_pwm.set_frequency:
          id: buzzer
          frequency: 800Hz
      - output.set_level:
          id: buzzer
          level: 50%
      - delay: 5s
      - output.turn_off: buzzer
      # Turn the OPEN/CLOSE switch/relay on briefly
      - switch.turn_on: open_switch
      - delay: 0.2s
      - switch.turn_off: open_switch
    stop_action:
      - switch.turn_on: open_switch
      - delay: 0.1s
      - switch.turn_off: open_switch
    # don't really need these here since they are set to default values anyway. was using before I got the ultrasonic sensor working #
    optimistic: false
    assumed_state: false
4 Likes