Two relays and blocking function

I would like to control the bottom valve of my hot-tub.
Then the valve is closed I can will the hottub and when the valve is open I empty the hottub.

So how this works. The valve is connected to two relays that are controlled by raspberry pi, that HA runs on. To close the valve I turn on relay 1 for 30 seconds, to open the valve I turn on relay 2 for 30 seconds.
If (by accident) I turn on both relays, I risk ruining the valve.

Do you have any suggestions on how to safely implement this in HA.
So if the “open” button has been pressed (relay 1), can I somehow make sure the relay 2 is Blocked during these 30 seconds.

If I were you I’d search and then read the documentation for questions like this.
Here’s a starter for 10 : -

Do the relays have multiple contacts? (N/O & N/C) If so you are better to wire them both through each others alternate contacts such that they are hard-wired with an interlock. That’s safer than relying on software


Exactly this. You could have a standard relay first in the circuit that handles the 30 seconds bit, then in series, a dual-throw relay (with both N/O (normally open) and N/C (normally closed)) contacts to handle the open/close action. Unless the insides of that relay melt, there’s no way both contacts can be live at once.

That’s what I’m about to do for my gas hot water controller. The standard Y-plan wiring has a “water on live” and a “water off live” connection, which I’ll be handling with an ESP8266 and a dual-throw relay rather than risking some software glitch blowing my house up.