Msg.Payload Change

Hi all,

I am sure I am doing something really simple here. I have a ping node which pings an IP address. On successful ping I get the msg.payload with the ms of the ping example:


What I am trying to do is use a regex to capture when it finds a number (which relates to the ms of the ping) change that to boolean - true.

I have another ping node that I set to an IP address I know is down, and the msg.payload is boolean false. I have a change node that reads the "false" and then changes it to a string of "down" - this works great - this is just testing to see that I can match the payload.

On the ping node that is pinging a active target, I am trying to take the ms in the payload and change it to "UP", now I have use the change node with regex the following regex which captures, numbers and decimales, i.e.
12345 OR 0.12345



I test the regex on and it finds the right values.
However when I use the regex on the change node using the following config:

On the debug nothing is changed (like it is when doing the simple change on the ping to a host i know is down)

Any advise on what I am doing wrong her

seems a hard way to do it. why not just test for false, then anything else is "up"

msg.payload = msg.payload === false ? "down" : "up"; in function node
payload = false ? "down" : "up" in a change node using JSONata expression

Maybe it is but what I am trying to do is have a few (10) devices on the network pinged. This is streamed into influxdb and then building dashboards based on that using grafana. The test I was going to use is store the true, false (can ping or cant ping) then based on the boolean value in grafana show traffic lights

If that makes sense? Whats throwing me off is that when the ping node pings an active client it doesnt return a boolean value it returns the milliseconds returned to ping that node

then just test for false and if not false return true before storing the result to db.
JSONATA expression
payload = false ? false : true

Told you I was doing something stupid when it seemed so simple :slight_smile: that will work and thank you!

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