Today's dumb question:
This code:
[{"id":"267a24d08e923993","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":3320,"y":2170,"wires":[["577228be11288c55"]]},{"id":"577228be11288c55","type":"function","z":"0918ee609bf69fc7","name":"function 37","func":"node.warn(msg.payload.foo);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3510,"y":2170,"wires":[[]]}]
I get undefined
.....
Clear, simple and easy to understand why.
So the train is derailed in this bit of code:
let todays_rain = flow.get("rain") || 0;
node.warn("Today's rain is " + todays_rain);
// If `reset` message received.
if (msg.reset == "reset") {
//
// OLD CODE BELOW REPLACED 2023 12 27
//
//msg.rain_now = Math.round((flow.get("rain") * 10) / 10);
//node.status({ text: "Rain = " + todays_rain + " counter = " + msg.count });
//
msg.rain_now = 0;
node.status({text:"RESET"});
flow.set("total_rain",0);
return msg;
}
node.warn("******");
node.warn(msg.payload.rain);
node.warn("******");
///
I see the first line of *****
but then this error:
I get:
TypeError: Cannot read properties of undefined (reading 'rain')
Why am I not getting undefined
as I do on the other machine?