substitutions:
  device_name: sonoffmini_2
  device_ip: 192.168.87.42

esphome:
  name: ${device_name}
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "Meneely"
  password: "punxsutawney1"
  manual_ip:
    static_ip: ${device_ip}
    gateway: 192.168.86.1
    subnet: 255.255.255.0
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "ESPHOME"
    password: "12345678"

logger:
  
api:
  reboot_timeout: 15min

ota:

# the web_server & sensor components can be removed without affecting core functionaility.

web_server:
  port: 80

sensor:
  - platform: wifi_signal
    name: ${device_name} Wifi Signal Strength
    update_interval: 60s
  - platform: uptime
    name: ${device_name} Uptime

#######################################
# Device specific Config Begins Below #
#######################################

binary_sensor:
  - platform: gpio
    pin: GPIO00 # The built-in switch
    id: reset
    internal: true
    filters:
      - invert:
      - delayed_off: 10ms
    on_press:
      - switch.toggle:
          id: relay_1

  - platform: gpio
    name: ${device_name}_status
    pin: GPIO04 # The external terminals
    id: switch_1
    filters:
      - delayed_on: 100ms
    on_press:
      then:
        - switch.toggle:
            id: relay_1
            #    on_release:
            #      then:
            #        - switch.toggle:
            #            id: relay_1

switch:
  - platform: gpio
    name: ${device_name}_switch
    icon: "mdi: lightbulb_outline"
    pin: GPIO12
    id: relay_1
    restore_mode: restore_default_off

status_led:
  pin:
    number: GPIO13
    inverted: true

output:
  - platform: esp8266_pwm
    id: blue_led
    pin: GPIO13
    inverted: True

light:
  # the 4 lines below define the Blue LED light on Sonoff Mini, to expose in HomeAssistant remove line "internal: true"
  - platform: monochromatic
    name: ${device_name}_blueled
    output: blue_led
    internal: true # hides the Blue LED from HomeAssistant
