How to tie two switches together

I have an ESP32 hooked to a relay board with 8 relays. I want to use this to turn a valve on and off. To turn the valve on or off I just need to reverse the polarity on the valves wires. I can do this using the relay board but I need to use 2 relays working at the same time.

Can I add some code to ESPhome that makes relay 7 turn on with relay 8 and vice-versa? Or, could I just “Y” the breadboard wires from the ESP32 and make one GPIO pin control 2 relays at once?

I think, applying Occam’s razor, this is the best solution.

You can use a template switch.

switch:
  - platform: template

    turn_on_action:
      - switch.turn_on: switch1
      - switch.turn_on: switch2
    turn_off_action:
      - switch.turn_off: switch1
      - switch.turn_off: switch2

Thanks for the replies. I’ll try the wiring method first, seems the easiest

Hey Brad, I have some motors to control and would like to actuate two relays for forward and two for reverse. Did the “Y” solution work or did you let the smoke out?
Grum

The “Y” solution has worked great for me.

Thanks Brad, works a treat.