# Trigger node expected behavior

**URL:** <https://discourse.nodered.org/t/trigger-node-expected-behavior/48563>\
**Category:** General\
**Created:** [19 July 2021 05:59 UTC](https://discourse.nodered.org/t/trigger-node-expected-behavior/48563 "2021-07-19T05:59:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrei-tatar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei-tatar/32/3780_2.png) [@andrei-tatar](https://discourse.nodered.org/u/andrei-tatar)\
**Post date:** [19 July 2021 05:59 UTC](https://discourse.nodered.org/t/trigger-node-expected-behavior/48563/1 "2021-07-19T05:59:08Z")

</div>

Hey,

I'm having a problem with the trigger node and I'm not quite sure if it's the way it's meant to work or a bug.

The functionality I'm trying to achieve is:

- forward all messages
- if no message has arrived for 5 mins, set offline mode

Does the trigger node swallow all messages (except the first one) or should it always forward the input message when configured to send the input message?

```auto
[{"id":"50923526.944fbc","type":"trigger","z":"60e86883.187908","name":"","op1":"","op2":"{\"online\": false}","op1type":"pay","op2type":"json","duration":"5","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"topic","topic":"topic","outputs":1,"x":550,"y":140,"wires":[["2600df68.b08ce"]]},{"id":"540ee0c9.953ba","type":"function","z":"60e86883.187908","name":"Map","func":"return {\n payload: {\n on: msg.payload.state === 'ON',\n online: true,\n },\n topic: msg.topic,\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":140,"wires":[["50923526.944fbc","398563bd.8873ec"]]},{"id":"c1e5338b.31e34","type":"mqtt in","z":"60e86883.187908","name":"","topic":"zigbee2mqtt/light/+","qos":"2","datatype":"json","broker":"f569d34c.8c7ed","nl":false,"rap":true,"rh":0,"x":150,"y":140,"wires":[["540ee0c9.953ba"]]},{"id":"2600df68.b08ce","type":"debug","z":"60e86883.187908","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":140,"wires":[]},{"id":"398563bd.8873ec","type":"debug","z":"60e86883.187908","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":80,"wires":[]},{"id":"f569d34c.8c7ed","type":"mqtt-broker","name":"","broker":"localhost","port":"1883","clientid":"node-red","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

```

Cheers!

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [19 July 2021 06:47 UTC](https://discourse.nodered.org/t/trigger-node-expected-behavior/48563/2 "2021-07-19T06:47:37Z")

</div>

> [@andrei-tatar](#):
>
> if no message has arrived for 5 mins, set offline mode

The wait 5 min then do something part works (when I add in an inject and shorten time for testing)... you should see a blue dot under the `Trigger` node as it is counting down, and yes, it passes on the msg that "triggered" it.

It is the something that you want done that is confusing to me. What exactly do you want to go "offline"?

---

<div class="post-metadata">

**Author:** ![andrei-tatar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei-tatar/32/3780_2.png) [@andrei-tatar](https://discourse.nodered.org/u/andrei-tatar)\
**Post date:** [19 July 2021 07:00 UTC](https://discourse.nodered.org/t/trigger-node-expected-behavior/48563/3 "2021-07-19T07:00:39Z")

</div>

The problem is that if you inject multiple times (within those 5 mins) the message is not forwarded anymore, it just disappears... I'm not sure if that's the intended behavior or a bug.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 July 2021 07:01 UTC](https://discourse.nodered.org/t/trigger-node-expected-behavior/48563/4 "2021-07-19T07:01:14Z")

</div>

The trigger node does not forward messages received after the first one (until the trigger resets). If you want all messages forwarded then connect them as you have wired the top debug node in your flow. That will receive all messages and the bottom one should see just the offline message.

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [19 July 2021 07:04 UTC](https://discourse.nodered.org/t/trigger-node-expected-behavior/48563/5 "2021-07-19T07:04:24Z")

</div>

I take it literally... as in it "Waits" until time or override.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/c/dc946b80fe0b717c8b7c402666196cd1ec9d9893.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 July 2021 07:10 UTC](https://discourse.nodered.org/t/trigger-node-expected-behavior/48563/6 "2021-07-19T07:10:29Z")

</div>

Set the trigger to not pass the initial payload, . Then bypass the trigger with a wire  
e.g.

```auto
[{"id":"1e9edc1d.fb0d8c","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload.state","v":"ON","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/test","x":140,"y":3140,"wires":[["540ee0c9.953ba"]]},{"id":"540ee0c9.953ba","type":"function","z":"c74669a0.6a34f8","name":"Map","func":"return {\n payload: {\n on: msg.payload.state === 'ON',\n online: true,\n },\n topic: msg.topic,\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":3140,"wires":[["50923526.944fbc","2600df68.b08ce"]]},{"id":"50923526.944fbc","type":"trigger","z":"c74669a0.6a34f8","name":"","op1":"","op2":"{\"online\": false}","op1type":"nul","op2type":"json","duration":"5","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"topic","topic":"topic","outputs":1,"x":470,"y":3180,"wires":[["2600df68.b08ce"]]},{"id":"2600df68.b08ce","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":3140,"wires":[]}]

```

I set the trigger to 5 seconds for testing

---

<div class="post-metadata">

**Author:** ![andrei-tatar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei-tatar/32/3780_2.png) [@andrei-tatar](https://discourse.nodered.org/u/andrei-tatar)\
**Post date:** [19 July 2021 07:28 UTC](https://discourse.nodered.org/t/trigger-node-expected-behavior/48563/7 "2021-07-19T07:28:09Z")

</div>

Cool, thanks for the help!

---

<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:** [17 September 2021 07:29 UTC](https://discourse.nodered.org/t/trigger-node-expected-behavior/48563/8 "2021-09-17T07:29:01Z")

</div>

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