Hi Guys,
Im trying to gather some data from a weather API and ii would want to get this particular value. How would i right that in Node red?
Hi Guys,
Im trying to gather some data from a weather API and ii would want to get this particular value. How would i right that in Node red?
You just need to highlight that property with your mouse, click the ‘copy path’ icon, and add msg.
at the front.
In this screenshot, the path is: msg.raw.vdl2.avlc.xid.pub_params[0].value
Not sure. I’ve not seen Node-RED put quotes in like that, so I suspect its something from the API.
Can you drop a screenshot of the debug expanded like mine?
We can take a look at it and see if we can spot anything.
Thanks for the quick response, I think I found the problem.
Since i am looking for rain conditions in a table that might be changing due to “predictability” of the rain, it’s searching for the path, but it can’t find it. So It’s causing it to read undefined.
There is no rain value on that path. But there use to be one. I need to see how i can adjust that or program against that.
Two ways that I handle that sort of thing.
(And I know @torchard has a function node JavaScript way).
You can check if the rain value exists in a switch node.
Note, I am not sure of your full path, so just put your rain path in, my screenshot is an example of what I am using.
In this case, it has just one output that will fire when the path is not empty.
Note this does not find if the path is there or not, just if the path has an empty value.
Here is the other way I look for a path or not.
I think you are going to want to use this switch node method.
The top output is the one when the rain data is there.
The bottom fires when there is no rain object at all.
This could be useful if you need other data from the API and don’t want the flow to stop just because there is no rain in the forecast… But handle it if there is.
Note in this method, I have to put the last part of copied path from the debug in.
I think in your case it will be ‘rain’, but you don’t put the trailing or leading .
in.