I am trying to write a function to give me a running average of a sensor value, but no matter what I do, the output is NaN. Yes, I did discover the Mean Value node, so my math is superfluous. Except, I would like to know why I am getting a NaN output- just to learn what I did wrong.
//Put just the average moisture into the payload. var moistureRaw = msg.moistureRaw; var runningWet = node.get('runningWet') || 0; runningWet = (runningWet + moistureRaw ) /2; node.set('runningWet', runningWet); msg.payload = runningWet; return msg;