# Convert rssi object to number

**URL:** <https://discourse.nodered.org/t/convert-rssi-object-to-number/53128>\
**Category:** Dashboard\
**Created:** [2 November 2021 13:54 UTC](https://discourse.nodered.org/t/convert-rssi-object-to-number/53128 "2021-11-02T13:54:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mTraub](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mTraub](https://discourse.nodered.org/u/mTraub)\
**Post date:** [2 November 2021 13:54 UTC](https://discourse.nodered.org/t/convert-rssi-object-to-number/53128/1 "2021-11-02T13:54:46Z")

</div>

Hello everyone,

first, i am new to Node Red and therefore not an expert in this field.

I am currently trying to get a "Sensor Health" Segment for my Dashboard.  
I am using the different Sensor-Values to display the health of the Sensor. For example the battery-life and signal strength.  
My problem is in the Signal Strenght value (rssi). Because the rssi-Value is stored as an object in the msg.payload.rssi i cannot build an if-function which compares it to another int/float value.  
For the battery health it is no problem because msg.payload.decoded.vdd returns me an integer value.

Is there a solution to get an integer value for the stored msg.payload.rssi ?

For information:When i am using the artless gauges it is no problem to show the rssi value simply by passing the object to the gauge.  
But when i want a custom LED to show either red, green or orange for different rssi values it is not possible because as i said above, it comes as an object and not as a string.

I dont know if i just cant use javascript properly because i am new to this or the workauround is somewhere else. Hope someone can help me out.

If you need any more information, i can deliver 🙂

Sorry for the english, i am from germany.

Cheers and thanks a lot  
Marius

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 November 2021 14:12 UTC](https://discourse.nodered.org/t/convert-rssi-object-to-number/53128/2 "2021-11-02T14:12:36Z")

</div>

> [@mTraub](#):
>
> My problem is in the Signal Strenght value (rssi). Because the rssi-Value is stored as an object in the msg.payload.rssi i cannot build an if-function which compares it to another int/float value.

You need to use a debug node to understand what data you are actually getting - then you can share that with us so that we can help. Generally an RSSI will be a number. But maybe it is a string containing a number?

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [2 November 2021 14:19 UTC](https://discourse.nodered.org/t/convert-rssi-object-to-number/53128/3 "2021-11-02T14:19:56Z")

</div>

If you just want to get hold of the rssi value and compare it with \<some\_number\> then you could do this in a function node.

```auto
let rssi = msg.payload.rssi;
if (rssi <= -85 ) {
blah
blah
blah
}

```

---

<div class="post-metadata">

**Author:** ![mTraub](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mTraub](https://discourse.nodered.org/u/mTraub)\
**Post date:** [2 November 2021 14:20 UTC](https://discourse.nodered.org/t/convert-rssi-object-to-number/53128/4 "2021-11-02T14:20:58Z")

</div>

![rssi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/a/fa77ffc94f92e5c3282ac870d43ef184f2c06e20.png)  
These are the debug data's i am getting.  
The vdd value i cant use and compare to other integer values and it works perfectly fine.  
But the rssi value i am getting is stored in an object and i dont know what kind of object this is.  
 ![function](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/ad0f3d63fb6a9de7b6d0c78012f9c19788d2f922.png)  
this is the function, i am just using this for an example so the final code will be different.  
For BattVal i am getting the "2" as an output, but for the rssi this does not work.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 November 2021 14:23 UTC](https://discourse.nodered.org/t/convert-rssi-object-to-number/53128/5 "2021-11-02T14:23:59Z")

</div>

Please post code rather than images, it is much easier to help then.

So what is wrong with:

```auto
if ( msg.payload.rssi <= -85 ) {
    // ... do something ...
}

```

The rssi you've shown isn't an object, it is a number as shown in the debug output.

---

<div class="post-metadata">

**Author:** ![mTraub](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mTraub](https://discourse.nodered.org/u/mTraub)\
**Post date:** [2 November 2021 14:34 UTC](https://discourse.nodered.org/t/convert-rssi-object-to-number/53128/6 "2021-11-02T14:34:22Z")

</div>

I dont know how to post code ...

> node.send({payload: msg.payload.rssi})

suprisingly returns me a number.  
but i cannot compare it to another integer value

---

<div class="post-metadata">

**Author:** ![mTraub](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mTraub](https://discourse.nodered.org/u/mTraub)\
**Post date:** [2 November 2021 14:40 UTC](https://discourse.nodered.org/t/convert-rssi-object-to-number/53128/7 "2021-11-02T14:40:49Z")

</div>

Got it, thanks a lot guys!

---

<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:** [16 November 2021 14:41 UTC](https://discourse.nodered.org/t/convert-rssi-object-to-number/53128/8 "2021-11-16T14:41:34Z")

</div>

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