For loop utilizing ui_numeric

Please don´t, please...

Andrew, please find a solution before is too late.... :laughing:

All fun, but I know the Dashboard is still in its infancy. Just trying to look beyond what I know.

Most water ever moved for least amount of energy. Check out the flex in the Schedule 40 PVC

That code was quick and dirty bash shell...

If you are using Node-Red then it is JavaScript.
you can use Python is you want.

You seem to be getting stuck on trivial things.

If the mechanics are slow, you can't do the job. Don't blame the program.
Node-red has limits. Raspberry Pies have limits. Adding MQTT will

further slow things down.

So you really need to scale down the devices used to as few as possible.
Therefore MQTT should not be used.

if you really want SPEED go with writing it to be used on an ARDUINO as they are a lot faster than Node-Red.
The "Recipe" value could then be entered via the serial link.

1 Like

So, the ui_numeric will set the value of a flow (or global) variable.

This is straightforward, right ?

You can retrieve the stored value wherever you need it.

a-2

@vlturner you are also missing - in your posts - timing for the pulsing of the valve.
If you are wanting to pulse the valve there are set times for how long it needs to be open and closed.

This is an extreme limiting factor on how fast you can spit out the 'mallows.

As this is critical timing, Node-Red is (alas) a poor choice as it is asynchronous, and so can't really be trusted to keep such stringent times.

Arduino (or equivalent) is recommended.

Insisting on using this is only increasing your vectors for failure to a greater than acceptable value. And blaming it is also not productive. You have to use the right tool for the job.

1 Like

I am listening to you all...You can see on the bottom picture the button controlling the hydrogen valve. Timing is already handled. We just need the loop to "Push the Button" global.charge times.( The little red bomb icon)

I have the https://www.bitscope.com/blog/JK/?p=JK38B coming soon to parse up the job and high speed sensors once I get the basic dashboard written on one.

[{"id":"ced75f23.f50368","type":"ui_numeric","z":"574cc1b.fd32a4","name":"Charge","label":"Charge","tooltip":"","group":"e55118c9.d1ac08","order":2,"width":0,"height":0,"wrap":true,"passthru":true,"topic":"Charge","format":"{{value}}","min":0,"max":"1500","step":1,"x":400,"y":520,"wires":[["8bec6989.8e277"]]},{"id":"93996c17.94769","type":"debug","z":"574cc1b.fd32a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1050,"y":520,"wires":[]},{"id":"8bec6989.8e277","type":"change","z":"574cc1b.fd32a4","name":"","rules":[{"t":"set","p":"charge","pt":"global","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"charge","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":520,"wires":[["93996c17.94769"]]},{"id":"d1f865ef.b40ce","type":"counter-loop","z":"574cc1b.fd32a4","name":"","counter":"ild1f865efb40ce","counterType":"msg","reset":true,"resetValue":"value-null","initial":0,"initialType":"num","operator":"gte","termination":"charge","terminationType":"global","increment":1,"incrementType":"num","x":660,"y":460,"wires":[["93996c17.94769","abf8c024.e62a9","8d72c631.b4ee58"],["ee0a1dca.c5407"]]},{"id":"abf8c024.e62a9","type":"ui_text","z":"574cc1b.fd32a4","group":"e55118c9.d1ac08","order":3,"width":0,"height":0,"name":"","label":"Loop Out 1","format":"{{msg.payload}}","layout":"row-spread","x":1070,"y":420,"wires":[]},{"id":"ee0a1dca.c5407","type":"ui_text","z":"574cc1b.fd32a4","group":"e55118c9.d1ac08","order":4,"width":0,"height":0,"name":"","label":"Loop Out 2","format":"{{msg.payload}}","layout":"row-spread","x":1070,"y":460,"wires":[]},{"id":"85e53723.d465f","type":"ui_switch","z":"574cc1b.fd32a4","name":"Charge Switch","label":"","tooltip":"","group":"e55118c9.d1ac08","order":1,"width":3,"height":"3","passthru":true,"decouple":"false","topic":"channel_6","style":"","onvalue":"true","onvalueType":"bool","onicon":"fa-pulse fa-3x fa-spinner","oncolor":"green","offvalue":"false","offvalueType":"bool","officon":"fa-bomb fa-3x","offcolor":"red","x":115,"y":460,"wires":[["2ee9810f.8712e6"]],"l":false},{"id":"2e390f63.5c791","type":"trigger","z":"574cc1b.fd32a4","op1":"","op2":"false","op1type":"pay","op2type":"bool","duration":"2","extend":false,"units":"s","reset":"","bytopic":"all","name":"Hydrogen Charge","x":360,"y":460,"wires":[["85e53723.d465f","d1f865ef.b40ce"]]},{"id":"2ee9810f.8712e6","type":"switch","z":"574cc1b.fd32a4","name":"Run","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":200,"y":460,"wires":[["2e390f63.5c791"],[]]},{"id":"8d72c631.b4ee58","type":"link out","z":"574cc1b.fd32a4","name":"","links":["5d97ffdb.3e3458"],"x":1015,"y":380,"wires":[]},{"id":"e55118c9.d1ac08","type":"ui_group","z":"","name":"Recipe","tab":"80410626.fc27e8","order":1,"disp":true,"width":"6","collapse":false},{"id":"80410626.fc27e8","type":"ui_tab","z":"","name":"Pump Control Recipe","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

My understanding is that you want the loop being used to trigger the "Bomb" switch a configurable (via ui_numeric) number of times.

Perhaps flow below works like you expect ?

[{"id":"a59dd65b.0b2108","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"e619e5ae.1be8d8","type":"ui_numeric","z":"a59dd65b.0b2108","name":"Charge","label":"Charge","tooltip":"","group":"1c40e75a.c60c19","order":2,"width":0,"height":0,"wrap":true,"passthru":true,"topic":"Charge","format":"{{value}}","min":0,"max":"1500","step":1,"x":520,"y":140,"wires":[["562ca488.a9448c"]]},{"id":"f3caf360.a9f7e","type":"debug","z":"a59dd65b.0b2108","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1010,"y":240,"wires":[]},{"id":"562ca488.a9448c","type":"change","z":"a59dd65b.0b2108","name":"","rules":[{"t":"set","p":"charge","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":140,"wires":[["e5423005.f1a37"]]},{"id":"a9cae854.997e98","type":"ui_switch","z":"a59dd65b.0b2108","name":"Charge Switch","label":"","tooltip":"","group":"1c40e75a.c60c19","order":1,"width":3,"height":"3","passthru":true,"decouple":"false","topic":"channel_6","style":"","onvalue":"true","onvalueType":"bool","onicon":"fa-pulse fa-3x fa-spinner","oncolor":"green","offvalue":"false","offvalueType":"bool","officon":"fa-bomb fa-3x","offcolor":"red","x":720,"y":240,"wires":[["f3caf360.a9f7e","c1909c77.d2b92"]]},{"id":"e5423005.f1a37","type":"debug","z":"a59dd65b.0b2108","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":900,"y":140,"wires":[]},{"id":"136d7d0f.fd6a73","type":"ui_button","z":"a59dd65b.0b2108","name":"","group":"1c40e75a.c60c19","order":4,"width":0,"height":0,"passthru":false,"label":"Start","tooltip":"","color":"","bgcolor":"","icon":"","payload":"Start","payloadType":"str","topic":"","x":130,"y":240,"wires":[["fe3b035d.25a66"]]},{"id":"fe3b035d.25a66","type":"function","z":"a59dd65b.0b2108","name":"Countdown","func":"let loopCounter = flow.get(\"charge\");\n\nwhile (loopCounter--) {\n    node.send({\"payload\" : true, \"loop\" : loopCounter})\n}\n\nmsg.payload = false;\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":240,"wires":[["1bf5b727.af9519"]]},{"id":"1bf5b727.af9519","type":"delay","z":"a59dd65b.0b2108","name":"","pauseType":"rate","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":500,"y":240,"wires":[["a9cae854.997e98"]]},{"id":"c1909c77.d2b92","type":"ui_text","z":"a59dd65b.0b2108","group":"1c40e75a.c60c19","order":3,"width":0,"height":0,"name":"","label":"Loop Counter","format":"{{msg.loop}}","layout":"row-spread","x":940,"y":320,"wires":[]},{"id":"1c40e75a.c60c19","type":"ui_group","z":"","name":"Recipe","tab":"94852a37.3fa7d8","order":1,"disp":true,"width":"6","collapse":false},{"id":"94852a37.3fa7d8","type":"ui_tab","z":"","name":"Pump Control Recipe","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

Part works, will tweak in the morning and let you know when I tie it the the relay board.

Thank you all...Andrei it needed work to not operate the valve at 0 loop count.
Here is the final starting point.

[{"id":"574cc1b.fd32a4","type":"tab","label":"Recipe","disabled":false,"info":""},{"id":"8d72c631.b4ee58","type":"link out","z":"574cc1b.fd32a4","name":"","links":["5d97ffdb.3e3458"],"x":1215,"y":760,"wires":[]},{"id":"c1d78beb.d8b728","type":"ui_numeric","z":"574cc1b.fd32a4","name":"Charge","label":"Charge","tooltip":"","group":"3bbd2a48.7b1926","order":2,"width":0,"height":0,"wrap":true,"passthru":true,"topic":"Charge","format":"{{value}}","min":0,"max":"1500","step":1,"x":380,"y":660,"wires":[["5dac344e.d39ba4","58dd482.fc32fb8"]]},{"id":"5dac344e.d39ba4","type":"change","z":"574cc1b.fd32a4","name":"","rules":[{"t":"set","p":"charge","pt":"flow","to":"payload","tot":"msg"},{"t":"set","p":"loop","pt":"global","to":"charge","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":660,"wires":[[]]},{"id":"cad1e2f8.1c78","type":"ui_button","z":"574cc1b.fd32a4","name":"","group":"3bbd2a48.7b1926","order":4,"width":0,"height":0,"passthru":true,"label":"Start","tooltip":"","color":"","bgcolor":"","icon":"","payload":"Start","payloadType":"str","topic":"","x":370,"y":720,"wires":[["6c754adf.5deb64"]]},{"id":"6c754adf.5deb64","type":"function","z":"574cc1b.fd32a4","name":"Countdown","func":"let loopCounter = flow.get(\"charge\") - 1;\n\nwhile (loopCounter--) {\n    node.send({\"payload\" : true, \"loop\" : loopCounter})\n}\n\nmsg.payload = false;\n\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":760,"wires":[["1df64be6.a56244"]]},{"id":"1df64be6.a56244","type":"delay","z":"574cc1b.fd32a4","name":"","pauseType":"rate","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"4","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":700,"y":760,"wires":[["923a31b6.272bb8"]]},{"id":"3f4e1de2.d36a52","type":"ui_text","z":"574cc1b.fd32a4","group":"3bbd2a48.7b1926","order":3,"width":0,"height":0,"name":"","label":"Loop Counter","format":"{{msg.count}}","layout":"row-spread","x":1320,"y":700,"wires":[]},{"id":"2468014e.5c243e","type":"trigger","z":"574cc1b.fd32a4","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"2","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":1100,"y":760,"wires":[["8d72c631.b4ee58"]]},{"id":"e60480d4.c4448","type":"mqtt in","z":"574cc1b.fd32a4","name":"Reset","topic":"Reset","qos":"2","datatype":"auto","broker":"6b8f56d7.82af78","x":230,"y":660,"wires":[["c1d78beb.d8b728"]]},{"id":"35badc49.bab5dc","type":"inject","z":"574cc1b.fd32a4","name":"Flow Start","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":720,"wires":[["cad1e2f8.1c78"]]},{"id":"e0241873.17042","type":"link out","z":"574cc1b.fd32a4","name":"To Master Reset","links":["a9a5894.8d1ad78"],"x":335,"y":600,"wires":[]},{"id":"807136ba.604ce","type":"inject","z":"574cc1b.fd32a4","name":"Reset","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":600,"wires":[["e0241873.17042"]]},{"id":"176ee413.0fb8bc","type":"ui_button","z":"574cc1b.fd32a4","name":"Reset","group":"3bbd2a48.7b1926","order":1,"width":4,"height":"6","passthru":true,"label":"Reset","tooltip":"","color":"black/white","bgcolor":"blue","icon":"","payload":"0","payloadType":"num","topic":"","x":210,"y":540,"wires":[["e0241873.17042"]]},{"id":"923a31b6.272bb8","type":"change","z":"574cc1b.fd32a4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"channel_1","tot":"str"},{"t":"set","p":"increment","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":760,"wires":[["2468014e.5c243e","69dc928d.0e8e44"]]},{"id":"69dc928d.0e8e44","type":"counter","z":"574cc1b.fd32a4","name":"Charge Counter","init":"0","step":"0","lower":"","upper":"","mode":"increment","outputs":"1","x":1120,"y":700,"wires":[["3f4e1de2.d36a52"]]},{"id":"58dd482.fc32fb8","type":"change","z":"574cc1b.fd32a4","name":"Reset Counter","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":700,"wires":[["69dc928d.0e8e44"]]},{"id":"3bbd2a48.7b1926","type":"ui_group","z":"","name":"Recipe","tab":"659e4ebd.42aa68","order":1,"disp":true,"width":"6","collapse":false},{"id":"6b8f56d7.82af78","type":"mqtt-broker","z":"","name":"PI","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"home/temperature","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"659e4ebd.42aa68","type":"ui_tab","z":"","name":"Pump Control Recipe","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

Tied in valve operation and resets. This isn't final but operational. Any suggestions for simplification?

When Bill Joy first started working on Java and asked me to look at it, and he told me I would write the OS in it someday, I should have taken him out to the parking lot...But I was a kid.

1 Like

Nice. I don´t see room for simplification. Seems good already.

Thank you...I was trying to use node-red nodes instead of writing functions. I see we need better designed loop nodes in the long run. @dceejay

feel free to create some ! - https://nodered.org/docs/creating-nodes/
or create a design document that the community can discuss to ensure it captures the required features.

1 Like

I like that idea, a design document...