Avoiding Loops in Node-Red

I am trying to sync some automations that include input_boolean, input_select, and dashboard switches. For the most part, they work, but occasionally they end up in a loop turning on/off forever. I’m not sure what triggers the loop, but it is not something I can have happen in production. If there isn’t a reasonable way to eliminate the loops, I can go back and do away with either the input_booleans or input selects, but like the ability to have both available.

You’re reading the state of the select, then writing back to the select which means it is changing state again, which starts the flow over.

With everything named the same thing it’s hard to troubleshoot that flow.

What is this flow supposed to accomplish?

I have 4 valve actuators, which control my pool. I have them controlled by relays.

What I posted above is just one of the valve actuators.

I have the following ways to control each valve:

Node-Red Dashboard Switch: True/Fasle
Input_Select: Spa/Feature
Input_Boolean: On/Off

The two Input_Select nodes are calling the same input_select and the two input_booleans are calling the same input_boolean.

I’m trying to keep the above 3 switching options synced regardless of which method is chosen to switch the valve.

I’m also sure there’s a more simple way to accomplish this with a function node vs all the change nodes (which I would love to hear about), but at this point I’m most concerned with the looping situation, which only happens rarely and sporadically and I’m not sure how to duplicate.

[{"id":"e27cfc2d.0f0818","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"2d34987d.dbb79","type":"server-state-changed","z":"e27cfc2d.0f0818","name":"V4 Pressure","server":"df79addc.b2967","version":1,"entityidfilter":"input_select.valve4_pressure","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":115,"y":150,"wires":[["ad0d7e02.dec148","18270ab1.0cd5bd"]]},{"id":"ad0d7e02.dec148","type":"change","z":"e27cfc2d.0f0818","name":"feat/spa","rules":[{"t":"change","p":"payload","pt":"msg","from":"Feature","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"Spa","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":255,"y":131,"wires":[["6c85a297.c8b8f4"]]},{"id":"18270ab1.0cd5bd","type":"change","z":"e27cfc2d.0f0818","name":"on/off","rules":[{"t":"change","p":"payload","pt":"msg","from":"Feature","fromt":"str","to":"on","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"Spa","fromt":"str","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":215,"y":266,"wires":[["7f57fa84.73abec"]]},{"id":"6c85a297.c8b8f4","type":"ui_switch","z":"e27cfc2d.0f0818","name":"","label":"V4 Press","tooltip":"","group":"f88ac8d6.c64ef","order":4,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":390,"y":146,"wires":[["bcdf6852.9e725","7988ba3.5b29744"]]},{"id":"7f57fa84.73abec","type":"api-call-service","z":"e27cfc2d.0f0818","name":"V4 Press","server":"df79addc.b2967","version":1,"service_domain":"homeassistant","service":"turn_{{payload}}","entityId":"input_boolean.valve4_ap","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":375,"y":266,"wires":[[]]},{"id":"bcdf6852.9e725","type":"change","z":"e27cfc2d.0f0818","name":"spa/feat","rules":[{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"Spa","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"Feature","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":525,"y":116,"wires":[["a48acbf0.1764a8"]]},{"id":"7988ba3.5b29744","type":"function","z":"e27cfc2d.0f0818","name":"ValveSetter","func":"flow.set(\"Valve4_ApOnOff\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":161,"wires":[[]]},{"id":"a48acbf0.1764a8","type":"api-call-service","z":"e27cfc2d.0f0818","name":"V4 Pres","server":"df79addc.b2967","version":1,"service_domain":"input_select","service":"select_option","entityId":"input_select.valve4_pressure","data":"{\"option\":\"{{payload}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":765,"y":116,"wires":[[]]},{"id":"83dce152.2d857","type":"server-state-changed","z":"e27cfc2d.0f0818","name":"V4 Pressure","server":"df79addc.b2967","version":1,"entityidfilter":"input_boolean.valve4_ap","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":535,"y":221,"wires":[["e6857b75.98007"]]},{"id":"e6857b75.98007","type":"change","z":"e27cfc2d.0f0818","name":"feat/spa","rules":[{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"Feature","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"Spa","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":221,"wires":[["a48acbf0.1764a8"]]},{"id":"2c2981de.ecc65e","type":"debug","z":"e27cfc2d.0f0818","name":"valve debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":955,"y":176,"wires":[]},{"id":"df79addc.b2967","type":"server","z":"","name":"Home Assistant - LRH","legacy":true,"hassio":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true},{"id":"f88ac8d6.c64ef","type":"ui_group","z":"","name":"On Off","tab":"a825f5c8.70c278","order":1,"disp":true,"width":"6","collapse":false},{"id":"a825f5c8.70c278","type":"ui_tab","z":"","name":"Pool Control","icon":"dashboard"}]

Additional information. Seems like the loops happen when I restart HA. I’ve gone in and set the “initial” state for all the inputs to be the same, hoping that will resolve?