Based on my experience I can recommend the following ESPHome config that uses the OG hardware and pin layout.
Very fast response and rock solid.
He had the code in several files. I consolidated the files into a single esphome yaml file to suit my needs.
#https://github.com/gabe565/esphome-configs/blob/c3d0aa4e88b63ea05b97cdc2309f7d69b0b36738/opengarage/packages/opengarage.yaml
substitutions:
# For Home Assistant entity_id, hostname, etc.
device_id: garage_door
# Pretty name to show for entities in Home Assistant
device_name: Garage Door
# entity_id of the vehicle in Home Assistant
vehicle_id: car
# Pretty name of the vehicle in Home Assistant
vehicle_name: Car in Garage
# Length of time that the relay should stay active.
# Some garage doors need the relay to stay active for longer.
# Longer values can slow down when button presses respond.
# For example, if you open the door, then quickly try to stop/close it,
relay_click_time: 500ms
# Height at which the door is considered open.
# Should be slightly larger than the distance from the ceiling to the door.
# Must be lower than the car threshold.
# Entered in cm.
door_threshold: '72'
# Height at which the car is considered to be home.
# Should be slightly larger than the distance from the ceiling to the top of the car.
# Must be higher than the door threshold.
# Entered in cm.
car_threshold: '175'
# Length of time time between distance sensor updates.
# Lower values will detect changes more quickly, but could result in increased noise.
distance_update_interval: 500ms
# Length of time to leave the pulse pin active
distance_pulse_time: 20us
# SR04 sensors can be noisy. The median is taken to prevent noisy data.
# Higher values will slow down the distance sensor's responsiveness,
# but will result in more consistent data.
# See https://esphome.io/components/sensor/index.html#median
distance_median_window_size: '31'
# When the first value should be sent. Must be lower than the distance_median_window_size.
distance_median_send_first_at: '5'
# Sound the alarm on open/close
# RTTL format references:
# - https://esphome.io/components/rtttl.html?highlight=rtttl#common-beeps
# - https://en.wikipedia.org/wiki/Ring_Tone_Transfer_Language
open_alarm: 'false'
open_alarm_rtttl: 'two_short:d=4,o=6,b=100:c,p,c'
# open_alarm_rtttl: 'long:d=1,o=6,b=100:c'
# open_alarm_rtttl: 'open_pulse:d=16,o=5,b=100:c,c6,p.,c,c6,p.,c,c6,p.'
# open_alarm_rtttl: 'open_slide:d=128,o=5,b=100:c,d,e,g,4c6.,4p,c,d,e,g,4c6.,4p'
close_alarm: 'false'
close_alarm_rtttl: 'two_short:d=4,o=5,b=100:c,p,c'
# close_alarm_rtttl: 'long:d=1,o=5,b=100:c'
# close_alarm_rtttl: 'close_pulse:d=16,o=5,b=100:c6,c,p.,c6,c,p.,c6,c,p.'
# close_alarm_rtttl: 'close_slide:d=128,o=5,b=100:c6,g,e,d,4c.,4p,c6,g,e,d,4c.,4p'
esphome:
name: opengarage
platform: ESP8266
board: esp01_1m
wifi:
ssid: 'your-ssid'
password: 'yoursupersecretpassword'
manual_ip:
static_ip: x.x.x.x #device ip
gateway: x.x.x.x #gateway ip
subnet: 255.255.255.0
dns1: 8.8.8.8
dns2: 8.8.4.4
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "OpenGarage Hotspot"
password: "yourfallbackhotspotpassword"
captive_portal:
logger:
level: error
ota:
# password:
binary_sensor:
- platform: status
name: $device_name Status
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
id: physical_button
on_press:
- switch.turn_on: relay
- platform: status
name: $device_name Status
- platform: template
name: $vehicle_name
device_class: presence
lambda: |-
if ($car_threshold < id(distance).state) {
return false;
}
if ($door_threshold < id(distance).state) {
return true;
}
return {};
on_state:
- then:
- homeassistant.service:
service: device_tracker.see
data:
dev_id: $vehicle_id
host_name: $vehicle_name
data_template:
location_name: '{{ location_name }}'
variables:
location_name: 'return x ? "home" : "not_home";'
cover:
- platform: template
name: $device_name
id: garage_door_cover
device_class: garage
lambda: 'return id(distance).state < $door_threshold ? COVER_OPEN : COVER_CLOSED;'
open_action:
- if:
condition:
lambda: 'return id(garage_door_cover).position == COVER_CLOSED;'
then:
- if:
condition:
lambda: 'return $open_alarm;'
then:
- rtttl.play:
rtttl: $open_alarm_rtttl
- wait_until:
not: rtttl.is_playing
- switch.turn_on: relay
close_action:
- if:
condition:
lambda: 'return id(garage_door_cover).position == COVER_OPEN;'
then:
- if:
condition:
lambda: 'return $close_alarm;'
then:
- rtttl.play:
rtttl: $close_alarm_rtttl
- wait_until:
not: rtttl.is_playing
- switch.turn_on: relay
sensor:
- platform: ultrasonic
trigger_pin: GPIO12
echo_pin: GPIO14
name: $device_name Distance
id: distance
update_interval: $distance_update_interval
unit_of_measurement: cm
pulse_time: $distance_pulse_time
timeout: 3m
filters:
# Sets the value to the max if the sensor times out
- lambda: 'return isnan(x) ? 3 : x;'
# Take median of the last 5 values
- median:
window_size: $distance_median_window_size
send_first_at: $distance_median_send_first_at
# Convert m to cm
- multiply: 100
- delta: 1
- platform: wifi_signal
name: $device_name RSSI
update_interval: 5min
filters:
- median:
window_size: 5
status_led:
pin:
number: GPIO2
inverted: true
switch:
- platform: gpio
pin: GPIO15
id: relay
restore_mode: ALWAYS_OFF
on_turn_on:
# Only pulse on for $relay_click_time
- delay: $relay_click_time
- switch.turn_off: relay
output:
- platform: esp8266_pwm
pin: GPIO13
id: buzzer_pwm
rtttl:
output: buzzer_pwm
api:
services:
- service: play_rtttl
variables:
song_str: string
then:
- rtttl.play:
rtttl: !lambda 'return song_str;'