Convert rssi object to number

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 :slight_smile:

Sorry for the english, i am from germany.

Cheers and thanks a lot

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?

1 Like

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.

let rssi = msg.payload.rssi;
if (rssi  <= -85 ) {
1 Like

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.
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.

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

So what is wrong with:

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.

1 Like

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

Got it, thanks a lot guys!

1 Like

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