Node-red-node-ping : add name in output

Hello,

This ping node offers the ping result as payload and the target as topic.
By default the target is shown on the node, if a name is entered, the name is shown.
I would like this name to be available in the output data, somehow.

Is this possible?

Kind regards,

Peter Hunt.

In Node-RED, typically the name field is just used to help make your flows clearer in the Editor and they are not involved with msg flows. So this request would be a break from that standard approach.

If you change to trigger mode you can send an object or array of objects (to ping multiple items) with any amount of additional properties that you can see in the output msg. See the built in help.

Thanks both, as for the trigger, I understand what you mean but this doesn't offer what I'm looking for, as I want to monitor several IP's and if I need as much triggers as servers, I might as well create an array in a function node as well :slight_smile:

Here is how i do it, i feed an array of objects to the ping node( as @Steve-Mcl describes) including any extra info i want to include, in this case a name property. I then join the results back to an array , I then create a table for display etc.

[{"id":"c59f8e4a.b682","type":"ping","z":"336d1a7d.c0d64e","protocol":"Automatic","mode":"triggered","name":"","host":"","timer":"20","inputs":1,"x":195,"y":1460,"wires":[["10110cd2.4cde1b"]],"l":false},{"id":"d9da2791.99656","type":"inject","z":"336d1a7d.c0d64e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"600","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"[{\"host\":\"192.168.1.10\",\"name\":\"OpenLuup/MSR\"},{\"host\":\"192.168.1.11\",\"name\":\"Vera\"},{\"host\":\"192.168.1.149\",\"name\":\"Ezlo\"},{\"host\":\"192.168.1.12\",\"name\":\"CCTV\"},{\"host\":\"192.168.1.25\",\"name\":\"Node-red/Mosquitto\"}]","payloadType":"json","x":135,"y":1460,"wires":[["c59f8e4a.b682"]],"l":false},{"id":"10110cd2.4cde1b","type":"change","z":"336d1a7d.c0d64e","name":"","rules":[{"t":"set","p":"ping.online","pt":"msg","to":"payload ? true : false","tot":"jsonata"},{"t":"move","p":"ping","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload.style","pt":"msg","to":"$$.payload.online? \"green\" : \"red\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":255,"y":1460,"wires":[["19e7a9a.b9a3256"]],"l":false},{"id":"19e7a9a.b9a3256","type":"join","z":"336d1a7d.c0d64e","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"ping.name","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"6","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":315,"y":1460,"wires":[["88465e53.68064"]],"l":false},{"id":"88465e53.68064","type":"change","z":"336d1a7d.c0d64e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload^(name)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":375,"y":1460,"wires":[["2d3e081f.8a5a58"]],"l":false},{"id":"2d3e081f.8a5a58","type":"debug","z":"336d1a7d.c0d64e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":650,"y":1420,"wires":[]}]
1 Like

@Hunter I am on mobile and find it difficult to write long posts and provide demos but @E1cid has nicely summed up exactly what I was saying.

In other words if you use an array the only 1 trigger and 1 ping node is required.

I really should have RTFM, this dynamically setting of the payload solved my issues.
Thanks for your replies! :slight_smile: