Esphome配置

esphome:
  name: hot-water

esp8266:
  board: esp01

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "QfP78UCAKC0dab/VIWt5hleR9mNIoISMv6A7vgmVZq8="

ota:
  password: "35d78fc74b970fd454a16898ca0f1efe"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Hot-Water Fallback Hotspot"
    password: "93gCTm1aK3JT"

captive_portal:

switch:
 - platform: gpio
   pin: 0
   name: "hot-water-switch"
   id: "hot_water"

binary_sensor:
 - platform: gpio
   pin: 
     number: 2
     mode: INPUT_PULLUP
   name: "hot-water-sensor"
   filters:
     - delayed_on_off: 300ms
   on_state:
     then:
       - switch.toggle: "hot_water"