substitutions: device_name: couchlight friendly_name: "Couch Light" esphome: name: ${device_name} friendly_name: ${friendly_name} on_boot: then: - lock.template.publish: id: child_lock state: UNLOCKED esp8266: board: d1_mini # Enable logging logger: # Enable Home Assistant API api: encryption: key: !secret api_encryption_key # OTA ota: - platform: esphome password: !secret ota_password # WiFi Credentials wifi: domain: .lan ssid: !secret wifi_ssid password: !secret wifi_password # see https://github.com/esphome/issues/issues/1532 power_save_mode: HIGH # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "${device_name} Fallback Hotspot" password: !secret wifi_ap_password captive_portal: light: - platform: binary id: light1 name: "Spot 1" output: relay_light1 - platform: binary id: light2 name: "Spot 2" output: relay_light2 output: - platform: gpio id: relay_light1 pin: D1 # GPIO5 - platform: gpio id: relay_light2 pin: D2 # GPIO4 # UNUSED GPIO - platform: gpio id: unused_gpio0 pin: number: D3 # GPIO0 mode: INPUT_PULLUP - platform: gpio id: unused_gpio1 pin: number: TX # GPIO1 mode: INPUT_PULLUP - platform: gpio id: unused_gpio2 pin: number: D4 # GPIO2 mode: INPUT_PULLUP - platform: gpio id: unused_gpio3 pin: number: RX # GPIO3 mode: INPUT_PULLUP - platform: gpio id: unused_gpio14 pin: number: D5 # GPIO14 mode: INPUT_PULLUP - platform: gpio id: unused_gpio15 pin: number: D8 # GPIO15 mode: INPUT_PULLUP - platform: gpio id: unused_gpio16 pin: number: D0 # GPIO16 mode: INPUT_PULLDOWN script: - id: reset_child_lock mode: restart then: - delay: 30min - lock.template.publish: id: child_lock state: UNLOCKED binary_sensor: - platform: gpio id: button_light1 name: "Spot 1 PushButton" pin: number: D7 # GPIO13 mode: INPUT_PULLUP filters: - invert - delayed_on: 50ms on_press: then: - if: condition: lock.is_unlocked: child_lock then: - light.toggle: light1 internal: true # hide from UI - platform: gpio id: button_light2 name: "Spot 2 PushButton" pin: number: D6 # GPIO12 mode: INPUT_PULLUP filters: - invert - delayed_on: 50ms on_press: then: - if: condition: lock.is_unlocked: child_lock then: - light.toggle: light2 internal: true # hide from UI lock: - platform: template id: child_lock name: "Child Lock" optimistic: true on_lock: - script.execute: reset_child_lock on_unlock: - script.stop: reset_child_lock