Additive / compound delay

Hi there,
I'm picking up data from mqtt as the input node, triggering a delay and then setting the msg.payload to '0'.
However i want to know what happens if the delay gets triggered twice, do the timers run concurrently?

If the timers would run concurrently, is there a way to compound the by adding the delays together instead?

Basically i have a pir sensor that outputs a 1 to a topic when it's triggered, but never sets the topic back to 0 so i'm using a delay to do it.

Thoughts, comments and suggestions appreciated!

Welcome to the forum @gazzat5.

That depends on what timer you are using. Please post here a bit of your flow so we can see what you are doing. Just the few relevant nodes.

See this post for how to share your flow here - How to share code or flow json

Here's my flow:

[
    {
        "id": "8ea50271.939ae",
        "type": "delay",
        "z": "a84d5beb.895958",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "minutes",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 440,
        "y": 1600,
        "wires": [
            [
                "5032178a.d3b698"
            ]
        ]
    },
    {
        "id": "5032178a.d3b698",
        "type": "function",
        "z": "a84d5beb.895958",
        "name": "reset_topic",
        "func": "msg.payload = 0;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 620,
        "y": 1600,
        "wires": [
            [
                "e5de41ff.8975c"
            ]
        ]
    },
    {
        "id": "e5de41ff.8975c",
        "type": "mqtt out",
        "z": "a84d5beb.895958",
        "name": "",
        "topic": "sensors/rtl_433/Smoke-GS558/unit",
        "qos": "",
        "retain": "true",
        "broker": "c10f09f0.421e98",
        "x": 890,
        "y": 1600,
        "wires": []
    },
    {
        "id": "8e8d66ea.b85608",
        "type": "mqtt in",
        "z": "a84d5beb.895958",
        "name": "",
        "topic": "sensors/rtl_433/Smoke-GS558/unit",
        "qos": "2",
        "datatype": "auto",
        "broker": "c10f09f0.421e98",
        "x": 200,
        "y": 1600,
        "wires": [
            [
                "8ea50271.939ae"
            ]
        ]
    },
    {
        "id": "c10f09f0.421e98",
        "type": "mqtt-broker",
        "z": "",
        "name": "dietpi",
        "broker": "localhost",
        "port": "1883",
        "clientid": "node-red",
        "usetls": false,
        "compatmode": false,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]

I suspect a trigger node may help as it can second a second (0) output after a delay from the first. Or maybe the delay put into rate limit mode ( which will then queue them up)

I think maybe what you want is to use a Trigger node configured like this

That will start a timer when it gets a message. If nothing else happens then after five minutes it will send a message with payload 0. However if another message comes within five minutes then it will start the timer again. If yet another message arrives then it will reset again. So the result is that it will send when nothing has happened for five minutes.

1 Like

Hi, thanks for that, it does the trick :smiley:. I've changed the flows so that the delay writes to a different mqtt topic as not to cause a feedback loop. The flows also takes the new topic and writes to influxdb.

See below:

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