Skip to content

Instantly share code, notes, and snippets.

@bbbenji
Last active December 30, 2021 23:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbbenji/05074c1fba9dc67ac7a99fbaaf1a08f6 to your computer and use it in GitHub Desktop.
Save bbbenji/05074c1fba9dc67ac7a99fbaaf1a08f6 to your computer and use it in GitHub Desktop.
# GPIO0
# GPIO1
# GPIO2
# GPIO3 Button middle
# GPIO4 Button left
# GPIO5 Button right
# GPIO12 Relay/LED red left
# GPIO13 LED green (all)
# GPIO14 Relay/LED red middle
# GPIO15 Relay/LED red Right
# GPIO16
esphome:
name: switch_01
platform: ESP8266
board: esp01_1m
<<: !include .common.yaml
# Status LED
status_led:
pin:
number: GPIO13
inverted: false
binary_sensor:
- platform: gpio
pin:
number: GPIO4
mode: INPUT_PULLUP
inverted: true
name: "switch_01 Button Left"
on_press:
if:
condition:
api.connected:
then:
- switch.turn_on: relay_1
- homeassistant.service:
service: light.toggle
data:
entity_id: light.bulb_1
else:
- switch.toggle: relay_1
- platform: gpio
pin:
number: GPIO3
mode: INPUT_PULLUP
inverted: true
name: "switch_01 Button Middle"
on_press:
if:
condition:
api.connected:
then:
- switch.turn_on: relay_2
- homeassistant.service:
service: light.toggle
data:
entity_id: light.bulb_2
else:
- switch.toggle: relay_2
- platform: gpio
pin:
number: GPIO5
mode: INPUT_PULLUP
inverted: true
name: "switch_01 Button Right"
on_press:
if:
condition:
api.connected:
then:
- switch.turn_on: relay_3
- homeassistant.service:
service: light.toggle
data:
entity_id: light.bulb_3
else:
- switch.toggle: relay_3
switch:
- platform: gpio
name: "switch_01 Relay Left"
pin: GPIO12
id: relay_1
inverted: false
- platform: gpio
name: "switch_01 Relay Middle"
pin: GPIO14
id: relay_2
inverted: false
- platform: gpio
name: "switch_01 Relay Right"
pin: GPIO15
id: relay_3
inverted: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment