Dear Sir,
I have a flow that receive some DHT22 values from different NodeMCU via MQTT.
-
I have created a "JOIN NODE" to JOIN all the sensor values, and make a correct unique long array to send to:
-
a "FUNCTION NODE" that prepare the GSHEET unique long array with all the DHT sensors.
The array is make to take the incoming array from the "JoinNode":
GSHEETuniqueLongArray= [
date,
time,
msg.payload.DHTEsterno[0].payload,
msg.payload.DHTEsterno[1].payload,
msg.payload.DHTSala[0].payload,
msg.payload.DHTSala[1].payload, etc etc....
]
return [GSHEETuniqueLongArray ];
The problem is that if one or more NodeMCU is powered OFF, the "function Node", to make a gsheet array, gives me the error:
"TypeError: Cannot read property '0' of undefined"
Is it possible to tell to this function node to don't consider for example the:
"msg.payload.DHTSala[0].payload" if this nodeMCU is disconnected?
I have already try with:
var a = msg.payload.DHTSala[0].payload;
if (typeof a !== 'undefined') { a = a } else { a="nd"};
but doesn't work!