I am having some issues coming up with a flow for my greenhouse zones.
I have 4 zones setup via smart solenoids and a master water solenoid, so technically 5 zones. If you turn on any of the four zones, the master will turn on.
If I turn off 1 zone but still have more than 1 zone still on, the master remains on, but if all zones are off than I want the master solenoid to switch to turn off.
At this stage, I am using the following but it does not seem to be giving me an accurate true/ false reading which makes me think I am probably doing this wrong.
This is the flow I have so far.
[{"id":"596aebd0.918ae4","type":"api-call-service","z":"812a8d9.718ce7","name":"water_off","server":"9444eca1.01d33","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.button_toggle","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1320,"y":500,"wires":[[]]},{"id":"2797832b.219a5c","type":"server-state-changed","z":"812a8d9.718ce7","name":"zone1_off","server":"9444eca1.01d33","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.52087318e09806cb1d21","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":120,"y":480,"wires":[["87b28952.8570a8"],[]]},{"id":"52a27c7c.256504","type":"server-state-changed","z":"812a8d9.718ce7","name":"zone2_off","server":"9444eca1.01d33","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.52087318e09806cbc52d","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":120,"y":540,"wires":[["6b3d8d4e.dac3c4"],[]]},{"id":"87b28952.8570a8","type":"api-current-state","z":"812a8d9.718ce7","name":"Detection Zone1","server":"9444eca1.01d33","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.52087318e09806cb1d21","state_type":"str","state_location":"","override_payload":"msg","entity_location":"","override_data":"none","blockInputOverrides":false,"x":380,"y":480,"wires":[["9bf7a176.4169d"]]},{"id":"6b3d8d4e.dac3c4","type":"api-current-state","z":"812a8d9.718ce7","name":"Detection Zone2","server":"9444eca1.01d33","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.52087318e09806cbc52d","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"","override_data":"none","blockInputOverrides":false,"x":380,"y":540,"wires":[["8d618a9d.a0a838"]]},{"id":"33b4acf.7caaa54","type":"function","z":"812a8d9.718ce7","name":"","func":"var z1 = global.get(\"zone1\");\nvar z2 = global.get(\"zone2\");\nvar z3 = global.get(\"zone3\");\nvar z4 = global.get(\"zone4\");\n\nif (z1 == \"off\" && z2 == \"off\"){\n msg.payload = \"true\"\n}\n\nelse{ \n msg.payload = \"false\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":880,"y":500,"wires":[["10a163b1.3c0f9c"]]},{"id":"10a163b1.3c0f9c","type":"switch","z":"812a8d9.718ce7","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"true","vt":"str"},{"t":"cont","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1090,"y":500,"wires":[["596aebd0.918ae4"],[]]},{"id":"9bf7a176.4169d","type":"function","z":"812a8d9.718ce7","name":"Set Z1 variable","func":"global.set(\"zone1\",msg.payload);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":480,"wires":[["33b4acf.7caaa54"]]},{"id":"8d618a9d.a0a838","type":"function","z":"812a8d9.718ce7","name":"Set z2 variable","func":"global.set(\"zone2\",msg.payload);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":540,"wires":[["33b4acf.7caaa54"]]},{"id":"9444eca1.01d33","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false}]
I think my logic might be wrong. I am still quite new to using NodeRed. Has anyone done something similar that they might be able to explain and share?