Toggle with sonoff basic and custom button card too fast

Hi,
fairly new to esphome but loving it.
I have a challenge where I tap a custom button card the sonoff toggles too fast and switches on and then back off again.
Where could I put a delay in the sonoff yaml? :

substitutions:
  devicename: erker
  upper_devicename: Erker

esphome:
  name: $devicename
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "xxxxxxxxx"
  password: "xxxxxxxxxxx"
  power_save_mode: none
  fast_connect: true
  reboot_timeout: 45min
  manual_ip:
    static_ip: 192.168.1.65
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    dns1: 8.8.8.8
    dns2: 8.8.4.4

# Enable logging
logger:

# Enable Home Assistant API
api:
#  password: !secret api_pass

ota:
#  password: !secret ota_pass

status_led:
  pin:
    number: GPIO13
    inverted: yes

binary_sensor:
  - platform: gpio
    id: button
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    on_press:
      then:
        - light.toggle: $devicename
        - delay: 2s

output:
  - platform: gpio
    id: light_relay
    pin: GPIO12

light:
  - platform: binary
    id: $devicename
    name: $upper_devicename
    output: light_relay

sensor:
  - platform: wifi_signal
    name: $upper_devicename - wifi
    update_interval: 60s

  - platform: uptime
    name: $upper_devicename - uptime

text_sensor:
  - platform: version
    name: $upper_devicename - version

Like this?

binary_sensor:
  - platform: gpio
    id: button
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    on_press:
      then:
        - light.turn_on: $devicename
        - delay: 2s
        - light.turn_off: $devicename

not yet Iā€™m afraid, still toggles too fast.
Switches on and off within 1 sec.

Oh right. I put the delay in the physical button on the device but you are talking about controlling the relay directly in home assistant. Call a script (tap_action) when you press the button:

        tap_action:
          action: call-service
          service: script.pulse_light_relay
script:
  pulse_light_relay:
    sequence:
    - switch.turn_on
      entity_id: switch.light_relay
    - delay:
        seconds: 2
    - switch.turn_off
      entity_id: switch.light_relay
1 Like

thanks, that did the trick!

1 Like