Here is a little flow where I use the merge node.
Its just a ping function, so correct the set ping list node with your names and IPs and it should work.
The flow sometimes fail if HA is not ready and due to the way it is constructed it will not restart again unless a variable is cleared, but if it is cleared too soon, then the flow will not finish correctly and some IPs might then not get pinged.
The merge node handles this because as long as the script runs the merge node will get new messages in and therefore not anything to the reset flow node.
If the flow fails, then there no new messages to the merge node and after 300 seconds it will send a message to the reset flow node and thereby make a restart of the flow possible.
[{"id":"5e79dbe6f1ff6193","type":"ping","z":"742cc87db4d12986","protocol":"IPv4","mode":"triggered","name":"ping","host":"","timer":"20","inputs":1,"x":290,"y":105,"wires":[["60ee1802b4936e33"]]},{"id":"de8cb585e64cbdcd","type":"function","z":"742cc87db4d12986","name":"init payload","func":"msg.payload = [\n {\n \"host\":msg.ping_hosts[flow.get('host_count')].host,\n \"name\":msg.ping_hosts[flow.get('host_count')].name,\n \"timeout\":1000\n }\n]\ndelete msg.ping_hosts\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":140,"y":105,"wires":[["5e79dbe6f1ff6193"]]},{"id":"8d89777709693798","type":"ha-api","z":"742cc87db4d12986","name":"sensor","server":"541ade28.b4a62","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"/api/states/{{entity_id}}","data":"","dataType":"json","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":635,"y":240,"wires":[["2b7fbc9f4d5a512c"]]},{"id":"60ee1802b4936e33","type":"function","z":"742cc87db4d12986","name":"rearrange payload","func":"ping = msg.payload\nmsg.payload = [\n {\n \"host\":msg.ping.host,\n \"name\":msg.ping.name,\n \"timeout\":msg.ping.timeout,\n \"ping1\":ping\n }\n]\ndelete msg.ping\ndelete msg.topic\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":465,"y":105,"wires":[["5556ec8bac29e714"]]},{"id":"5556ec8bac29e714","type":"ping","z":"742cc87db4d12986","protocol":"IPv4","mode":"triggered","name":"ping","host":"","timer":"20","inputs":1,"x":290,"y":150,"wires":[["4216857a7920c093"]]},{"id":"4216857a7920c093","type":"function","z":"742cc87db4d12986","name":"rearrange payload","func":"ping = msg.payload\nmsg.payload = [\n {\n \"host\":msg.ping.host,\n \"name\":msg.ping.name,\n \"timeout\":msg.ping.timeout,\n \"ping1\":msg.ping.ping1,\n \"ping2\":ping\n }\n]\ndelete msg.ping\ndelete msg.topic\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":465,"y":150,"wires":[["5756468d017e28fc"]]},{"id":"3448a970a6c3c28b","type":"function","z":"742cc87db4d12986","name":"rearrange payload","func":"ping = msg.payload\nmsg.payload = [\n {\n \"host\":msg.ping.host,\n \"name\":msg.ping.name,\n \"timeout\":msg.ping.timeout,\n \"ping1\":msg.ping.ping1,\n \"ping2\":msg.ping.ping2,\n \"ping3\":ping\n }\n]\ndelete msg.ping\ndelete msg.topic\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":465,"y":195,"wires":[["9039ddb76aeaf573"]]},{"id":"5756468d017e28fc","type":"ping","z":"742cc87db4d12986","protocol":"IPv4","mode":"triggered","name":"ping","host":"","timer":"20","inputs":1,"x":290,"y":195,"wires":[["3448a970a6c3c28b"]]},{"id":"eab00987afff6bab","type":"function","z":"742cc87db4d12986","name":"make final payload","func":"ping = msg.payload\nmsg.entity_id = `sensor.ping_${msg.ping.name.toLowerCase().replace(/ /g, '_' )}`;\npacketloss=0;\naverage = 0;\nif (msg.ping.ping1==false)\n{\n packetloss=1;\n}\nelse\n{\n average=msg.ping.ping1;\n}\n\nif (msg.ping.ping2==false)\n{\n packetloss++;\n}\nelse\n{\n average=average+msg.ping.ping2;\n}\n\nif (msg.ping.ping3==false)\n{\n packetloss++;\n}\nelse\n{\n average=average+msg.ping.ping3;\n}\n\nif (ping==false)\n{\n packetloss++;\n}\nelse\n{\n average=average+ping;\n}\n\nif (packetloss!=4)\n{\n average=average/(4-packetloss);\n}\npacketloss=packetloss*25\n\nmsg.payload = {\n data: {\n state: Date.now(),\n attributes: {\n 'name':msg.ping.name,\n 'host':msg.ping.host,\n 'ping1': msg.ping.ping1,\n 'ping2': msg.ping.ping2,\n 'ping3': msg.ping.ping3,\n 'ping4': ping,\n 'average': Math.floor(average),\n 'packetloss': packetloss,\n friendly_name: 'Ping '+msg.ping.name,\n icon: 'mdi:pulse'\n }\n }\n};\ndelete msg.ping\ndelete msg.topic\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":465,"y":240,"wires":[["8d89777709693798"]]},{"id":"9039ddb76aeaf573","type":"ping","z":"742cc87db4d12986","protocol":"IPv4","mode":"triggered","name":"ping","host":"","timer":"20","inputs":1,"x":290,"y":240,"wires":[["eab00987afff6bab"]]},{"id":"06433f919f86b67b","type":"function","z":"742cc87db4d12986","name":"set ping list","func":"msg.ping_hosts = [\n { \"name\":\"Router\",\"host\":\"10.10.12.1\"},\n { \"name\":\"First Hop\", \"host\":\"100.70.8.1\"},\n { \"name\":\"Public IP\",\"host\":\"185.107.15.19\"},\n { \"name\":\"Google\", \"host\":\"8.8.8.8\"},\n { \"name\":\"Switch 1\", \"host\":\"10.10.14.11\"},\n { \"name\":\"Switch 2\", \"host\":\"10.10.14.12\"},\n { \"name\":\"Switch 3\", \"host\":\"10.10.14.13\"},\n { \"name\":\"Switch 4\", \"host\":\"10.10.14.14\"},\n { \"name\":\"AP 1\", \"host\":\"10.10.14.21\"},\n { \"name\":\"Hue Bridge\", \"host\":\"10.10.12.12\"},\n { \"name\":\"RF Bridge 1\", \"host\":\"10.10.12.14\"},\n { \"name\":\"RF Bridge 2\", \"host\":\"10.10.12.16\"},\n { \"name\":\"NAS\", \"host\":\"10.10.12.20\"},\n { \"name\":\"Radio Bedroom Left\", \"host\":\"10.10.12.50\"},\n { \"name\":\"Radio Bedroom Right\", \"host\":\"10.10.12.52\"},\n { \"name\":\"Smartplug Outdoor\", \"host\":\"10.10.12.150\"},\n { \"name\":\"Smartplug Refrigerator\", \"host\":\"10.10.12.151\"},\n { \"name\":\"Smartplug Freezer\", \"host\":\"10.10.12.152\"},\n { \"name\":\"Smartplug Dishwasher\", \"host\":\"10.10.12.153\"},\n { \"name\":\"Smartplug Washingmachine\", \"host\":\"10.10.12.154\"},\n { \"name\":\"Sonoff Plug 1\", \"host\":\"10.10.12.155\"},\n { \"name\":\"Sonoff Plug 2\", \"host\":\"10.10.12.156\"},\n { \"name\":\"Sonoff Plug 3\", \"host\":\"10.10.12.157\"},\n { \"name\":\"Sonoff Plug 4\", \"host\":\"10.10.12.158\"},\n { \"name\":\"Sonoff Plug 5\", \"host\":\"10.10.12.159\"},\n { \"name\":\"Sonoff Plug 6\", \"host\":\"10.10.12.160\"},\n { \"name\":\"Sonoff Switch 1\", \"host\":\"10.10.12.161\"},\n { \"name\":\"Kasa1\", \"host\":\"10.10.12.162\"},\n { \"name\":\"Kasa2\", \"host\":\"10.10.12.163\"},\n { \"name\":\"Kasa3\", \"host\":\"10.10.12.164\"},\n { \"name\":\"Kasa4\", \"host\":\"10.10.12.165\"},\n { \"name\":\"Kasa5\", \"host\":\"10.10.12.166\"},\n { \"name\":\"Kasa6\", \"host\":\"10.10.12.167\"}\n ]\nflow.set('ping_hosts_length',msg.ping_hosts.length)\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":775,"y":45,"wires":[["de8cb585e64cbdcd"]]},{"id":"cea4042da4a1a615","type":"inject","z":"742cc87db4d12986","name":"start ping cycle","props":[],"repeat":"120","crontab":"","once":true,"onceDelay":"30","topic":"","x":130,"y":45,"wires":[["c3848bb02d93a9da"]]},{"id":"1a060eab08e27cc9","type":"function","z":"742cc87db4d12986","name":"initiate counter","func":"flow.set('host_count',0)\nflow.set('running',1)\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":575,"y":45,"wires":[["06433f919f86b67b"]]},{"id":"2b7fbc9f4d5a512c","type":"function","z":"742cc87db4d12986","name":"increase counter","func":"counter=flow.get('host_count')+1\nif (counter==flow.get('ping_hosts_length'))\n{\n flow.set('running',0)\n}\nflow.set('host_count',counter)\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":240,"wires":[["04d9427be7f1da21","1ebf45b3f585cced"]]},{"id":"c3848bb02d93a9da","type":"switch","z":"742cc87db4d12986","name":"Check for active session","property":"running","propertyType":"flow","rules":[{"t":"neq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":45,"wires":[["1a060eab08e27cc9"]]},{"id":"04d9427be7f1da21","type":"switch","z":"742cc87db4d12986","name":"Check for active session","property":"running","propertyType":"flow","rules":[{"t":"neq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":755,"y":150,"wires":[["06433f919f86b67b"]]},{"id":"e85fb753c38c3214","type":"function","z":"742cc87db4d12986","name":"reset flow ","func":"flow.set('host_count',0)\nflow.set('running',0)\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":975,"y":285,"wires":[[]]},{"id":"8a20032e6aa7d835","type":"inject","z":"742cc87db4d12986","name":"Reset at startup","props":[{"p":"reset","v":"1","vt":"num"}],"repeat":"","crontab":"","once":true,"onceDelay":"60","topic":"","x":130,"y":285,"wires":[["e85fb753c38c3214"]]},{"id":"1ebf45b3f585cced","type":"merge","z":"742cc87db4d12986","name":"","timeout":"300","x":965,"y":240,"wires":[["e85fb753c38c3214"]]},{"id":"541ade28.b4a62","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":""}]