# Alive tjek of all IoT devices

**URL:** https://discourse.nodered.org/t/alive-tjek-of-all-iot-devices/53983
**Category:** General
**Created:** [19 November 2021 09:24 UTC](https://discourse.nodered.org/t/alive-tjek-of-all-iot-devices/53983 "2021-11-19T09:24:46Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![rothestar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rothestar/32/30672_2.png) [@rothestar](https://discourse.nodered.org/u/rothestar)
#### Post date: [19 November 2021 09:24 UTC](https://discourse.nodered.org/t/alive-tjek-of-all-iot-devices/53983/1 "2021-11-19T09:24:46Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/4/54f9109b655dfc92065a252917a5ea5333af850e.png)

the output from the MQTT node:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5d732bdfe60e97387524c5062e34e38b99c531bc.png)

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/0/8046fb64104e31a5cb5bfe76160e6e1e2095353b.png)

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

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [19 November 2021 10:15 UTC](https://discourse.nodered.org/t/alive-tjek-of-all-iot-devices/53983/2 "2021-11-19T10:15:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [19 November 2021 10:20 UTC](https://discourse.nodered.org/t/alive-tjek-of-all-iot-devices/53983/3 "2021-11-19T10:20:21Z")

</div>

> [@rothestar](#):
>
> 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.

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

---

<div class="post-metadata">

### Author: ![rothestar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rothestar/32/30672_2.png) [@rothestar](https://discourse.nodered.org/u/rothestar)
#### Post date: [19 November 2021 11:33 UTC](https://discourse.nodered.org/t/alive-tjek-of-all-iot-devices/53983/4 "2021-11-19T11:33:39Z")

</div>

the payload should look like this:  
"h106\_3a":"10.188.62.25"

then it will enter the influxdb

like this:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1a31da06747c984df6313e457c79cff82eeb9878.png)

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

it hardcoded in the function node:

```auto
//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;

```

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [19 November 2021 11:58 UTC](https://discourse.nodered.org/t/alive-tjek-of-all-iot-devices/53983/5 "2021-11-19T11:58:28Z")

</div>

> [@rothestar](#):
>
> ```auto
> msg.payload = {
> idd:ip
> }
> 
> ```

Try instead

```auto
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?

---

<div class="post-metadata">

### Author: ![rothestar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rothestar/32/30672_2.png) [@rothestar](https://discourse.nodered.org/u/rothestar)
#### Post date: [19 November 2021 12:13 UTC](https://discourse.nodered.org/t/alive-tjek-of-all-iot-devices/53983/6 "2021-11-19T12:13:06Z")

</div>

> [@Colin](#):
>
> ```auto
> msg.payload = {}
> msg.payload[idd] = ip
> 
> ```

works like a charme.  
thanks

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [18 January 2022 12:13 UTC](https://discourse.nodered.org/t/alive-tjek-of-all-iot-devices/53983/7 "2022-01-18T12:13:32Z")

</div>

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