Pass a time value to Trigger node

Is it possible to pass a value to a Trigger node to change its delay time?

Basically, I need to have a Numeric widget on my dashboard to set a delay time. Then the Trigger node needs to accept that value and change according to that input.

If it's not possible to do this with the Trigger node, what should I be looking at to put into a Function node, please?

Thank you in advance,
Dax.

Click once on the trigger node, click the documentation tab on the right.
You can set the delay time via msg.delay

Thank you @bakman2. I could never find the documentation on the built-in nodes, so that is awesome to know.

I set up an inject node to the input of a trigger node and I was able to set the delay time correctly, but unfortunately whenever the msg.delay is received, it triggers the Trigger node and causes it to send msg.payload.

Further, the msg.delay is also transmitted from the Trigger node.

Re-reading my original post with my new understanding, I realise I hadn't been completely explicit. This is what I'm trying to create, where Delay Time is set by a Dashboard Numeric input widget and Start trigger is a Dashboard button input widget.

One way would be to use a ui-form node where the form consists of the delay time input and the submit button is your start trigger. Then you will have both items together and can build the message to send to the trigger node.
If you don't like that idea then you can use a Join node to join the two events together into one message. See this article in the cookbook for an example of how to join messages into one object.

Hey Colin, thanks for the reply. Given that the 'Start Trigger' could be either a manual button-press or a signal from another flow, I'm not sure if the ui-node suggestion you made would do the trick.
I will look at that cookbook article and thank you very much for linking it.

All the best,
Dax.

You could store delay in context storage using text input.
Then when button pressed retrieve the delay.
e.g.

[{"id":"de5a53de.c6563","type":"ui_button","z":"9b3f9f31.c45298","name":"","group":"8b5cde76.edd58","order":5,"width":0,"height":0,"passthru":true,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"button payload","payloadType":"str","topic":"topic","topicType":"msg","x":160,"y":880,"wires":[["2239319d.300b26"]]},{"id":"2239319d.300b26","type":"change","z":"9b3f9f31.c45298","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"delay","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":880,"wires":[["8fefddb9.516378"]]},{"id":"c2399d5.1150ce","type":"inject","z":"9b3f9f31.c45298","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":940,"wires":[["de5a53de.c6563"]]},{"id":"8fefddb9.516378","type":"trigger","z":"9b3f9f31.c45298","name":"","op1":"start","op2":"","op1type":"str","op2type":"pay","duration":"250","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":560,"y":880,"wires":[["7ed0502.67c00b"]]},{"id":"7ed0502.67c00b","type":"debug","z":"9b3f9f31.c45298","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":920,"wires":[]},{"id":"f770cf93.e42a6","type":"ui_text_input","z":"9b3f9f31.c45298","name":"","label":"","tooltip":"","group":"8b5cde76.edd58","order":4,"width":0,"height":0,"passthru":true,"mode":"number","delay":"0","topic":"topic","topicType":"msg","x":170,"y":820,"wires":[["ee96b444.32b43"]]},{"id":"c7e6c8f5.e315f","type":"inject","z":"9b3f9f31.c45298","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"3000","payloadType":"num","x":50,"y":780,"wires":[["f770cf93.e42a6"]]},{"id":"ee96b444.32b43","type":"change","z":"9b3f9f31.c45298","name":"","rules":[{"t":"set","p":"delay","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":820,"wires":[[]]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"6","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

The injects are just for testing.

1 Like

Thanks @E1cid, I'll give that a test tomorrow. Thank you!

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