I was about to help someone and while writing a flow and using the moment
node I noticed some weird happenings.
Here is a working version:
[{"id":"b036bcbd7e968d27","type":"function","z":"65c9b63cb09879a0","name":"","func":"msg1 = {};\nvar last = context.get(\"last\") || 0;\n//node.warn(\"Last \" + last);\n\nvar now = msg.payload;\n//node.warn(\"Now \" + now);\n\nvar diff = now - last;\n//node.warn(\"Diff \" + diff);\n\ncontext.set(\"last\",now);\nmsg.payload = diff;\nmsg1.payload = last;\nreturn [msg,msg1];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1690,"y":440,"wires":[["854e8054259d8865"],["29f6c4455848f54b"]]},{"id":"5b1517de26decbd9","type":"inject","z":"65c9b63cb09879a0","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1530,"y":440,"wires":[["b036bcbd7e968d27","2a950ded67900e92"]]},{"id":"854e8054259d8865","type":"moment","z":"65c9b63cb09879a0","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"mm:ss","locale":"en-AU","output":"payload","outputType":"msg","outTz":"Australia/Sydney","x":1870,"y":440,"wires":[["b20ec09a7b4ecb1e"]]},{"id":"29f6c4455848f54b","type":"moment","z":"65c9b63cb09879a0","name":"","topic":"","input":"","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm:ss","locale":"en-AU","output":"","outputType":"msg","outTz":"Australia/Sydney","x":1870,"y":530,"wires":[["b50cd4588cac6937"]]},{"id":"2a950ded67900e92","type":"moment","z":"65c9b63cb09879a0","name":"","topic":"","input":"","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm:ss","locale":"en-AU","output":"","outputType":"msg","outTz":"Australia/Sydney","x":1730,"y":350,"wires":[["56370474810d5420"]]},{"id":"b20ec09a7b4ecb1e","type":"debug","z":"65c9b63cb09879a0","name":"diff","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1890,"y":390,"wires":[]},{"id":"b50cd4588cac6937","type":"debug","z":"65c9b63cb09879a0","name":"last","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1890,"y":480,"wires":[]},{"id":"56370474810d5420","type":"debug","z":"65c9b63cb09879a0","name":"Time","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1900,"y":350,"wires":[]}]
I have extra things shown (available) to help me check it is/was working.
Within a second things seem to add up - but for the first time.
So, where's the problem?
The moment
node going to the diff
debug node.
It is set to show mm:ss
Minutes and Seconds.
But!
If I make it HH:mm:ss
it ALWAYS shows 10
hours!
Is that a bug?