# Delay and Trigger died

**URL:** <https://discourse.nodered.org/t/delay-and-trigger-died/83881>\
**Category:** General\
**Tags:** home-assistant, mqtt, domoticz\
**Created:** [20 December 2023 17:17 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881 "2023-12-20T17:17:18Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dakhaasje](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dakhaasje/32/86107_2.png) [@Dakhaasje](https://discourse.nodered.org/u/Dakhaasje)\
**Post date:** [20 December 2023 17:17 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/1 "2023-12-20T17:17:18Z")

</div>

Hi,  
I'm using Node-Red for a few years now, for iot and home management in combination with Domoticz (power management) and Home Assistant ( many easily configured different modules).  
I use Tasmota (48 active devices), tuya (dunno, 50?) , P1 meter with Domoticz-Rpi3. etc. (all together I count 200 entities in HA). I have a Mqtt service running on a w11 machine. quite stable, more stable than the NodeRed/HA Ubuntu -NUC. (the Rpi3 mqtt server died).  
I use 433Hz Pir/contact sensors, which are translated to MQTT with 2 Tasmota Sonoff RF hubs.  
Node Red is tasked with translating codes to manageable mqtt hierarchy., and setting defaults back to 'off' after a triggering ('on' ).  
Here I use a call-node which is triggered by every single RF sensor/button/thing.  
Now my 'Delay' and 'Trigger' functions have stopped to function!  
the call part:

```auto
[
    {
        "id": "66bd848d37186bd1",
        "type": "link in",
        "z": "e8c1d00af083fb50",
        "name": "call fx mqtt rf",
        "links": [
            "6edce0e771790629"
        ],
        "x": 2305,
        "y": 200,
        "wires": [
            [
                "50ac2e28452bc687"
            ]
        ]
    },
    {
        "id": "50ac2e28452bc687",
        "type": "change",
        "z": "e8c1d00af083fb50",
        "name": "on",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "on",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2530,
        "y": 200,
        "wires": [
            [
                "bde328220543c8db",
                "28a14bb787e6f9ff",
                "59206a6fad86a8a1",
                "2c4e2161c1465fd7",
                "2a6a6aeb7402be97"
            ]
        ]
    },
    {
        "id": "358ced3f24d4f759",
        "type": "change",
        "z": "e8c1d00af083fb50",
        "name": "off",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "off",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2730,
        "y": 240,
        "wires": [
            [
                "bde328220543c8db",
                "28a14bb787e6f9ff",
                "11b4a7091fb62e18"
            ]
        ]
    },
    {
        "id": "bde328220543c8db",
        "type": "link out",
        "z": "e8c1d00af083fb50",
        "name": "return rf mqtt",
        "mode": "return",
        "links": [],
        "x": 2985,
        "y": 140,
        "wires": []
    },
    {
        "id": "28a14bb787e6f9ff",
        "type": "mqtt out",
        "z": "e8c1d00af083fb50",
        "name": "",
        "topic": "",
        "qos": "1",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "524d0d0f.80da54",
        "x": 3010,
        "y": 200,
        "wires": []
    },
    {
        "id": "a68decf986ec831d",
        "type": "comment",
        "z": "e8c1d00af083fb50",
        "name": "RF FX CALL",
        "info": "",
        "x": 2510,
        "y": 140,
        "wires": []
    },
    {
        "id": "9391c1a004931d0c",
        "type": "debug",
        "z": "e8c1d00af083fb50",
        "name": "debug off d",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2850,
        "y": 340,
        "wires": []
    },
    {
        "id": "11b4a7091fb62e18",
        "type": "debug",
        "z": "e8c1d00af083fb50",
        "name": "debug off t",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2990,
        "y": 260,
        "wires": []
    },
    {
        "id": "59206a6fad86a8a1",
        "type": "controltimer",
        "z": "e8c1d00af083fb50",
        "name": "1s",
        "timerType": "delay",
        "timerDurationUnit": "second",
        "timerDurationType": "num",
        "timerDuration": 1,
        "timerLoopTimeoutUnit": "second",
        "timerLoopTimeoutType": "num",
        "timerLoopTimeout": 0,
        "loopTimeoutMessageType": "str",
        "loopTimeoutMessage": "LOOP_TIMEOUT",
        "timerMaxLoopIterationsType": "num",
        "timerMaxLoopIterations": 0,
        "loopMaxIterationsMessageType": "str",
        "loopMaxIterationsMessage": "MAX_LOOP_ITERATIONS",
        "isRunningTimerProgressVisible": true,
        "outputReceivedMessageOnTimerTrigger": true,
        "outputReceivedMessageOnTimerHalt": false,
        "startTimerOnReceivalOfUnknownMessage": true,
        "resetTimerOnReceivalOfUnknownMessage": false,
        "resetTimerOnReceivalOfStartAction": false,
        "continueTimerOnReceivalOfStartAction": false,
        "isDebugModeEnabled": false,
        "timerTriggeredMessageType": "str",
        "timerTriggeredMessage": "TIMER_TRIGGERED",
        "timerHaltedMessageType": "str",
        "timerHaltedMessage": "TIMER_HALTED",
        "isStartActionEnabled": true,
        "isStopActionEnabled": true,
        "isResetActionEnabled": true,
        "isPauseActionEnabled": true,
        "isContinueActionEnabled": true,
        "actionPropertyNameType": "str",
        "actionPropertyName": "payload",
        "startActionNameType": "str",
        "startActionName": "START",
        "stopActionNameType": "str",
        "stopActionName": "STOP",
        "resetActionNameType": "str",
        "resetActionName": "RESET",
        "pauseActionNameType": "str",
        "pauseActionName": "PAUSE",
        "continueActionNameType": "str",
        "continueActionName": "CONTINUE",
        "x": 2510,
        "y": 240,
        "wires": [
            [
                "358ced3f24d4f759"
            ],
            []
        ]
    },
    {
        "id": "2c4e2161c1465fd7",
        "type": "delay",
        "z": "e8c1d00af083fb50",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 2520,
        "y": 300,
        "wires": [
            [
                "1962e48785ec94a6"
            ]
        ]
    },
    {
        "id": "1962e48785ec94a6",
        "type": "change",
        "z": "e8c1d00af083fb50",
        "name": "off",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "off",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2670,
        "y": 300,
        "wires": [
            [
                "9391c1a004931d0c"
            ]
        ]
    },
    {
        "id": "2a6a6aeb7402be97",
        "type": "debug",
        "z": "e8c1d00af083fb50",
        "name": "debug on",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2760,
        "y": 120,
        "wires": []
    },
    {
        "id": "524d0d0f.80da54",
        "type": "mqtt-broker",
        "name": "9x9",
        "broker": "censured",
        "port": "cens",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "compatmode": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]

```

Only "Debug on" and "Debug off t" have output. That means the delay function has no output at all.  
When using Trigger instead, only on output works.  
(as for test I walked past 3 pir sensors)  
debug result:

```auto
20-12-2023 17:39:04node: debug onhome/RF/cmnd/pir8 : msg.payload : string[2]
"on"
20-12-2023 17:39:04node: debug off thome/RF/cmnd/pir8 : msg.payload : string[3]
"off"
20-12-2023 17:39:08node: debug onhome/RF/cmnd/pir6 : msg.payload : string[2]
"on"
20-12-2023 17:39:08node: debug onhome/RF/cmnd/pir6 : msg.payload : string[2]
"on"
20-12-2023 17:39:08node: debug off thome/RF/cmnd/pir6 : msg.payload : string[3]
"off"
20-12-2023 17:39:10node: debug onhome/RF/cmnd/pir5 : msg.payload : string[2]
"on"
20-12-2023 17:39:11node: debug onhome/RF/cmnd/pir5 : msg.payload : string[2]
"on"
20-12-2023 17:39:11node: debug off thome/RF/cmnd/pir5 : msg.payload : string[3]
"off"
20-12-2023 17:39:13node: debug onhome/RF/cmnd/pir6 : msg.payload : string[2]
"on"
20-12-2023 17:39:13node: debug onhome/RF/cmnd/pir6 : msg.payload : string[2]
"on"
20-12-2023 17:39:14node: debug off thome/RF/cmnd/pir6 : msg.payload : string[3]
"off"
20-12-2023 17:39:24node: debug onhome/RF/cmnd/pir8 : msg.payload : string[2]
"on"
20-12-2023 17:39:24node: debug onhome/RF/cmnd/pir8 : msg.payload : string[2]
"on"
20-12-2023 17:39:25node: debug off t
home/RF/cmnd/pir8 : msg.payload : string[3]
"off"

```

Normally I would set timeout to about 10 seconds, to give some code and programs(HA-tuya/zigbee) time to execute and react to mqtt messages.. This means the call function should be able to handle multiple topics at the same time.  
Node Red V 3.0.2 on Ubuntu 22.04.3 LTS  
HA core also on Ubuntu, docker/portainer  
mosquitto fails to run docked, moved to w11 machine.

I replaced/removed all delay and trigger nodes from my flows. (1.6MB json)

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [21 December 2023 01:41 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/2 "2023-12-21T01:41:13Z")

</div>

Moved to General category as not about developing a node.

---

<div class="post-metadata">

**Author:** ![Dakhaasje](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dakhaasje/32/86107_2.png) [@Dakhaasje](https://discourse.nodered.org/u/Dakhaasje)\
**Post date:** [21 December 2023 10:05 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/3 "2023-12-21T10:05:12Z")

</div>

That is really helpful. #censored#

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [21 December 2023 11:03 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/4 "2023-12-21T11:03:24Z")

</div>

> [@Dakhaasje](#):
>
> This means the call function should be able to handle multiple topics at the same time.

There's no "at the same time" in NR at all. Yet I don't think this is the cause of what you see here...  
Have you checked the command line for any error log? Due to the number of items you're processing there might be a lot of traffic in your flows - potentially a risc to outnumber some resources.  
Do you still see those anomalies after a restart of NR?

---

<div class="post-metadata">

**Author:** ![Dakhaasje](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dakhaasje/32/86107_2.png) [@Dakhaasje](https://discourse.nodered.org/u/Dakhaasje)\
**Post date:** [21 December 2023 11:55 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/5 "2023-12-21T11:55:38Z")

</div>

machine restarted, same problem.  
Replaced all delays with timers... cpu temperature rise by 10 C. still problems  
Replaced them with delays again and ctrl-deleted delays where not absolutely neccessary, still malfunctioning delays.  
Replaced the pir on-off critical delay with a function with 'await' that delayed 150ms, solved lights not turning on.  
rest of delays still not functioning.

Probably I triggered a crash in some library in NR that handles delays/triggers. I think I need to re-install NR. I might try to run NR with flows imported on the w11 machine to see if that would help.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [21 December 2023 12:20 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/6 "2023-12-21T12:20:08Z")

</div>

> [@Dakhaasje](#):
>
> That is really helpful. #censored#

Yes, I thought so, as very few people develop their own nodes, most people would not look at your post!  
As it was 2am for me, putting it in the correct category at least means that people in other time zones might be able to help you.

> [@Dakhaasje](#):
>
> Now my 'Delay' and 'Trigger' functions have stopped to function!

The flow you posted doesn't contain any trigger nodes, so how can we debug this for you ?

1. What hardware are you running NR on.
2. Can you post the "original" code that stopped working - without the custom **"controltimer"** node. I don't think this does what you need anyway.
3. Add to the flow a selection of inject nodes to simulate the expected topics and payloads of incoming RF sensors.
4. Replace the MQTT out node with a debug node (nobody has access to your server)

---

<div class="post-metadata">

**Author:** ![Dakhaasje](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dakhaasje/32/86107_2.png) [@Dakhaasje](https://discourse.nodered.org/u/Dakhaasje)\
**Post date:** [21 December 2023 17:00 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/8 "2023-12-21T17:00:17Z")

</div>

actual live node. with not working delay/trigger.

```auto
[
    {
        "id": "66bd848d37186bd1",
        "type": "link in",
        "z": "e8c1d00af083fb50",
        "name": "call fx mqtt rf",
        "links": [
            "6edce0e771790629"
        ],
        "x": 2275,
        "y": 180,
        "wires": [
            [
                "50ac2e28452bc687"
            ]
        ]
    },
    {
        "id": "50ac2e28452bc687",
        "type": "change",
        "z": "e8c1d00af083fb50",
        "name": "on",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "on",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2470,
        "y": 180,
        "wires": [
            [
                "896ef8a1fdb18123",
                "bde328220543c8db",
                "28a14bb787e6f9ff",
                "bf43fedc18c80527",
                "91c51d4be1e32a64"
            ]
        ]
    },
    {
        "id": "bde328220543c8db",
        "type": "link out",
        "z": "e8c1d00af083fb50",
        "name": "return rf mqtt",
        "mode": "return",
        "links": [],
        "x": 3015,
        "y": 120,
        "wires": []
    },
    {
        "id": "28a14bb787e6f9ff",
        "type": "mqtt out",
        "z": "e8c1d00af083fb50",
        "name": "",
        "topic": "",
        "qos": "1",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "524d0d0f.80da54",
        "x": 3050,
        "y": 180,
        "wires": []
    },
    {
        "id": "a68decf986ec831d",
        "type": "comment",
        "z": "e8c1d00af083fb50",
        "name": "actual working flow.RF FX CALL",
        "info": "",
        "x": 2350,
        "y": 60,
        "wires": []
    },
    {
        "id": "11b4a7091fb62e18",
        "type": "debug",
        "z": "e8c1d00af083fb50",
        "name": "working payload",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 3080,
        "y": 320,
        "wires": []
    },
    {
        "id": "2a6a6aeb7402be97",
        "type": "debug",
        "z": "e8c1d00af083fb50",
        "name": "working topic",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "topic",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2730,
        "y": 340,
        "wires": []
    },
    {
        "id": "896ef8a1fdb18123",
        "type": "delay",
        "z": "e8c1d00af083fb50",
        "name": "",
        "pauseType": "delay",
        "timeout": "2",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 2620,
        "y": 240,
        "wires": [
            [
                "6127146489898bc6"
            ]
        ]
    },
    {
        "id": "7827b53646523704",
        "type": "change",
        "z": "e8c1d00af083fb50",
        "name": "off",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "off",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2890,
        "y": 300,
        "wires": [
            [
                "bde328220543c8db",
                "28a14bb787e6f9ff",
                "11b4a7091fb62e18"
            ]
        ]
    },
    {
        "id": "bf43fedc18c80527",
        "type": "function",
        "z": "e8c1d00af083fb50",
        "name": "function 3 with delay 75ms",
        "func": "var beginpay = msg.payload; //get payload code\nmsg.payload = \"on\";\nvar finaltopic = msg.topic; //get topic\n\nconst delay = ms => new Promise(res => setTimeout(res, ms))\n\nfor (i = 0; i < 2; i++) {\n //node.send({\n // payload: `I've waited ${i * 75}ms`,\n //})\n await delay(75)\n}\n\nif (finaltopic == null) { // voorgaand geeft geen topic mee: \n msg.topic = \"home/RF/\" + beginpay; //dan wordt payload topic\n}\nelse { // voorgaand heeft wel topic mee\n\n msg.topic = \"\" + finaltopic; //dan wordt dat topic\n}\nreturn msg;\n\n/*\nconst delay = ms => new Promise(res => setTimeout(res, ms))\n\nfor (i = 0; i < 12; i++) {\n node.send({\n payload: `I've waited ${i*75}ms`,\n })\n await delay(75)\n}\n\n\n\n*/",
        "outputs": 1,
        "noerr": 4,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 2480,
        "y": 300,
        "wires": [
            [
                "2a6a6aeb7402be97",
                "7f0d5d31e8415e38"
            ]
        ]
    },
    {
        "id": "7f0d5d31e8415e38",
        "type": "switch",
        "z": "e8c1d00af083fb50",
        "name": "on1",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "on",
                "vt": "str"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 2690,
        "y": 300,
        "wires": [
            [
                "7827b53646523704"
            ],
            []
        ]
    },
    {
        "id": "96d31f37ce45c385",
        "type": "debug",
        "z": "e8c1d00af083fb50",
        "name": "no output",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 3080,
        "y": 240,
        "wires": []
    },
    {
        "id": "6127146489898bc6",
        "type": "change",
        "z": "e8c1d00af083fb50",
        "name": "pay=delay worked! ",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "delay worked!",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2810,
        "y": 240,
        "wires": [
            [
                "96d31f37ce45c385"
            ]
        ]
    },
    {
        "id": "91c51d4be1e32a64",
        "type": "trigger",
        "z": "e8c1d00af083fb50",
        "name": "",
        "op1": "on",
        "op2": "off",
        "op1type": "str",
        "op2type": "str",
        "duration": "2",
        "extend": false,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 2,
        "x": 2720,
        "y": 60,
        "wires": [
            [
                "bde328220543c8db",
                "28a14bb787e6f9ff",
                "115c2d9d5a8cb3ae"
            ],
            [
                "28a14bb787e6f9ff",
                "bde328220543c8db",
                "5cb6f7e47121cddb"
            ]
        ]
    },
    {
        "id": "25777b9aace66b8b",
        "type": "comment",
        "z": "e8c1d00af083fb50",
        "name": "easiest would be:",
        "info": "",
        "x": 2720,
        "y": 20,
        "wires": []
    },
    {
        "id": "10bd5052d2a7139b",
        "type": "comment",
        "z": "e8c1d00af083fb50",
        "name": "incoming topic: home/RF/cmnd/pirXX payload:on, mostly",
        "info": "from switches which compare RF codes to RFreceivedData",
        "x": 2390,
        "y": 120,
        "wires": []
    },
    {
        "id": "115c2d9d5a8cb3ae",
        "type": "debug",
        "z": "e8c1d00af083fb50",
        "name": "debug 7, works",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 3000,
        "y": 40,
        "wires": []
    },
    {
        "id": "5cb6f7e47121cddb",
        "type": "debug",
        "z": "e8c1d00af083fb50",
        "name": "output 'timeout'; if any.",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 3060,
        "y": 80,
        "wires": []
    },
    {
        "id": "c7119ad2a4d5ba14",
        "type": "inject",
        "z": "e8c1d00af083fb50",
        "name": "test",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "home/RF/cmnd/pir24",
        "payload": "on",
        "payloadType": "str",
        "x": 2330,
        "y": 220,
        "wires": [
            [
                "50ac2e28452bc687"
            ]
        ]
    },
    {
        "id": "524d0d0f.80da54",
        "type": "mqtt-broker",
        "name": "99",
        "broker": "192.168.2.99",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "compatmode": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]

```

result:

```auto
1-12-2023 17:55:45node: debug 7, works
home/RF/cmnd/pir24 : msg.payload : string[2]
"on"
21-12-2023 17:55:45node: working topichome/RF/cmnd/pir24 : msg.topic : string[18]
"home/RF/cmnd/pir24"
21-12-2023 17:55:45node: working payloadhome/RF/cmnd/pir24 : msg.payload : string[3]
"off"
21-12-2023 17:55:47node: no outputhome/RF/cmnd/pir24 : msg.payload : string[13]
"delay worked!"
21-12-2023 17:55:47node: output 'timeout'; if any.home/RF/cmnd/pir24 : msg.payload : string[3]
"off"

```

Delay worked.(once). trigger not though.

```auto
21-12-2023 17:56:51node: debug 7, workshome/RF/cmnd/pir8 : msg.payload : string[2]
"on"
21-12-2023 17:56:53node: working topichome/RF/cmnd/pir8 : msg.topic : string[17]
"home/RF/cmnd/pir8"
21-12-2023 17:56:54node: working payloadhome/RF/cmnd/pir8 : msg.payload : string[3]
"off"
21-12-2023 17:56:55node: working topichome/RF/cmnd/pir8 : msg.topic : string[17]
"home/RF/cmnd/pir8"
21-12-2023 17:56:56node: working payload
home/RF/cmnd/pir8 : msg.payload : string[3]
"off"

```

@Hardware: intel NUC, Celeron j4125, 16Gb RAM, NvmE ssd.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [21 December 2023 17:18 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/9 "2023-12-21T17:18:04Z")

</div>

It all appears to be working as expected to me ?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/6916f6ed5d0ce3fe0d814ff3636420f0af467a81.png)

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [21 December 2023 17:22 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/10 "2023-12-21T17:22:32Z")

</div>

Not sure if you meant to send the off trigger message to a different output though ?

Also if you are expecting it to work with different incoming topics then you need to set it up that way.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/0/90bc5bbb13199b986b301a4eaa987aa2194cb771.png)

---

<div class="post-metadata">

**Author:** ![Dakhaasje](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dakhaasje/32/86107_2.png) [@Dakhaasje](https://discourse.nodered.org/u/Dakhaasje)\
**Post date:** [21 December 2023 18:51 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/11 "2023-12-21T18:51:39Z")

</div>

> [@Sean-McG](#):
>
> Not sure if you meant to send the off trigger message to a different output though ?

Most times I do. as the 2nd output runs different way, won't need to add a switch.  
'handle all messages' does not mean handle all messages then? because all messages have same payload, while a few times the same topic might be coming after another, and I do not want the light go off while I still trigger the Pir. Which then explains why the pir status should go 'off' after the light went on.  
Pir status is kept retained on mqtt, so HA can use them too.

To fool the trigger I can always exchange payload and topic, if that fixes things.

> [@](#):
>
> It all appears to be working as expected to me ?

just for the test it worked, but a moment later a real input came, and it failed.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [21 December 2023 22:35 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/13 "2023-12-21T22:35:08Z")

</div>

Your flow will only work properly for one topic.  
As you had it setup, the first topic to arrive sends on and starts the timer, after 2 seconds the off message is sent. Any messages arriving while the timer is active are ignored.

I have changed the trigger to use each topic. Now each incoming topic will send the on msg, then after 2 seconds an off msg. I have also added the extend delay option, this means that if the same pir(topic) is triggered again within this period, the timer restarts for that pir.

All incoming messages will run their own timers and you can see how many timers are running in the node status.

You will then need to route these messages by their topics to switch the correct light.

```auto
[{"id":"50ac2e28452bc687","type":"change","z":"5a045d978a5b966a","name":"on","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":775,"y":795,"wires":[["91c51d4be1e32a64"]]},{"id":"91c51d4be1e32a64","type":"trigger","z":"5a045d978a5b966a","name":"","op1":"on","op2":"off","op1type":"str","op2type":"str","duration":"2","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"topic","topic":"topic","outputs":2,"x":915,"y":795,"wires":[["115c2d9d5a8cb3ae"],["5cb6f7e47121cddb"]]},{"id":"115c2d9d5a8cb3ae","type":"debug","z":"5a045d978a5b966a","name":"On msgs","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1110,"y":765,"wires":[]},{"id":"5cb6f7e47121cddb","type":"debug","z":"5a045d978a5b966a","name":"Off Msgs","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1110,"y":815,"wires":[]},{"id":"c7119ad2a4d5ba14","type":"inject","z":"5a045d978a5b966a","name":"home/RF/cmnd/pir15","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"home/RF/cmnd/pir15","payload":"on","payloadType":"str","x":550,"y":780,"wires":[["50ac2e28452bc687"]]},{"id":"4908ab0dd960aeac","type":"inject","z":"5a045d978a5b966a","name":"home/RF/cmnd/pir24","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"home/RF/cmnd/pir24","payload":"on","payloadType":"str","x":550,"y":825,"wires":[["50ac2e28452bc687"]]}]

```

---

<div class="post-metadata">

**Author:** ![Dakhaasje](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dakhaasje/32/86107_2.png) [@Dakhaasje](https://discourse.nodered.org/u/Dakhaasje)\
**Post date:** [21 December 2023 23:37 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/14 "2023-12-21T23:37:36Z")

</div>

OK, so I thought I'd done the system a favor by calling the same routine. If not for the delay that idea would have been good.  
Problem should be solved then by putting a trigger behind each and every RF translated flow (purely to put status back to off).  
[new setup triggers](https://ibb.co/jhtdQWR)

---

<div class="post-metadata">

**Author:** ![Dakhaasje](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dakhaasje/32/86107_2.png) [@Dakhaasje](https://discourse.nodered.org/u/Dakhaasje)\
**Post date:** [22 December 2023 13:12 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/15 "2023-12-22T13:12:02Z")

</div>

It is still not working. in mqtt the status remains 'on' for all sensors.

---

<div class="post-metadata">

**Author:** ![Dakhaasje](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dakhaasje/32/86107_2.png) [@Dakhaasje](https://discourse.nodered.org/u/Dakhaasje)\
**Post date:** [23 December 2023 19:29 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/16 "2023-12-23T19:29:53Z")

</div>

[this works. trigger still does not work!](https://ibb.co/CbfBpkr)  
I removed all triggers from all nodes. PC seems to run a bit faster (Firefox at least)

°code removed°  
picture shows my solution, not the problem. For problem code see earlier posts.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 December 2023 20:15 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/17 "2023-12-23T20:15:45Z")

</div>

That code is not importable.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5dff4547eff49c4e9a032051e384c68f2b3773b7.png)

---

<div class="post-metadata">

**Author:** ![Dakhaasje](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dakhaasje/32/86107_2.png) [@Dakhaasje](https://discourse.nodered.org/u/Dakhaasje)\
**Post date:** [23 December 2023 23:51 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/18 "2023-12-23T23:51:52Z")

</div>

> [@jbudd](#):
>
> That code is not importable

removed it.

---

<div class="post-metadata">

**Author:** ![Dakhaasje](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dakhaasje/32/86107_2.png) [@Dakhaasje](https://discourse.nodered.org/u/Dakhaasje)\
**Post date:** [2 January 2024 00:28 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/19 "2024-01-02T00:28:28Z")

</div>

there was one } too many. you should not import unknown code anyway.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 March 2024 00:29 UTC](https://discourse.nodered.org/t/delay-and-trigger-died/83881/20 "2024-03-02T00:29:04Z")

</div>

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