# Help on message construction in a TRIGGER node

**URL:** https://discourse.nodered.org/t/help-on-message-construction-in-a-trigger-node/23381
**Category:** General
**Created:** [20 March 2020 23:24 UTC](https://discourse.nodered.org/t/help-on-message-construction-in-a-trigger-node/23381 "2020-03-20T23:24:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [20 March 2020 23:24 UTC](https://discourse.nodered.org/t/help-on-message-construction-in-a-trigger-node/23381/1 "2020-03-20T23:24:30Z")

</div>

This is a broken down flow of my _problem_.

Putting aside the `change` node at the top:

Press the `inject` node and get a message saying 192.168.0.254 is online.

The `trigger` node waits 10 seconds and if nothing is received I want it to send the same message but replace online with offline.

Alas this isn't happening.

--  
Now the top part:

This sets the flow variable `SCAN_FREQUENCY` to 20000. (20 seconds)

I want the _delay_ on the `trigger` node to be twice that value.

It is shown like this because there is no direct connection from how the _SCAN\_FREQUENCY_ is set and the `trigger` node.

The code:

```auto
[{"id":"7b035fc4.696038","type":"inject","z":"a941e919.4a7d88","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":2270,"wires":[["d263b33b.c60ba8"]]},{"id":"d263b33b.c60ba8","type":"change","z":"a941e919.4a7d88","name":"","rules":[{"t":"set","p":"SCAN_TIME","pt":"flow","to":"20000","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":2270,"wires":[[]]},{"id":"ae0a9ed3.61274","type":"function","z":"a941e919.4a7d88","name":"","func":"msg = {\"topic\":\"192.168.0.254\",\n \"host\":\"192.168.0.254\",\n \"_topic\":\"Gateway\",\n \"payload\":\"192.168.0.254 On-line\",\n };\n\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":2380,"wires":[["45d4648.bca2c9c","f302ebc0.037eb8"]]},{"id":"834f8cd5.72dd28","type":"inject","z":"a941e919.4a7d88","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":2380,"wires":[["ae0a9ed3.61274"]]},{"id":"45d4648.bca2c9c","type":"debug","z":"a941e919.4a7d88","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":420,"y":2340,"wires":[]},{"id":"f302ebc0.037eb8","type":"trigger","z":"a941e919.4a7d88","op1":"","op2":"{\"topic\":\"192.168.0.254\",\"host\":\"192.168.0.254\",\"_topic\":\"Gateway\",\"payload\":\"192.168.0.254 Off-line\",\"_msgid\":\"f742073e.b764d8\"}","op1type":"pay","op2type":"json","duration":"10","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":440,"y":2380,"wires":[["598f8ae4.df6c7c"]]},{"id":"598f8ae4.df6c7c","type":"debug","z":"a941e919.4a7d88","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":2340,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [20 March 2020 23:59 UTC](https://discourse.nodered.org/t/help-on-message-construction-in-a-trigger-node/23381/2 "2020-03-20T23:59:40Z")

</div>

Your bottom flow is sending the 'offline' msg, but you have stuck it inside an object inside msg.payload.  
Change the 'Then Send' option to  
 ![Screen Shot 2020-03-20 at 7.40.48 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/1/414ea06cb47d8f5bb3c9b9daeb099e6856722b79.png)  
and your debug will look like:  
 ![Screen Shot 2020-03-20 at 7.40.54 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/b/8bc6af626ec6be323162c807f87791cdade18545.png)

I don't believe that you can dynamically set the delay time

---

<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: [19 May 2020 23:59 UTC](https://discourse.nodered.org/t/help-on-message-construction-in-a-trigger-node/23381/3 "2020-05-19T23:59:50Z")

</div>

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