Trigger flows from two helper switches

I’m working on making a pool control system in HA, and I’m using node-red for the system logic. (I’m terrible at writing code, so any visual sort of editor is a godsend.) My system has a bunch of Pi GPIO switches controlling the pool systems, and then I have helper switches to control the GPIO in a way that makes sense for people using the system. (I’m emulating the way my old Compool system works.)

The problem I’m running into is I can’t figure out how to make a flow trigger when two of the helper switches are off. The switches are Pool and Spa, and each of them turn the valves to the respective mode, and neither are on at the same time (which is done using node-red as well - when one is turned on, it turns the other off). I also need both switches to turn on the pump GPIO, and that’s where I’m running into trouble. I can’t figure out a reliable way to create this: if either switch is on, pump is on; if both are off, pump is off.

The best method I have so far is with the Ultimate Boolean add-on logic gate, but it needs two of those gates, and for some reason the pump flicks off and back on instead of staying on, probably because of the millisecond when the switch is turned on and the other one is turning off. (And now I’m trying to get that method to work again, and I can’t.) Is there a better and more reliable way to do this, without having to write lines of code in a function node?

Oh, and once I get that working, my next challenge is to add in some way of checking the state of another gpio switch, and adding in a delay (for the heater) if the switch is on, before shutting the pump off.

Would it just be a matter of two “events: state” nodes triggering when either switch goes “off”, and after each a “current state” node that checks the ‘other’ switch is also “off”?

1 Like

Yes that’s it! After a bunch of messing around I got it to work, the only hiccup I had is that for some reason “events: state” records the states as a boolean, while the “current state” records it as “on” or “off”. Once I realized that, it worked smoothly. The “current state” also worked to add the heater delay.

I’m pretty new to node-red, so I’m not surprised I missed an obvious solution. Thanks for your help!

The correct way is to use event state nodes to trigger a flow of current state nodes with if settings setup.