Delay node can not work with multi topic with different msg.rate

[
    {
        "id": "e96b3cf4329c5f4a",
        "type": "inject",
        "z": "d70eb72327dc3f2e",
        "name": "Node1",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 200,
        "wires": [
            [
                "b4486d7bda88c94b"
            ]
        ]
    },
    {
        "id": "a98f535fcde0bd82",
        "type": "inject",
        "z": "d70eb72327dc3f2e",
        "name": "Node2",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 240,
        "wires": [
            [
                "a86b125b73f7bf56"
            ]
        ]
    },
    {
        "id": "f9dd0dd191b3d3fb",
        "type": "delay",
        "z": "d70eb72327dc3f2e",
        "name": "",
        "pauseType": "timed",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "5",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "allowrate": true,
        "outputs": 2,
        "x": 630,
        "y": 220,
        "wires": [
            [
                "b637dea8b0153dda"
            ],
            []
        ]
    },
    {
        "id": "b4486d7bda88c94b",
        "type": "function",
        "z": "d70eb72327dc3f2e",
        "name": "fun1",
        "func": "msg.topic=\"1111\"\nmsg.rate=5000\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 350,
        "y": 200,
        "wires": [
            [
                "c02eaad562f17b9b"
            ]
        ]
    },
    {
        "id": "a86b125b73f7bf56",
        "type": "function",
        "z": "d70eb72327dc3f2e",
        "name": "fun2",
        "func": "msg.topic=\"2\"\nmsg.rate=10000\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 350,
        "y": 240,
        "wires": [
            [
                "c02eaad562f17b9b"
            ]
        ]
    },
    {
        "id": "b637dea8b0153dda",
        "type": "debug",
        "z": "d70eb72327dc3f2e",
        "name": "debug 86",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 800,
        "y": 200,
        "wires": []
    },
    {
        "id": "c02eaad562f17b9b",
        "type": "junction",
        "z": "d70eb72327dc3f2e",
        "x": 500,
        "y": 220,
        "wires": [
            [
                "f9dd0dd191b3d3fb"
            ]
        ]
    }
]

As the flow shows, the debug show nothing with two branch of messages.

But if I delete node2 , only has Node2 send message, then the debug node will show message.

You may need to explain it for people like me.

I don't understand what you want and what you are getting.

Please try to:
Explain what you want to happen.
What is happening.

I want node1 and node2 out put message with different rate, but seems use delay node can't achive it.

That is not possible with a single delay node.
If you check the code in line 249 (and the functionality is similar for all modes of operation) you can see that msg.rate is not stored based on the msg.topic.
In line 250 you can see that the timeout is reset, hence you will not get any output, because your timer is reset with every message delivering msg.rate (at a rate of 1msg/sec).

1 Like

I am seeing weird things when I run a SIMILAR flow.

[{"id":"6db7a285e85762b4","type":"delay","z":"d188b95f33e5f7e4","name":"","pauseType":"timed","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":true,"outputs":2,"x":1240,"y":3610,"wires":[["4977aa834ee57c10"],["a1a1deeea2e90997"]]},{"id":"1ade33a3d7ca52ca","type":"function","z":"d188b95f33e5f7e4","name":"fun3","func":"msg.topic=\"33\"\nmsg.rate=5000\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":3610,"wires":[["6db7a285e85762b4"]]},{"id":"76353e11e8441739","type":"function","z":"d188b95f33e5f7e4","name":"fun2","func":"msg.topic=\"2\"\nmsg.rate=10000\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":3560,"wires":[["6db7a285e85762b4"]]},{"id":"18bf251fef88f1f8","type":"function","z":"d188b95f33e5f7e4","name":"fun1","func":"msg.topic=\"1111\"\nmsg.rate=5000\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":3520,"wires":[["6db7a285e85762b4"]]},{"id":"673809bc521ae1d5","type":"trigger","z":"d188b95f33e5f7e4","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-250","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1160,"y":3670,"wires":[["6db7a285e85762b4"]]},{"id":"a11eb9420d53a580","type":"trigger","z":"d188b95f33e5f7e4","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-250","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1160,"y":3710,"wires":[["6db7a285e85762b4"]]},{"id":"4977aa834ee57c10","type":"debug","z":"d188b95f33e5f7e4","name":"debug 270","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1400,"y":3540,"wires":[]},{"id":"a1a1deeea2e90997","type":"debug","z":"d188b95f33e5f7e4","name":"Intermediate output","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1420,"y":3720,"wires":[]},{"id":"c7010cbdb412e550","type":"inject","z":"d188b95f33e5f7e4","name":"Node3","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Node 3","payloadType":"str","x":820,"y":3610,"wires":[["1ade33a3d7ca52ca"]]},{"id":"7eefe41464f65f7b","type":"inject","z":"d188b95f33e5f7e4","name":"Node2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"Node 2","payloadType":"str","x":820,"y":3560,"wires":[["76353e11e8441739"]]},{"id":"f8bdb55903341aae","type":"inject","z":"d188b95f33e5f7e4","name":"Node1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"Node 1","payloadType":"str","x":820,"y":3520,"wires":[["18bf251fef88f1f8"]]},{"id":"fd7a89c2649053cd","type":"function","z":"d188b95f33e5f7e4","name":"fun1","func":"msg.topic=\"1111\"\nmsg.rate=5000\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":3670,"wires":[["673809bc521ae1d5"]]},{"id":"afd3d945bc9fdb01","type":"inject","z":"d188b95f33e5f7e4","name":"STOP 1","props":[{"p":"reset","v":"reset","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":980,"y":3750,"wires":[["673809bc521ae1d5"]]},{"id":"d057efe30abab42e","type":"function","z":"d188b95f33e5f7e4","name":"fun2","func":"msg.topic=\"2\"\nmsg.rate=10000\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":3710,"wires":[["a11eb9420d53a580"]]},{"id":"bdbc863e7e4c0c3b","type":"inject","z":"d188b95f33e5f7e4","name":"STOP 2","props":[{"p":"reset","v":"reset","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":980,"y":3790,"wires":[["a11eb9420d53a580"]]},{"id":"10e13db9a9a5e701","type":"inject","z":"d188b95f33e5f7e4","name":"Start 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"Node 1","payloadType":"str","x":820,"y":3670,"wires":[["fd7a89c2649053cd"]]},{"id":"bda80a4f1df7258a","type":"inject","z":"d188b95f33e5f7e4","name":"Start 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"Node 2","payloadType":"str","x":820,"y":3710,"wires":[["d057efe30abab42e"]]}]

(Standard nodes)

When thing are happening - as per your first post - nothing happens.

But if you lick either of the top3 (well forget the #3 node) you SOMETIMES get an output.
This is helped if you maybe press the node at slightly quicker than once a second.
And you need to do it for at least 10 seconds. Maybe 15.

Ok: slight correction:
Let it run for a while then STOP #2 (or 1) and keep pressing the upper #1 button. (Or the one which is still running)

You start to get outputs at the time set.

Frantically pressing this button.
Here's what I see.

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