Hello Everyone,
I'm completely new to node-red.
I am trying to create a flow in which i have to loop while condition and
within loop i need to add sub flows based on value of loop.
※sub flows are the same handling.
Input
- A zip file that inside contains many text files
Output
- The result file contains the processed content of each txt file in the input ZIP file, such as comparison, calculation and editing.
I'm thinking of the draf like this:
[{"id":"a5510213.ab69c","type":"subflow","name":"Subflow 1","info":"","in":[],"out":[]},{"id":"43e653d8.4eb50c","type":"function","z":"a5510213.ab69c","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":190,"y":80,"wires":[[]]},{"id":"18febc57.82b2a4","type":"switch","z":"a5510213.ab69c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":220,"y":120,"wires":[[]]},{"id":"603ee840.f02c08","type":"template","z":"3b501765.6a7958","name":"i=0","field":"i","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"0","x":510,"y":520,"wires":[["17301876.45fad8"]]},{"id":"17301876.45fad8","type":"switch","z":"3b501765.6a7958","name":"i<4","property":"i","propertyType":"msg","rules":[{"t":"lt","v":"4","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":790,"y":520,"wires":[["781cc82b.bc4508"],["bc8de519.bf7fb8"]]},{"id":"de118552.608c38","type":"function","z":"3b501765.6a7958","name":"i++","func":"msg.i++;\n\nreturn msg;","outputs":1,"noerr":0,"x":950,"y":380,"wires":[["17301876.45fad8"]]},{"id":"912db2b0.8768b","type":"debug","z":"3b501765.6a7958","name":"msg end","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1260,"y":560,"wires":[]},{"id":"ae6ab5c2.fee078","type":"debug","z":"3b501765.6a7958","name":"msg output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1270,"y":480,"wires":[]},{"id":"1f381e41.ded552","type":"inject","z":"3b501765.6a7958","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"str","x":390,"y":520,"wires":[["603ee840.f02c08"]]},{"id":"21b81be3.dd31f4","type":"comment","z":"3b501765.6a7958","name":"↓ output 4 times","info":"","x":1280,"y":440,"wires":[]},{"id":"ab22648b.1eff08","type":"comment","z":"3b501765.6a7958","name":"conditional for while ↑","info":"","x":760,"y":560,"wires":[]},{"id":"e138d0d7.649ce","type":"comment","z":"3b501765.6a7958","name":"↓ init value i to increment","info":"","x":570,"y":480,"wires":[]},{"id":"d10b2b36.526988","type":"comment","z":"3b501765.6a7958","name":"↓ count up i","info":"","x":970,"y":340,"wires":[]},{"id":"bc8de519.bf7fb8","type":"template","z":"3b501765.6a7958","name":"Post-loop processing","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"End of loop","x":1020,"y":560,"wires":[["912db2b0.8768b"]]},{"id":"781cc82b.bc4508","type":"template","z":"3b501765.6a7958","name":"Generate result output","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Value i = {{i}}","x":1020,"y":480,"wires":[["ae6ab5c2.fee078","de118552.608c38"]]},{"id":"d4664aee.ff01c8","type":"inject","z":"3b501765.6a7958","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":310,"y":740,"wires":[["6fbc670f.1f89b8"]]},{"id":"9d77fa16.931b98","type":"zip","z":"3b501765.6a7958","name":"","mode":"decompress","filename":"","outasstring":false,"x":540,"y":740,"wires":[["b12057db.c97bd8"]]},{"id":"dc2e094d.3e4c88","type":"subflow:a5510213.ab69c","z":"3b501765.6a7958","name":"","env":[],"x":800,"y":740,"wires":[]},{"id":"fde08b64.a893b8","type":"comment","z":"3b501765.6a7958","name":"↑ file content: comparison, calculation, editing,...","info":"","x":920,"y":780,"wires":[]},{"id":"b12057db.c97bd8","type":"debug","z":"3b501765.6a7958","name":"msg zip","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":660,"wires":[]},{"id":"77cad8a2.aa1348","type":"comment","z":"3b501765.6a7958","name":"↑ output array file txt","info":"","x":578,"y":780,"wires":[]},{"id":"6fbc670f.1f89b8","type":"file in","z":"3b501765.6a7958","name":"","filename":"/Temp/FOLDER_TEXT.zip","format":"","chunk":false,"sendError":false,"encoding":"none","x":410,"y":640,"wires":[["9d77fa16.931b98"]]}]
■What has been done:
- Create
while
loop using node of Node-RED with the value of the loop condition fixed is4
- The extracted input zip file the result is an array
msg.payload : array[3]
(★)
■Problem:
- I don't know how to put array in (★) instead of fixed value
4
ofwhile
loop and make it work
Any idea will be great.
Thanks.