Skip to content

Instantly share code, notes, and snippets.

@aceat64
Created March 10, 2022 22:38
Show Gist options
  • Save aceat64/85bf858d44b2d340195a9aad9cb8e9c5 to your computer and use it in GitHub Desktop.
Save aceat64/85bf858d44b2d340195a9aad9cb8e9c5 to your computer and use it in GitHub Desktop.
substitutions:
device_name: garage-door
friendly_name: Garage Door
esphome:
name: ${device_name}
platform: ESP32
board: featheresp32
wifi:
manual_ip:
static_ip: 192.168.xxx.xxx
gateway: 192.168.xxx.xxx
subnet: 255.255.255.0
dns1: 192.168.xxx.xxx
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${device_name}
password: !secret fallback_password
captive_portal:
# Enable logging
logger:
# Make sure logging is not using the serial port
baud_rate: 0
# Enable Home Assistant API
api:
ota:
binary_sensor:
- platform: gpio
pin:
number: A0
mode: INPUT_PULLUP
name: "Garage Door Contact Sensor"
id: contact_sensor
internal: true
switch:
- platform: gpio
pin: A1
name: "Garage Door Relay"
id: relay
internal: true
cover:
- platform: template
device_class: garage
name: ${friendly_name}
lambda: |-
if (id(contact_sensor).state) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
open_action:
- switch.turn_on: relay
- delay: 0.5s
- switch.turn_off: relay
close_action:
- switch.turn_on: relay
- delay: 0.5s
- switch.turn_off: relay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment