# For loop utilizing ui\_numeric

**URL:** https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268
**Category:** Dashboard
**Created:** [30 June 2020 23:52 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268 "2020-06-30T23:52:15Z")
**Posts on this page:** 14
**Page:** 2

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [1 July 2020 02:16 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/21 "2020-07-01T02:16:53Z")

</div>

> [@vlturner](#):
>
> You guys are going to force me to write my loops in Python Function.

Please don´t, please...

Andrew, please find a solution before is too late.... 😆

---

<div class="post-metadata">

### Author: ![vlturner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vlturner/32/15211_2.png) [@vlturner](https://discourse.nodered.org/u/vlturner)
#### Post date: [1 July 2020 02:18 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/22 "2020-07-01T02:18:21Z")

</div>

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

[![]( " - YouTube") ](https://www.youtube.com/watch?v=GyEXHVwZZew)

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...

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [1 July 2020 02:19 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/23 "2020-07-01T02:19:58Z")

</div>

> [@vlturner](#):
>
> Actually...It is rocket science. Hypersonic Pulse Detonation and it solves the thermal issues. Mine operates silently at room temperature. And its logarithmic not linear in the charge to pressure..No one in the world other than I and my PhD Chemist father-in-law understand it...
> 
> Again. trying to slip in anything but ui\_numeric...

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.

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [1 July 2020 02:23 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/24 "2020-07-01T02:23:28Z")

</div>

> [@vlturner](#):
>
> I need the functionality of ui\_numeric to let me set it and then to poke it when called to pass its count.

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/ca97a848868bda5958cd6781fcec3d618cd0d250.png)

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [1 July 2020 02:41 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/25 "2020-07-01T02:41:33Z")

</div>

@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.

---

<div class="post-metadata">

### Author: ![vlturner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vlturner/32/15211_2.png) [@vlturner](https://discourse.nodered.org/u/vlturner)
#### Post date: [1 July 2020 02:52 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/26 "2020-07-01T02:52:02Z")

</div>

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](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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/f/0fec857ad17490a9a3a9180baf23ad26f51b9fdd.png)

```auto
[{"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}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/6/7667a15a19e534b64d37b8c41f568bd82d10ed0f.png)

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [1 July 2020 03:59 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/27 "2020-07-01T03:59:26Z")

</div>

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 ?

```auto
[{"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}]

```

 ![a-3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/474a1e44e36d022055278fbd46ca2a7bf78227e6.png)

---

<div class="post-metadata">

### Author: ![vlturner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vlturner/32/15211_2.png) [@vlturner](https://discourse.nodered.org/u/vlturner)
#### Post date: [1 July 2020 05:33 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/28 "2020-07-01T05:33:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![vlturner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vlturner/32/15211_2.png) [@vlturner](https://discourse.nodered.org/u/vlturner)
#### Post date: [2 July 2020 05:35 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/29 "2020-07-02T05:35:21Z")

</div>

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

```auto
[{"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.

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [2 July 2020 15:20 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/30 "2020-07-02T15:20:58Z")

</div>

> [@vlturner](#):
>
> Any suggestions for simplification?

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

---

<div class="post-metadata">

### Author: ![vlturner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vlturner/32/15211_2.png) [@vlturner](https://discourse.nodered.org/u/vlturner)
#### Post date: [2 July 2020 15:24 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/31 "2020-07-02T15:24:11Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [2 July 2020 15:29 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/32 "2020-07-02T15:29:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![vlturner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vlturner/32/15211_2.png) [@vlturner](https://discourse.nodered.org/u/vlturner)
#### Post date: [3 July 2020 03:12 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/33 "2020-07-03T03:12:44Z")

</div>

I like that idea, a design document...

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [2 August 2020 03:12 UTC](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268/34 "2020-08-02T03:12:51Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/for-loop-utilizing-ui-numeric/29268.md?page=1)
