Sonoff T1 Button Switch ESPHome Config Help

Hello people,

I am now stuck and I have a Sonoff T1 in the bathroom, this controls the ceiling spots.
Previously, he ran with Tasmota, but I now wanted to switch completely to ESPHome.
What I need is a button, this should be switched instand on and off. Only so the spots in the ceiling turn on.
With my current Config I get this on and off, but I have to press the switch very quickly after each other.
This is of course not productive for automation. I also noticed that the light dims down after a few seconds, but I don’t know why :frowning: I already searched the whole internet, but I couldn’t find a reasonable config.
What am I doing wrong? Here is the current config:

substitutions:
  device_name: 'badspots'

esphome:
  name: "${device_name}"
  platform: ESP8266
  board: esp01_1m
  on_boot:
    priority: -10
    then:
      - light.turn_on: blue_led_light

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pw
  fast_connect: true
  reboot_timeout: 60min
  manual_ip:
    static_ip: xxx.xxx.xxx.xxx
    gateway: xxx.xxx.xxx.xxx
    subnet: xxx.xxx.xxx.xxx
# Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${device_name} Hotspot"
    password: !secret appw

api:
  password: !secret apipw

ota:
  password: !secret otapw

logger:
  esp8266_store_log_strings_in_flash: false

# Enable Web Server
web_server:
  port: 80
  auth:
    username: !secret webuser
    password: !secret webpw

time:
  - platform: homeassistant
    id: ha_time
    timezone: Europe/Berlin 



sensor:
  - platform: uptime
    name: "${device_name} Uptime"
    update_interval: 60s
  - platform: wifi_signal
    name: "${device_name} WIFI"
    update_interval: 60s

switch:
  - platform: restart
    name: "${device_name} Neustart"
  - platform: gpio
    name: "${device_name} Schalter"
    pin: GPIO12
    id: relay_1
    icon: "mdi:power-plug"
    restore_mode: ALWAYS_OFF
  - platform: template
    name: "Relay Switch"
    icon: "mdi:fire"
    id: relay_switch
    optimistic: true
    turn_on_action:
      - light.turn_on:
          id: blue_led_light
      - switch.turn_on:
          id: relay_1
    turn_off_action:
      - light.turn_off:
          id: blue_led_light
      - switch.turn_off: 
          id: relay_1

binary_sensor:
  - platform: status
    name: "${device_name} Status"

  - platform: gpio
    name: "${device_name} Touchpad"
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
    id: touchpad
    on_press:
      then:
         - switch.toggle: relay_switch

output:
  - platform: esp8266_pwm
    id: blue_led
    pin: GPIO13
    inverted: True
    
light:
  # ... and then make a light out of it.
  - platform: monochromatic
    name: "${device_name} Blaue LED"
    output: blue_led
    internal: true
    id: blue_led_light

status_led:
  pin:
    number: GPIO13
    inverted: True
    
text_sensor:
  - platform: version
    name: "${device_name} Version"

big thanks for your help :slight_smile:

Maybe the problem is that you don’t have the device configured as light but as a switch?

But Sonoff T1 is a Wall Switch ^^

But doesn’t it control a light?

Of course it controls a light, but that is not smarthome capable.
Either I get it wrong now, or we are talking past each other. However, I have now been able to delete it myself, a quick toggle was the solution.

binary_sensor:
  - platform: status
    name: "${device_name} Status"
  - platform: gpio
    name: "${device_name} Touchpad"
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
    id: touchpad
    on_press:
      then:
         - light.toggle:
             id: led
         - switch.turn_on: relay_switch

switch:
  - platform: restart
    name: "${device_name} Neustart"
  - platform: gpio
    name: "${device_name} Schalter"
    pin: GPIO12
    id: relay
    icon: "mdi:power-plug"
    restore_mode: ALWAYS_OFF
    on_turn_on:
      - switch.toggle:
          id: relay_switch
      - light.toggle:
          id: led
      - delay: 250ms
      - switch.toggle:
          id: relay_switch
      - light.turn_off:
          id: led
    on_turn_off:
      - switch.turn_off:
          id: relay_switch
      - light.toggle:
          id: led
  - platform: template
    name: "Relay Switch"
    icon: "mdi:fire"
    id: relay_switch
    optimistic: true
    internal: true
    turn_on_action:
      - switch.turn_on:
          id: relay
    turn_off_action:
      - switch.turn_off: 
          id: relay`