Yes and no one of the joys of JavaScript I'm afraid. You need to use the alternate syntax for accessing properties that start with numbers (or contain spaces or other non standard characters ). So you need rain["3h"]
msg.payload[0].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)
EDIT...
also, looking at your output above, it doesnt look like 3h is a member property of rain
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)
The 'path' string is yet another tool added to my arsenal.
Using copy in debug statement the path is: var rainAmt0=msg.payload[4].rain["3h"];
No syntax...Thank you.
It seems that payload[0] sometimes has rain object and sometimes not. Problem solved.
Thanks Steve-Mcl and dceejay.