Mimic Sonoff Mini behavior on an ESP12

Hi.

I trying to emulate what the Sonoff Mini does, but with 3 light switches.

Basically, I want to decouple the logic behind the On/Off wall switch and automate it using ESPHome.

So, if I turn on (toggle) the wall switch, I want a relay to turn on the lights, also I can see the status in Lovelace. Same thing when I turn it off.

Will the on_state for the switches work for what I need?

Like so:

binary_sensor:
  - platform: gpio
    # ...
    on_state:
      then:
        - switch.toggle: relay_1

Are you asking about the hardware configuration or the software? The behavior of the device in response to switches is all down to the firmware you are running on it, the one I’m most familiar with is Tasmota and it will certainly run on any generic esp8266 based module. On the hardware side you need your switch(es) to control the state of one or more GPIO pins, and then in software you can specify exactly how you’d like the output to respond to these inputs.

Software

Precisely. This would be my first ESPHome+ESP8266 automation (not relying on HA)

BTW, here’s a schematic where you can see the three switches and three relays