Skip to content

Instantly share code, notes, and snippets.

@aceat64
Created October 22, 2021 18:48
Show Gist options
  • Save aceat64/11ea08891827bbb97905ae9d61048b6f to your computer and use it in GitHub Desktop.
Save aceat64/11ea08891827bbb97905ae9d61048b6f to your computer and use it in GitHub Desktop.
esphome light switch
substitutions:
device_name: back-yard-flood
friendly_name: Back Yard Flood
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
esp8266_restore_from_flash: true
wifi:
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:
output:
- platform: gpio
pin: GPIO12
id: power
- platform: gpio
pin: GPIO5
inverted: true
id: led1
light:
- platform: binary
name: ${friendly_name}
output: power
id: powerswitch
on_turn_on:
- output.turn_on: led1
on_turn_off:
- output.turn_off: led1
status_led:
pin:
number: GPIO4
inverted: true
binary_sensor:
- platform: gpio
pin:
number: GPIO13
mode: INPUT_PULLUP
internal: true
id: main_button
on_press:
- light.toggle: powerswitch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment