During delay drop all intermediate messages?

Could you advise me? I need that if an message is "ON" comes, then within 11 seconds all other messages will be ignored!
I tried to implement delay using the node "delay" but, this node is randomly counting the seconds, there is no constancy! Sometimes it can be 10 seconds, but next time only God knows how long it will delay!
As you can see on the screenshot, only one second instead of 11!
Is there a more better solution instead this?

[{"id":"a4553b4d.2d4328","type":"tab","label":"Sort mesages","disabled":false,"info":""},{"id":"115302c8.5f995d","type":"inject","z":"a4553b4d.2d4328","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":310,"y":160,"wires":[["c2928d09.328a4"]]},{"id":"87aafa65.d187d8","type":"inject","z":"a4553b4d.2d4328","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":310,"y":220,"wires":[["c2928d09.328a4"]]},{"id":"80127c2e.578d2","type":"inject","z":"a4553b4d.2d4328","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Refresh","payloadType":"str","x":310,"y":280,"wires":[["c2928d09.328a4"]]},{"id":"dbb4b1b8.3cb36","type":"debug","z":"a4553b4d.2d4328","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1130,"y":160,"wires":[]},{"id":"9d5c918e.57876","type":"delay","z":"a4553b4d.2d4328","name":"","pauseType":"queue","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"11","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":740,"y":140,"wires":[["b87509cf.be0028"]]},{"id":"c2928d09.328a4","type":"function","z":"a4553b4d.2d4328","name":"Sort","func":"//node.warn(Date.now());\n//var msg2 ;\nvar msg2 = { payload: \"LOCK\" };\n\nif (msg.payload === \"ON\") { \n    node.warn(\"LOCK\");\n    \n    return [ msg, msg2 ]; \n} \nelse {\n    //msg.payload=\"OFF\";\n    node.warn(\"PASS\");\n    return [ null, msg ];\n} \n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":530,"y":180,"wires":[["9d5c918e.57876"],["b87509cf.be0028"]]},{"id":"b87509cf.be0028","type":"function","z":"a4553b4d.2d4328","name":"LOCK","func":"var lock = flow.get('lock') || false;\n\n//var lock = flow.get('lock') || \"\"; \nif (msg.payload === \"LOCK\"){\n    node.warn(\"LOCK IN\");\n    flow.set('lock',true);\n    \n}\n\nelse if (msg.payload === \"ON\") { \n    //node.warn(\"TEST\");\n    node.warn(\"LOCK OUT\");\n    flow.set('lock',false);\n    return [ msg ]; \n} \nelse {\n    //msg.payload=\"OFF\";\n     if(lock === false)\n    {\n        node.warn(\"PASS OUT\");\n        return [ msg ];\n    }\n    else {\n        node.warn(\"PASS EGNORE\");\n    }\n} \n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":970,"y":180,"wires":[["dbb4b1b8.3cb36"]]}]

The delay node delays everything that arrives by the amount specified. You may find the trigger node more like what you need in that it can ignore further inputs while it’s timeout is running

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.