I am new to Node-Red and am running it in Home Assistant. I am also new to HTML with very little previous programming knowledge(some Basic/Visual Basic/Access/C++). Yes that says Basic.
I am pulling an https request from OpenWeatherMap.org that is returning an array of objects(i think?). Is there a way to iterate through all the elements of all the objects and round all numbers to no decimals?
I tried:
var x = 0;
var len = {payload: msg.payload.length };
while (x < len) {
if (typeof msg.payload[X] !== 'string'){
msg.payload[x] = Number(a.toFixed(0))
}
x++
}
which did not work.
I then tried to set msg.payload.len to the length function with:
msg.payload.len = {payload: msg.payload.length };
and I get this:
As you can see I have .len shown as an object under msg.payload and it shows empty in the debug window. I have tried with and without the () after .length.
Any help appreciated. All of my searches give me nothing except that {payload: msg.payload.length} should work. I tried msg.length as well.
That does return the total number of the objects in the .payload. It return 16 which is the first level of objects, but how do would I make it look inside each object also?
Each day will be structured the same. Just the data will be slightly different in where it is.
In you example is would be something like: msg.day1......
And you would have the sunrise and sunset times.
Then you would have temp which would have a sub-set of dayminmaxnight and eve.... etc.
Then the feels_like with it's sub set.
Ok I did this. I had to install npm in order to install the node. When I installed it seems to have gone off without a hitch, but the nodes were not added to my node-red window?