Can I use a variable?

Hi,
I now have 20 gauges each with a trigger that sends a 0 to the gauges if I have no mqtt coming in within a certain time, now from time to time I need to change the time on the triggers to help with troubleshooting etc, my question is can a variable be used in the trigger node as changing the time in 20 nodes is so time consuming

Thanks
Stuart

Click the trigger node once and select the help panel:

image

It will describe what the node accepts as input: msg.delay

delay number

Sets the delay, in milliseconds, to be applied to the message. This option only applies if the node is configured to allow the message to override the configured default delay interval.

You can use one trigger node if you set it to each msg.topic, you then use a switch node to direct to correct gauge.
You can also feed in different delays for each topic if you wish.
e.g.

[{"id":"46e9ca6abf0bc688","type":"inject","z":"d1395164b4eec73e","name":"mqtt in topic1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic1","payload":"1","payloadType":"num","x":670,"y":7600,"wires":[["7916fa6baec05626","397818ab07c739a7"]]},{"id":"7916fa6baec05626","type":"debug","z":"d1395164b4eec73e","name":"gauge 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1000,"y":7600,"wires":[]},{"id":"397818ab07c739a7","type":"trigger","z":"d1395164b4eec73e","name":"","op1":"","op2":"0","op1type":"nul","op2type":"num","duration":"5","extend":true,"overrideDelay":true,"units":"s","reset":"","bytopic":"topic","topic":"topic","outputs":1,"x":740,"y":7520,"wires":[["2edb09d7971cfe2e"]]},{"id":"2edb09d7971cfe2e","type":"switch","z":"d1395164b4eec73e","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"topic1","vt":"str"},{"t":"eq","v":"topic2","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":930,"y":7520,"wires":[["7916fa6baec05626"],["200e33fad41b9463"]]},{"id":"3312c19a6f0d2b35","type":"inject","z":"d1395164b4eec73e","name":"mqtt in topic 2","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"delay","v":"10000","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic2","payload":"2","payloadType":"num","x":670,"y":7660,"wires":[["200e33fad41b9463","397818ab07c739a7"]]},{"id":"200e33fad41b9463","type":"debug","z":"d1395164b4eec73e","name":"gauge 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1000,"y":7660,"wires":[]}]

Hi bakman2,

Thanks for the info

Stuart

Hi E1cid again,

I had a look at the trigger and I don't think it allows a variable for the time as there is no dropdown box offering variables, I will have a look at your method and see if i can work something out

Thanks
Stuart

The variable is in the inject node msg.delay, topic 2 is set to 10 seconds. Topic one has no delay property so will use the 5 seconds set in the trigger node.

Or you could use an environment variable, which you can set in settings.js, or outside the node-red environment.

Thanks for the explanation E1cid, I love learning how different things work in Node-Red

Stuart

Hi Colin,
Thanks for your info too, I thought of variables because I have used them in the past when tinkering with Basic
Thanks
Stuart