Sonoff BASIC R1 with ESPhome

ESPhome configuration (sonoff_bassic_r1.yaml)

esphome:
  name: sonoff-basic-r1
 
esp8266:
  board: esp01_1m
 
wifi:
  networks:
    - ssid: !secret wifi_ssid
      password: !secret wifi_password
    - ssid: !secret wifi_ssid_2
      password: !secret wifi_password_2
 
  ap:
    ssid: "Sonoff Basic Fallback"
    password: ""
 
logger:
  baud_rate: 0
 
api:
 
ota:
  platform: esphome
 
web_server:
  port: 80
  local: true
  log: false
 
output:
  - platform: gpio
    pin:
      number: GPIO13
      inverted: true
    id: sonoff_led
 
light:
  - platform: binary
    id: relay_led
    internal: true
    output: sonoff_led
 
switch:
  - platform: gpio
    pin: GPIO12
    id: sonoff_relay
    name: "Sonoff Relay"
 
    on_turn_on:
      - light.turn_on: relay_led
 
    on_turn_off:
      - light.turn_off: relay_led
 
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: true
 
    id: sonoff_button
    name: "Sonoff Button"
 
    on_press:
      - switch.toggle: sonoff_relay

ESPhome flash

esphome run sonoff_bassic_r1.yaml --device 192.168.178.XXX

Links
https://devices.esphome.io/devices/sonoff-basic-diy-light/