How to extract a value after splitting a JSON String in Node-RED

I am injecting a String into my flow, then making it into a JSON String with the JSON node and splitting it with the split node. I get 5 messages out of this split node because there are 5 values with 5 properties. What I need is to extract only one of the values, to then use it in a function node. How can I do this?

enter image description here

This is a picture of one of the 5 outputs. What I want is to ONLY use the value (137) in a function node that should come after the split node. Thanks in advance.

If you only want one of the values out of 5 then it may be easier to just select that from the 5 rather than after the split. - what does the object with 5 items in look like ? Can you show us a debug of that ?

1 Like

Hello and thank you for your reply.

gfhjk

This is how the input of the split node looks like. I thought I should split it so that I can use the value of the power in a function node.

Maybe it's easier if I just explain my goal. I want to be able to use the power value in a function node, to check if it's zero or higher. How can I extract the power value from this message? (the message will be updated every 5 seconds)

msg.payload.power_mw should get you the value. You should be able to use this in a change node or a function

2 Likes

Im not sure why but this comes up time and time again. Perhaps a graphic would help?

image

If you read https://nodered.org/docs/user-guide/messages it will explain how you can use the debug panels tooltips to find out the correct path to any data you can display

1 Like