How to create a sequence to send msg one after another instead in parallel

Seems to be a lot of duplication
I would create the array of ip's, then split them into separte messages. Then rate limit msg's, run each http request. Once request responds flush next msg from rate limit, then rejoin the array splits. Once all split msg's have rejoined delay a few seconds and repeat. You can break the loop with simple gate or something similar. I have added an inject you can break the loop by injecting when 5 second delay is running.
e.g.

[{"id":"bfd2dec.4751c2","type":"function","z":"452103ea51141731","name":"Make Array List","func":"const esp_list =[\n    \"ESS0_IP\", \n    \"ESS1_IP\", \n    \"ESS2_IP\", \n    \"ESS3_IP\"\n];\nmsg.payload = global.get(esp_list);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":4220,"wires":[["dd0bebb4.f47388","c18cc7569aa84461"]]},{"id":"7ee8bbb8.bd19e4","type":"hmi-tag out","z":"452103ea51141731","sse":"4ed039a6.814638","hmiID":"FinishBtn","name":"FinishBtn","all":false,"x":400,"y":4180,"wires":[["bfd2dec.4751c2"]]},{"id":"301047edb84f43b6","type":"delay","z":"452103ea51141731","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":540,"y":4220,"wires":[["bfd2dec.4751c2"]]},{"id":"dd0bebb4.f47388","type":"debug","z":"452103ea51141731","name":"","active":false,"console":"false","complete":"false","x":770,"y":4080,"wires":[]},{"id":"c18cc7569aa84461","type":"split","z":"452103ea51141731","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":930,"y":4220,"wires":[["4d2e2231f6204b8f"]]},{"id":"e97d79427a894d8d","type":"join","z":"452103ea51141731","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":"false","timeout":"","count":"","reduceRight":false,"x":1410,"y":4220,"wires":[["301047edb84f43b6"]]},{"id":"75414161afad949d","type":"inject","z":"452103ea51141731","name":"stop loop","props":[{"p":"reset","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":400,"y":4280,"wires":[["301047edb84f43b6"]]},{"id":"4d2e2231f6204b8f","type":"delay","z":"452103ea51141731","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"60","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1100,"y":4220,"wires":[["ec45d109.b5144"]]},{"id":"ec45d109.b5144","type":"http request","z":"452103ea51141731","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{payload}}/scib_data.dat","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"credentials":{"user":"","password":""},"x":1270,"y":4220,"wires":[["849bc568.57f898","e97d79427a894d8d"]]},{"id":"afa587f8.0cb5e8","type":"function","z":"452103ea51141731","name":"ESS0 Array","func":"var scib_data = [];\nscib_data = msg.payload.split(\",\");\n\nif(scib_data.length === 1301)\n{\n    var msgObj = {\n        \"topic\": \"ESS0_scib_data\",\n        \"payload\": scib_data \n    };\n\n    return [msgObj, {\"flush\":1}];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":4420,"wires":[["dbbed3c87ca466fe"],["4d2e2231f6204b8f"]]},{"id":"03033f2b4c7ef319","type":"function","z":"452103ea51141731","name":"HANDLE NO SUCCESS","func":"\n    return [msgObj, {\"flush\":1}];\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":800,"y":4460,"wires":[["65df3d29e216c86f"],["4d2e2231f6204b8f"]]},{"id":"849bc568.57f898","type":"switch","z":"452103ea51141731","name":"200 success?","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"num"},{"t":"else"}],"checkall":"true","outputs":2,"x":560,"y":4440,"wires":[["afa587f8.0cb5e8"],["03033f2b4c7ef319"]]},{"id":"dbbed3c87ca466fe","type":"debug","z":"452103ea51141731","name":"debug 110","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1090,"y":4400,"wires":[]},{"id":"65df3d29e216c86f","type":"debug","z":"452103ea51141731","name":"debug 111","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1090,"y":4440,"wires":[]}]

Untested as do not have your devices to test.

1 Like