Hi Node-REDers !
On one of my flow I am using an inject node with an interval of 1s, to check the status of a machine and calculate later on some indicators like its availability.
I have another inject node with an interval of 1h that resets my values. Unfortunately when the 1h interval occur, I do not have 3600 injections of my 1s interval. It´s lower and changes every hour. Over the past days the Min I had is 3400 and the max 3542.
I put the extract of the flow herebelow:
[{"id":"588e2ecc.702e1","type":"inject","z":"110bffaa.86774","name":"1s Timestamp","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":60,"wires":[["848b147f.00bdc8"]]},{"id":"848b147f.00bdc8","type":"function","z":"110bffaa.86774","name":"1h Machine Availability","func":"var machine_status = flow.get('machine_status')||0;\nvar machine_1h_running = flow.get('machine_1h_running')||0;\nvar machine_1h_stopped = flow.get('machine_1h_stopped')||0;\nvar timestamp1h_count = flow.get('timestamp1h_count')||0;\n\n\nif (machine_status === 0 )\n{ \n machine_1h_stopped++;\n flow.set('machine_1h_stopped',machine_1h_stopped);\n\n}\nelse if (machine_status === 1)\n{\n machine_1h_running++;\n flow.set('machine_1h_running',machine_1h_running);\n}\ntimestamp1h_count++;\nflow.set('timestamp1h_count',timestamp1h_count);\n\nmsg.payload=timestamp1h_count;\nreturn msg;\n","outputs":1,"noerr":0,"x":470,"y":100,"wires":[["69312c40.a93354"]]},{"id":"40a5ffed.c0fdd","type":"inject","z":"110bffaa.86774","name":"1h Timestamp","topic":"","payload":"","payloadType":"date","repeat":"3600","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":120,"wires":[["d31e7176.04f06"]]},{"id":"d31e7176.04f06","type":"function","z":"110bffaa.86774","name":"Hourly Machine Performance & Reset","func":"var machine_1h_running = flow.get('machine_1h_running')||0;\nvar machine_1h_stopped = flow.get('machine_1h_stopped')||0;\nvar timestamp1h_count = flow.get('timestamp1h_count')||0;\n\nflow.set('machine_1h_running',0);\nflow.set('machine_1h_stopped',0);\nflow.set('timestamp1h_count',0);","outputs":7,"noerr":0,"x":550,"y":180,"wires":[[],[],[],[],[],[],[]]},{"id":"69312c40.a93354","type":"debug","z":"110bffaa.86774","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":830,"y":100,"wires":[]}]
Should I try to use the bigtimer node, modify the inject node to use a timeout instead of an interval, or do that totally differently ?
I am keen to all your suggestions.
Cheers,
Antoine