-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathvariable_interval_inject.json
321 lines (321 loc) · 8.29 KB
/
variable_interval_inject.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
[
{
"id": "3234f262056babaf",
"type": "delay",
"z": "f6b1667f7ee0d1b0",
"name": "Recursive delay",
"pauseType": "delayv",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": true,
"outputs": 1,
"x": 780,
"y": 720,
"wires": [
[
"63daa2969066caec",
"572e6832bcf30618"
]
]
},
{
"id": "63daa2969066caec",
"type": "debug",
"z": "f6b1667f7ee0d1b0",
"name": "debug 34",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1020,
"y": 720,
"wires": []
},
{
"id": "d6577d4db9cbded4",
"type": "inject",
"z": "f6b1667f7ee0d1b0",
"name": "1s rate",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "1000",
"payloadType": "num",
"x": 130,
"y": 580,
"wires": [
[
"4158a248e1e2b3e4"
]
]
},
{
"id": "b97d8dcaebe9cc85",
"type": "inject",
"z": "f6b1667f7ee0d1b0",
"name": "2s rate",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "2000",
"payloadType": "num",
"x": 130,
"y": 620,
"wires": [
[
"4158a248e1e2b3e4"
]
]
},
{
"id": "9415f762de6c9ced",
"type": "inject",
"z": "f6b1667f7ee0d1b0",
"name": "5s rate",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "5000",
"payloadType": "num",
"x": 130,
"y": 660,
"wires": [
[
"4158a248e1e2b3e4"
]
]
},
{
"id": "4158a248e1e2b3e4",
"type": "change",
"z": "f6b1667f7ee0d1b0",
"name": "",
"rules": [
{
"t": "set",
"p": "ratelimit",
"pt": "flow",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "tick",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "trigger",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 360,
"y": 620,
"wires": [
[
"b300a73d7dc605ae",
"dc0ddfa85869080c"
]
]
},
{
"id": "572e6832bcf30618",
"type": "change",
"z": "f6b1667f7ee0d1b0",
"name": "",
"rules": [
{
"t": "set",
"p": "delay",
"pt": "msg",
"to": "ratelimit",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 780,
"y": 620,
"wires": [
[
"3234f262056babaf"
]
]
},
{
"id": "bf8022099b6ce347",
"type": "inject",
"z": "f6b1667f7ee0d1b0",
"name": "Stop",
"props": [
{
"p": "reset",
"v": "",
"vt": "date"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 510,
"y": 780,
"wires": [
[
"3234f262056babaf"
]
]
},
{
"id": "966379b5822bea96",
"type": "comment",
"z": "f6b1667f7ee0d1b0",
"name": "Programmable interval inject",
"info": "This flow functions and an inject node, but allows the interval to be changed.\nThe basic principle that the delay node output if fed back to itself through a change node which sets the appropriate delay for each message.\n\nThe 3 sample inject node set the interval to 1s, 2s, 5s. The interval is sent in the msg.payload in milliseconds.\nThese inject nodes can be supplemented with a dashboard input field (slider, dropdown) so it can be controlled from the screen as well.\nThis flow does not start sending out messages when deployed, if that is required, create another inject node with default rate and set to trigger on startup. \nI also added a \"Autostart with saved value\" this should be used if the flow variable is saved to file (in that case update the change nodes to use the file storage) so it can restart the trigger with the last delay value read from the file system (set this inject node to trigger on startup).\n\nThe interval is stored in a flow context variable, and this value is inserted into the message every time by the change node above the delay node. This ensures that if the rate value in the context value changes, it is applied at the next message.\n\nI added the delay 100ms and the msg.reset nodes, because when the rate changes it introduces a new message the recursive loop and that would mess up the timing.\n\n\"Stop\" inject node resets the delay node (deleted the message that keeps triggeting itelf) and stops the process.",
"x": 170,
"y": 520,
"wires": []
},
{
"id": "20fc9533e15a9b16",
"type": "inject",
"z": "f6b1667f7ee0d1b0",
"name": "Autostart with saved value",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "tick",
"payload": "trigger",
"payloadType": "str",
"x": 510,
"y": 560,
"wires": [
[
"572e6832bcf30618"
]
]
},
{
"id": "dc0ddfa85869080c",
"type": "change",
"z": "f6b1667f7ee0d1b0",
"name": "",
"rules": [
{
"t": "set",
"p": "reset",
"pt": "msg",
"to": "reset",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 460,
"y": 720,
"wires": [
[
"3234f262056babaf"
]
]
},
{
"id": "b300a73d7dc605ae",
"type": "delay",
"z": "f6b1667f7ee0d1b0",
"name": "",
"pauseType": "delay",
"timeout": "100",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 550,
"y": 620,
"wires": [
[
"572e6832bcf30618"
]
]
}
]