Node-REDのDelayノードで、待ち時間を変数で与える方法です。
サンプルフロー
フローの解説
injectノードには、msg.delayというプロパティを作成し、待ち時間にしたい数値をmsで入力します。
delayノードは、動作のところで、”msg.delayに遅延を設定”を選択。
以上です。
実行結果
msg.delayを100,000にしたので100秒遅延する状態になっています。
フロー
[{"id":"fe2fe9f2a99032db","type":"debug","z":"be019e09a297a8c6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":880,"wires":[]},{"id":"41b395e3dc37a8d1","type":"inject","z":"be019e09a297a8c6","name":"","props":[{"p":"payload"},{"p":"delay","v":"100000","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":740,"wires":[["3e9d5098f3d9b569"]]},{"id":"3e9d5098f3d9b569","type":"delay","z":"be019e09a297a8c6","name":"","pauseType":"delayv","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":400,"y":820,"wires":[["fe2fe9f2a99032db"]]}]