I'm accessing openweather.org and pulling down a matrix like so.
[0 … 9]
[10 … 19]
[20 … 29]
dt_txt: "2020-04-19 18:00:00"
The code to access works with the wind array but not the rain object.
Here's my code:
var rainAmt0=msg.payload.rain.3h); //ng
var windSpeed0=msg.payload.wind.speed; //OK
There is an issue with the '3' which causes a syntax error. "unexpected '.' ".
So what am I doing wrong?
Still throwing error:
"TypeError: Cannot read property '3h' of undefined"
msg.payload.rain << must be undefined cos it cant get >> ["3h"]
try putting a debug just before where this function is & see what is in
msg.payload before it reaches this function - my bet is its not what you expect.
The documentation on "working with messages" has some excellent tips on this (well worth 10mins of your time)
also, looking at your output above, it doesnt look like
3h is a member property of
Its a good idea to use the copy path button in the debug side-bar to avoid errors like this (it in the "working with messages" documentation)
PS, you are viewing element  not element 
have you checked element .rain has a 3h property?
The 'path' string is yet another tool added to my arsenal.
Using copy in debug statement the path is: var rainAmt0=msg.payload.rain["3h"];
No syntax...Thank you.
It seems that payload sometimes has rain object and sometimes not.
Thanks Steve-Mcl and dceejay.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.