Delay when using mytimeout node

Hi,

I have tried to make some progress bar using chart bar and mytimeout node. So I have 5 horizontal chart bar which means 5 steps of my program. When the first mytimeout is over, another one begins and so on. So I can have many steps running one after each other. But it looks I have a delay when one mytimeout is over and when the new one begins... Someone has an idea ?

Thank you

[{"id":"24095369.3ba49c","type":"tab","label":"Flow 11","disabled":false,"info":""},{"id":"7c6c7448.8bde5c","type":"ui_chart","z":"24095369.3ba49c","name":"","group":"448586ea.7f42a8","order":2,"width":6,"height":2,"label":"Fmax Droite N1","chartType":"horizontalBar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"3","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#ff3333","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1320,"y":380,"wires":[[]]},{"id":"ea35b564.b74718","type":"mytimeout","z":"24095369.3ba49c","name":"Fmax Droite N1","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"3","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1020,"y":380,"wires":[["1bcf5fe1.b61d9"],["7c6c7448.8bde5c"]]},{"id":"1926930.9633b6d","type":"mytimeout","z":"24095369.3ba49c","name":"Recup Fmax N1","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"3","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1020,"y":580,"wires":[["7155d527.f2ae6c"],["44553cbc.cbb974"]]},{"id":"1bcf5fe1.b61d9","type":"function","z":"24095369.3ba49c","name":"","func":"if (msg.payload == 'off') {\n    msg.payload = 'on'\n}\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":500,"wires":[["1926930.9633b6d"]]},{"id":"44553cbc.cbb974","type":"ui_chart","z":"24095369.3ba49c","name":"","group":"448586ea.7f42a8","order":3,"width":6,"height":2,"label":"Recup Post Fmax N1","chartType":"horizontalBar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"3","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1340,"y":580,"wires":[[]]},{"id":"5bc83a09.4924d4","type":"function","z":"24095369.3ba49c","name":"","func":"msg.payload = 3\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":620,"wires":[["7c6c7448.8bde5c","44553cbc.cbb974","788a24ce.b5d11c","f5cb9d51.25cbb","ffdd6657.7974e8"]]},{"id":"788a24ce.b5d11c","type":"ui_chart","z":"24095369.3ba49c","name":"","group":"448586ea.7f42a8","order":4,"width":6,"height":2,"label":"Fmax Droite N2","chartType":"horizontalBar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"3","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#ff3333","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1320,"y":760,"wires":[[]]},{"id":"73da4ea1.bca96","type":"mytimeout","z":"24095369.3ba49c","name":"Fmax Droite N2","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"3","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1020,"y":760,"wires":[["172c3b1b.69ca85"],["788a24ce.b5d11c"]]},{"id":"4a6a4347.2d280c","type":"mytimeout","z":"24095369.3ba49c","name":"Recup Fmax N2","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"3","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1020,"y":940,"wires":[[],["f5cb9d51.25cbb","abe89208.ceeb1"]]},{"id":"172c3b1b.69ca85","type":"function","z":"24095369.3ba49c","name":"","func":"if (msg.payload == 'off') {\n    msg.payload = 'on'\n}\nreturn msg;","outputs":1,"noerr":0,"x":850,"y":860,"wires":[["4a6a4347.2d280c"]]},{"id":"f5cb9d51.25cbb","type":"ui_chart","z":"24095369.3ba49c","name":"","group":"448586ea.7f42a8","order":5,"width":6,"height":2,"label":"Recup Post Fmax N2","chartType":"horizontalBar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"3","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1340,"y":940,"wires":[[]]},{"id":"7155d527.f2ae6c","type":"function","z":"24095369.3ba49c","name":"","func":"if (msg.payload == 'off') {\n    msg.payload = 'on'\n}\nreturn msg;","outputs":1,"noerr":0,"x":850,"y":680,"wires":[["73da4ea1.bca96"]]},{"id":"a5347043.afc05","type":"mytimeout","z":"24095369.3ba49c","name":"PrĂ©paration","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"3","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1010,"y":180,"wires":[["de9b1309.05b59"],["ffdd6657.7974e8"]]},{"id":"ffdd6657.7974e8","type":"ui_chart","z":"24095369.3ba49c","name":"","group":"448586ea.7f42a8","order":1,"width":6,"height":2,"label":"PrĂ©paration","chartType":"horizontalBar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"3","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#f2f155","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1310,"y":180,"wires":[[]]},{"id":"de9b1309.05b59","type":"function","z":"24095369.3ba49c","name":"","func":"if (msg.payload == 'off') {\n    msg.payload = 'on'\n}\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":280,"wires":[["ea35b564.b74718"]]},{"id":"2bc8f415.f15abc","type":"ui_button","z":"24095369.3ba49c","name":"","group":"77e8a1e0.4442a","order":5,"width":0,"height":0,"passthru":false,"label":"Quand vous ĂȘtes prĂȘts, cliquez ici ","tooltip":"","color":"","bgcolor":"","icon":"","payload":"on","payloadType":"str","topic":"","x":480,"y":120,"wires":[["a5347043.afc05","77091505.3e085c"]]},{"id":"77091505.3e085c","type":"function","z":"24095369.3ba49c","name":"","func":"var now = new Date();\nmsg.payload = now.getTime();\nflow.set('t1', msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":260,"wires":[["99462f8b.767b9"]]},{"id":"99462f8b.767b9","type":"debug","z":"24095369.3ba49c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":580,"y":400,"wires":[]},{"id":"369383b2.8308ec","type":"debug","z":"24095369.3ba49c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1530,"y":240,"wires":[]},{"id":"d58e121.3a232f","type":"inject","z":"24095369.3ba49c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":350,"y":620,"wires":[["5bc83a09.4924d4"]]},{"id":"abe89208.ceeb1","type":"function","z":"24095369.3ba49c","name":"","func":"if (msg.payload === 0) {\n    msg.payload = new Date().getTime();\n    flow.set('t2', msg.payload);\n}\nreturn msg;","outputs":1,"noerr":0,"x":1280,"y":240,"wires":[["369383b2.8308ec"]]},{"id":"9420fc40.3e53f","type":"debug","z":"24095369.3ba49c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":950,"y":1060,"wires":[]},{"id":"e4f3f1ac.e9f0b","type":"function","z":"24095369.3ba49c","name":"","func":"msg.payload = flow.get('t2') - flow.get('t1');\nreturn msg;","outputs":1,"noerr":0,"x":770,"y":1060,"wires":[["9420fc40.3e53f"]]},{"id":"e9677333.7f267","type":"inject","z":"24095369.3ba49c","name":"Tstop - Tstart","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":570,"y":1060,"wires":[["e4f3f1ac.e9f0b"]]},{"id":"ba90e488.d01f78","type":"inject","z":"24095369.3ba49c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":180,"wires":[["a5347043.afc05","77091505.3e085c"]]},{"id":"448586ea.7f42a8","type":"ui_group","z":"","name":"Compte Ă  rebours","tab":"f75bbc9f.a03b1","order":3,"disp":true,"width":"6","collapse":false},{"id":"77e8a1e0.4442a","type":"ui_group","z":"","name":"PrĂ©paration au test","tab":"f75bbc9f.a03b1","order":2,"disp":true,"width":"6","collapse":false},{"id":"f75bbc9f.a03b1","type":"ui_tab","z":"","name":"PrĂ©hension SELFIT","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

The flow you shared has only one node. May you possibly share the whole flow (if it is not confidential or too large) ?

Sorry, my bad. I have updated my code.
Thank you for your concern.

It is not possible to import your flow. Could you please edit your post to include the flow between three backticks? :wink:

```
Your code
```

Thank you! It's updated.
I have add into my node a time computation. I compute the time between the start (when I lauch the code) and the time at the end. I have 5 mytimeout node of 3s so, the computed time should be 15 seconds. Or the time is eerytime different and between 16 and 18 seconds most of the time...
Thank you for you help.

Good, I confirm that i can also see the issue.

I guess this delay is intrinsic to the mytimeout node.

I suggest you to use the contrib-interval-length to assess how much the mytimeout node delays message. Apparently it is more than you would expect. If you confirm those findings better to contact the developer of the mytimeout node for a deeper assessment.

I did a quick testing with below flow and noted that the node delays the message 3.8 seconds when configured to delay 3 seconds.

a-01

a-02

Same testing for the standard delay node.

a-03

a-04

1 Like

I imagine it decrements and tests only every second and its internal 1 second tick is not synchronised to the incoming message so it is never going to accurate for measuring short intervals.

1 Like

thank you for your time, I will do that. I also have tried to use a template node a create a javascript function using setInterval() and it works quiet well.

1 Like

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