Hi folks,
I got a question about my node-red-contrib-interval-length node, which measures the time interval between consecutive input messages. In the config screen you can specify in which output message field that measurement needs to be stored. For example I want the measurement to be stored in msg.customfield
:
When I use for example this simple test flow:
[{"id":"23df382c.058f38","type":"interval-length","z":"dc82a538.a81ba8","format":"mills","bytopic":false,"minimum":"","maximum":"","window":"","timeout":false,"msgTimeout":"","minimumunit":"msecs","maximumunit":"msecs","windowunit":"msecs","msgTimeoutUnit":"msecs","reset":false,"startup":false,"msgField":"customfield","timestampField":"timestamp","repeatTimeout":false,"name":"","x":840,"y":840,"wires":[["2cf9022f.d3f66e"],[]]},{"id":"be32c12.fd5c84","type":"inject","z":"dc82a538.a81ba8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":640,"y":840,"wires":[["23df382c.058f38"]]},{"id":"2cf9022f.d3f66e","type":"debug","z":"dc82a538.a81ba8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1030,"y":840,"wires":[]}]
This works fine for me (i.e. the timeinterval is stored in msg.customfield
):
However the user responded that this field doesn't show in his output message...
I have no clue what is going on there, since there is very little code involved. So I have created an "extra_logging" branch in my Github repository which he could install like this:
npm install bartbutenaers/node-red-contrib-interval-length#extra_logging
In this branch I have added some extra logging code:
console.log("************* START EXTRA LOGGING *************");
console.log("outputValue = " + outputValue);
console.log("node.msgField = " + node.msgField);
// Normally the interval value will be put in the msg,payload (overwriting the original input msg.payload value).
// But the user can explicitly require to put the interval value in another message field.
try {
console.log("Now we will set the message property");
RED.util.setMessageProperty(msg, node.msgField, outputValue, true);
console.log("Now we have set the message property");
console.log("msg[" + node.msgField + "] = " + msg[node.msgField]);
} catch(err) {
console.log("Something went wrong: " + err.message);
node.error("Error setting interval value in msg." + node.msgField + " : " + err.message);
}
console.log("************* STOP EXTRA LOGGING *************");
In my test setups I now see nicely some extra log lines:
But the user doesn't see this extra logging.
Does anybody have any tips of how I can troubleshoot this issue?
Thanks !!!
Bart