You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
936 B
48 lines
936 B
4 months ago
|
substitutions:
|
||
|
button_action: sonoff_button_toggle_relay
|
||
|
relay_on_action: nullScript
|
||
|
relay_off_action: nullScript
|
||
|
|
||
|
esphome:
|
||
|
board: esp8285
|
||
|
platform: ESP8266
|
||
|
name: ${hostname}
|
||
|
build_path: ./build/${hostname}
|
||
|
|
||
|
packages:
|
||
|
base: !include ../common/base.yaml
|
||
|
basicSensors: !include ../common/basicSensors.yaml
|
||
|
|
||
|
switch:
|
||
|
- platform: gpio
|
||
|
name: "${friendly_name} Relay"
|
||
|
id: relay
|
||
|
pin: GPIO12
|
||
|
restore_mode: RESTORE_DEFAULT_OFF
|
||
|
on_turn_on:
|
||
|
then:
|
||
|
- script.execute: "${relay_on_action}"
|
||
|
on_turn_off:
|
||
|
then:
|
||
|
- script.execute: "${relay_off_action}"
|
||
|
|
||
|
binary_sensor:
|
||
|
- platform: gpio
|
||
|
pin:
|
||
|
number: GPIO0
|
||
|
mode: INPUT_PULLUP
|
||
|
inverted: True
|
||
|
name: "${friendly_name} Button"
|
||
|
on_press:
|
||
|
then:
|
||
|
- script.execute: "${button_action}"
|
||
|
|
||
|
|
||
|
script:
|
||
|
- id: sonoff_button_toggle_relay
|
||
|
then:
|
||
|
- switch.toggle: relay
|
||
|
- id: nullScript
|
||
|
then:
|
||
|
|