SONOFF Mini double click

I have reprogrammed a Sonoff mini with ESPHome. It’s controlling a standard switch and light. I would like to execute a double click automation on HA different that the single click.

  • single click → on or off the light
  • dbl click → close or open the room window cover

I did program on ESPHome a press and a on release function. On HA I did program an automation who reacts to the double click. Everything works perfectly except the fact that on the double click the main light flickers.

So I need a way to make sure that the main light doesn’t change the status when I do a double click. How can I implement this ? I have tried a delayed_on_off, but it doesn’t work with on_press and on_release

- platform: gpio
    name: "kappa2 Switch"
    pin: GPIO04
    id: switch_01
    on_press:
      - switch.toggle: relay_01
    on_release:
      - switch.toggle: relay_01

I think you need Binary Sensor Component — ESPHome

1 Like

Like @nickrout said. And use “on_multi_click”.

1 Like

Well I nearly have it working, the on_multiclick can fill my need pretty well. I replaced the double click by a fast click (even better). The only thing I need is to send a trigger to HA to start an automation. What would the easiest/best way to do this ?

 on_multi_click:
    - timing:
        - ON for at most 1s
        - OFF for at least 0.5s
      then:
        - logger.log: "Fast Click. Need to send a trigger to HA to start automation" 
    - timing:
        - OFF for at least 0.5s
      then:
        - switch.turn_off: relay_01
    - timing:
        - ON for at least 0.5s
      then:
        - switch.turn_on: relay_01

You can set up a template binary_sensor.

This will then show up in HA and you can use it to trigger an automation.

binary_sensor:
  - platform: template                           # Sun is up to HA
    name: "Fish feeder sun is up"
    id: fish_feeder_sun_is_up

You’ll then see binary_sensor.fish_feeder_sun_is_up in HA.

1 Like

Thanks I’ll try a binary template sensor. I can only select 1 person for the solution, but all 3 of you gave me correct answers to solve my problem, so thank u all.