📋 サンプルフロー(クリックで展開)
参照元:NodeREDエディター内サンプルフロー
[
{
"id": "5de2cee3922f8186",
"type": "tab",
"label": "delay",
"disabled": false,
"info": "",
"env": []
},
{
"id": "c1fce30a7a997845",
"type": "comment",
"z": "5de2cee3922f8186",
"name": "Delay message",
"info": "Delay node can delay sending input message to output port by a specified amount of time.",
"x": 200,
"y": 80,
"wires": []
},
{
"id": "54c1e915df89ce76",
"type": "inject",
"z": "5de2cee3922f8186",
"name": "",
"props": [
{"p": "payload"},
{"p": "topic", "vt": "str"}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Hello, World!",
"payloadType": "str",
"x": 250,
"y": 140,
"wires": [["28cb0141268e5da4", "61d5ac69a4e4d65b"]]
},
{
"id": "61d5ac69a4e4d65b",
"type": "debug",
"z": "5de2cee3922f8186",
"name": "即時出力",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 460,
"y": 140,
"wires": []
},
{
"id": "28cb0141268e5da4",
"type": "delay",
"z": "5de2cee3922f8186",
"name": "",
"pauseType": "delay",
"timeout": "3",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 440,
"y": 200,
"wires": [["2bac60bdace9d64f"]]
},
{
"id": "2bac60bdace9d64f",
"type": "change",
"z": "5de2cee3922f8186",
"name": "Goodbye, World!",
"rules": [{"t": "set", "p": "payload", "pt": "msg", "to": "Goodbye, World!", "tot": "str"}],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 630,
"y": 200,
"wires": [["f2eb7500f8c0d6d3"]]
},
{
"id": "f2eb7500f8c0d6d3",
"type": "debug",
"z": "5de2cee3922f8186",
"name": "3秒後出力",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 830,
"y": 200,
"wires": []
},
{
"id": "c15b8c3e.955ed",
"type": "comment",
"z": "5de2cee3922f8186",
"name": "Delay message by message property",
"info": "Delay node can delay sending input message to output port by a specified amount of time by `msg.delay` property.",
"x": 270,
"y": 280,
"wires": []
},
{
"id": "a5ed5817.9df448",
"type": "inject",
"z": "5de2cee3922f8186",
"name": "1秒遅延",
"props": [
{"p": "payload"},
{"p": "topic", "vt": "str"},
{"p": "delay", "v": "1000", "vt": "num"}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "delay 1s",
"payloadType": "str",
"x": 240,
"y": 340,
"wires": [["5cf53f4.25b7ec", "59b7b67a.a8e888"]]
},
{
"id": "59b7b67a.a8e888",
"type": "debug",
"z": "5de2cee3922f8186",
"name": "即時",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 450,
"y": 340,
"wires": []
},
{
"id": "5cf53f4.25b7ec",
"type": "delay",
"z": "5de2cee3922f8186",
"name": "msg.delay使用",
"pauseType": "delayv",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 460,
"y": 400,
"wires": [["fc989f41.c4114"]]
},
{
"id": "fc989f41.c4114",
"type": "change",
"z": "5de2cee3922f8186",
"name": "Goodbye!",
"rules": [{"t": "set", "p": "payload", "pt": "msg", "to": "Goodbye!", "tot": "str"}],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 400,
"wires": [["74ba3d1c.666034"]]
},
{
"id": "74ba3d1c.666034",
"type": "debug",
"z": "5de2cee3922f8186",
"name": "遅延後",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 820,
"y": 400,
"wires": []
},
{
"id": "6cdf7297.bf5a8c",
"type": "inject",
"z": "5de2cee3922f8186",
"name": "10秒遅延",
"props": [
{"p": "payload"},
{"p": "topic", "vt": "str"},
{"p": "delay", "v": "10000", "vt": "num"}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "delay 10s",
"payloadType": "str",
"x": 240,
"y": 400,
"wires": [["59b7b67a.a8e888", "5cf53f4.25b7ec"]]
},
{
"id": "b0200f61.5efa5",
"type": "comment",
"z": "5de2cee3922f8186",
"name": "Reset or flush pending message",
"info": "Delay node can reset or flush delayed message by sending it a message with `reset` or `flush` property.",
"x": 250,
"y": 500,
"wires": []
},
{
"id": "d5cd8991.e6d2e8",
"type": "inject",
"z": "5de2cee3922f8186",
"name": "メッセージ送信",
"props": [{"p": "payload"}, {"p": "topic", "vt": "str"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Hello, World!",
"payloadType": "str",
"x": 260,
"y": 560,
"wires": [["607f556b.3ec5fc", "fd14cb.2044db38"]]
},
{
"id": "fd14cb.2044db38",
"type": "debug",
"z": "5de2cee3922f8186",
"name": "即時",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 450,
"y": 560,
"wires": []
},
{
"id": "607f556b.3ec5fc",
"type": "delay",
"z": "5de2cee3922f8186",
"name": "10秒遅延",
"pauseType": "delay",
"timeout": "10",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 450,
"y": 620,
"wires": [["d1fc6763.2a30c8"]]
},
{
"id": "d1fc6763.2a30c8",
"type": "change",
"z": "5de2cee3922f8186",
"name": "Goodbye!",
"rules": [{"t": "set", "p": "payload", "pt": "msg", "to": "Goodbye!", "tot": "str"}],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 620,
"y": 620,
"wires": [["15486d4a.80c6f3"]]
},
{
"id": "15486d4a.80c6f3",
"type": "debug",
"z": "5de2cee3922f8186",
"name": "10秒後",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 800,
"y": 620,
"wires": []
},
{
"id": "2b8b28c7.4c8978",
"type": "inject",
"z": "5de2cee3922f8186",
"name": "reset",
"props": [{"p": "topic", "vt": "str"}, {"p": "reset", "v": "true", "vt": "bool"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 230,
"y": 620,
"wires": [["607f556b.3ec5fc"]]
},
{
"id": "3a7e1bec.8bc3d4",
"type": "inject",
"z": "5de2cee3922f8186",
"name": "flush",
"props": [{"p": "topic", "vt": "str"}, {"p": "flush", "v": "true", "vt": "bool"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 230,
"y": 680,
"wires": [["607f556b.3ec5fc"]]
},
{
"id": "2d14f1a7.e776ce",
"type": "comment",
"z": "5de2cee3922f8186",
"name": "Slow down messages passing through a flow",
"info": "Delay node can be used to slow down messages passing through a flow.",
"x": 290,
"y": 760,
"wires": []
},
{
"id": "af78b43e.9817d8",
"type": "inject",
"z": "5de2cee3922f8186",
"name": "配列送信",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[0,1,2,3,4,5,6,7,8,9]",
"payloadType": "json",
"x": 240,
"y": 820,
"wires": [["a35943e3.eaf0a"]]
},
{
"id": "a35943e3.eaf0a",
"type": "split",
"z": "5de2cee3922f8186",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 390,
"y": 820,
"wires": [["23eacc60.7290a4"]]
},
{
"id": "23eacc60.7290a4",
"type": "delay",
"z": "5de2cee3922f8186",
"name": "1msg/秒",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 520,
"y": 820,
"wires": [["b5b7746a.53bf88"]]
},
{
"id": "b5b7746a.53bf88",
"type": "debug",
"z": "5de2cee3922f8186",
"name": "1秒ごと",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"x": 660,
"y": 820,
"wires": []
},
{
"id": "3dc5015b.96c97e",
"type": "comment",
"z": "5de2cee3922f8186",
"name": "Limit rate of message transfer for each topic",
"info": "Delay node can limit of message transmission from input to output port by a specified number of message per a specified time.",
"x": 290,
"y": 900,
"wires": []
},
{
"id": "bdafe4c6.4d5658",
"type": "inject",
"z": "5de2cee3922f8186",
"name": "トピック別データ",
"props": [{"p": "payload"}, {"p": "topic", "vt": "str"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[{\"topic\":\"apple\",\"payload\":1},{\"topic\":\"apple\",\"payload\":2},{\"topic\":\"apple\",\"payload\":3},{\"topic\":\"orange\",\"payload\":1},{\"topic\":\"orange\",\"payload\":2},{\"topic\":\"orange\",\"payload\":3},{\"topic\":\"banana\",\"payload\":1},{\"topic\":\"banana\",\"payload\":2},{\"topic\":\"banana\",\"payload\":3}]",
"payloadType": "json",
"x": 260,
"y": 960,
"wires": [["f86dc462.195818"]]
},
{
"id": "f86dc462.195818",
"type": "split",
"z": "5de2cee3922f8186",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 410,
"y": 960,
"wires": [["9feb3aac.616c38"]]
},
{
"id": "9feb3aac.616c38",
"type": "change",
"z": "5de2cee3922f8186",
"name": "topic設定",
"rules": [
{"t": "set", "p": "topic", "pt": "msg", "to": "payload.topic", "tot": "msg"},
{"t": "set", "p": "payload", "pt": "msg", "to": "payload.payload", "tot": "msg"}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 560,
"y": 960,
"wires": [["e0bdfcc1.cdf48"]]
},
{
"id": "e0bdfcc1.cdf48",
"type": "delay",
"z": "5de2cee3922f8186",
"name": "トピック別最新",
"pauseType": "timed",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "2",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": false,
"outputs": 1,
"x": 740,
"y": 960,
"wires": [["29d8beea.6b37f2"]]
},
{
"id": "29d8beea.6b37f2",
"type": "debug",
"z": "5de2cee3922f8186",
"name": "最新のみ",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "false",
"x": 920,
"y": 960,
"wires": []
}
]
動作: 一定時間遅延させる
遅延時間: 3秒
入力: 10:00:00 に "Hello, World!"
出力: 10:00:03 に "Hello, World!"(3秒後)
動作: msg.delayに指定した時間遅延
(設定画面で「msg.delayで上書き」を選択)
メッセージ1: msg.delay = 1000 → 1秒後に出力
メッセージ2: msg.delay = 10000 → 10秒後に出力
Resetの場合:
1. メッセージを送信(10秒遅延開始)
2. 5秒後にresetを送信
3. 待機中のメッセージは破棄される(出力なし)
Flushの場合:
1. メッセージを送信(10秒遅延開始)
2. 5秒後にflushを送信
3. 待機中のメッセージが即座に出力される
動作: メッセージのレートを制限
レート: 1メッセージ / 1秒
入力: 10個のメッセージを一斉に送信
出力: 1秒ごとに1メッセージずつ出力(10秒かかる)
動作: トピックごとに最新メッセージを送信
レート: 1メッセージ / 2秒
中間メッセージを破棄: ✓
入力:
apple:1 → apple:2 → apple:3
orange:1 → orange:2 → orange:3
banana:1 → banana:2 → banana:3
出力(2秒後):
apple:3(最新のみ)
orange:3(最新のみ)
banana:3(最新のみ)
外部API(1秒に10回まで)への連続リクエスト
↓
Delayノード(レート: 10msg/秒)
↓
HTTP Request → API呼び出し
↓
レート制限エラーを回避しながら大量処理
温度センサー(100ms間隔で送信)
↓
Delayノード(トピック別、1msg/5秒、ドロップ)
↓
最新値のみ5秒ごとにダッシュボードに表示
↓
通信量とCPU負荷を大幅削減
Raspberry Pi起動
↓
Delay 10秒(ネットワーク接続待ち)
↓
Delay 5秒(センサー初期化待ち)
↓
メイン処理開始
※ 起動直後の不安定な状態を回避