Button active relay

Hi all. Yesterday I recorded a sonoff s20 for the first time and I can’t make the relay activate or deactivate when the button is pressed. From home assistant it works fine. It is only from esphome that
I did not find what the code is. I thank you

A more serious question is it now necessary to use mqtt for devices recorded with esphome.

switch:
  - platform: gpio
    name: "Relay enchufe reposicion"
    pin: GPIO12

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode:
        input: true
        pullup: true
      inverted: true
    name: "Boton enchufe resposicion"
  - platform: status
    name: "Estado enchufe resposicion"
  - platform: gpio
    pin: GPIO3
    name: "Sensor enchufe resposicion"

Hi Paplo
here is an tamplate

you are missing the part
on_press:
- switch.toggle: relay

just copy and paste :slight_smile:

1 Like

It was just that. I could not find it. Thanks a lot

Is it still useful to use mqtt or now not with esphome?