Alive tjek of all IoT devices

Ok im stuck again.

I am trying to see if all of our IoT devices are alive by pinging them and send the result to grafana.. as of now we have 30 units for testing purposes and et may expand to 200+ units.. so i would like it to be as automates as possibe.

Most og the units now are Shelly 1PM's but in the future we might switch to Shelly Pro 4PM.

image

the output from the MQTT node:
image

My problem is the send the Id and the IP to an influxdb for later ping.

so for now the funtion code looks like this:

var idd=msg.payload.id;
var ip=msg.payload.ip;

msg.payload = {
idd:ip
}

msg.measurement = "ip_adress";
node.status({fill:"green",shape:"ring",text:"id:"+idd+" ip:"+ip});
return msg;

The result looks like this:

image

So the task is to parse the variable idd as a value to the output so it gets the idd to the column name i the database.

So hav can I passe the id of the shelly (in this case h106_3a) with its IP to the influxdb??

Best regards
Henrik Oestergaard

Do the devices support LWT? If so then perhaps you can use that indicate whether they are alive rather than pinging them.

Show us exactly what you want the payload to look like for this example.

the payload should look like this:
"h106_3a":"10.188.62.25"

then it will enter the influxdb

like this:

I use InfluxDB Studio to explore the database.. (just made a test database for it to look right.

it hardcoded in the function node:

//var id=msg.payload.id;
//var ip=msg.payload.ip;

msg.payload = {
    h106_3a:"10.188.62.25"
}
msg.measurement = "test"   
//    node.status({fill:"green",shape:"ring",text:"id:"+id+" ip:"+ip});
return msg;

Try instead

msg.payload = {}
msg.payload[idd] = ip

However, that seems an odd thing to store in a field in a time series database. Normally the field data in influx is data that varies over time. Is the IP time variant?

works like a charme.
thanks

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