Physical switch on Shelly RGBW2 rapidly turns ON and OFF

The Shelly RGBW2 offers the possibility to als be controlled by a physical switch on GPIO5 (Input-Connector).

I have configured the switch like this:

binary_sensor:
  - platform: gpio
    name: "${device_name}_button"
    pin:
      number: GPIO5
#      mode: INPUT_PULLUP
    on_state:
      then:
        - light.toggle: light01

If I directly switch the connection between ground and input, everything works fine.

If I use the alternate method to connect an AC switch through the provided optocoupler, I can see in the ESPHome-log, that the switch just constantly turns the ligts On and Off, if the physical switch is in position β€œON”.

If I activate the mode-line in the config (s.above) no events register in the ESP-Home log.

Did anybody manage to get a physical AC-Switch working with the shelly RGBW2 or has any hints how to solve this?

1 Like

ok, it seems that debouncing the signal as suggested in the ESPhome-docs by introducing a filter

binary_sensor:
  - platform: gpio
    name: "${device_name}_button"
    pin:
      number: GPIO5
    filters:
      - delayed_off: 100ms
    on_state:
      then:
        - light.toggle: light01

solved the problem.

2 Likes

You saved my day! I was using on_click and it was driving me crazy!

Thank you for sharing!

1 Like