node-red-contrib-event-calc 3.3.3 → 3.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -55
- package/examples/alarm-simulation-example.json +288 -0
- package/examples/change-detection-example.json +448 -0
- package/examples/isa88-batch-example.json +278 -0
- package/examples/opcua-alarm-example.json +516 -0
- package/examples/test-flows.json +723 -0
- package/examples/throughput-test.json +293 -0
- package/nodes/event-alarm.html +252 -0
- package/nodes/event-alarm.js +292 -0
- package/nodes/event-cache.js +84 -33
- package/nodes/event-calc.js +132 -77
- package/nodes/event-flatten.html +53 -0
- package/nodes/event-flatten.js +25 -0
- package/nodes/event-frame.html +192 -0
- package/nodes/event-frame.js +246 -0
- package/nodes/simple-frame.html +125 -0
- package/nodes/simple-frame.js +126 -0
- package/package.json +6 -2
- package/node-red-contrib-event-calc-3.3.2.tgz +0 -0
- package/nul +0 -0
- package/playwright.config.js +0 -22
- package/tests/external-trigger.spec.js +0 -141
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "change-detection-flow",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "Change Detection Example",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Demonstrates hasChanged(), timeSinceLastChange(), now(), and prev() functions.\n\n1. Click 'Send 22' then 'Send 22' again (same value) - hasChanged returns false\n2. Click 'Send 25' (different value) - hasChanged returns true\n3. Watch timeSinceLastChange grow between clicks"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "cache-cd",
|
|
11
|
+
"type": "event-cache",
|
|
12
|
+
"name": "CD Cache",
|
|
13
|
+
"maxEntries": "10000",
|
|
14
|
+
"ttl": "0"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "inject-val-22",
|
|
18
|
+
"type": "inject",
|
|
19
|
+
"z": "change-detection-flow",
|
|
20
|
+
"name": "Send 22",
|
|
21
|
+
"props": [
|
|
22
|
+
{ "p": "topic", "vt": "str" },
|
|
23
|
+
{ "p": "payload" }
|
|
24
|
+
],
|
|
25
|
+
"topic": "sensor/temperature",
|
|
26
|
+
"payload": "22",
|
|
27
|
+
"payloadType": "num",
|
|
28
|
+
"repeat": "",
|
|
29
|
+
"crontab": "",
|
|
30
|
+
"once": false,
|
|
31
|
+
"onceDelay": 0.1,
|
|
32
|
+
"x": 130,
|
|
33
|
+
"y": 100,
|
|
34
|
+
"wires": [["event-in-cd"]]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "inject-val-25",
|
|
38
|
+
"type": "inject",
|
|
39
|
+
"z": "change-detection-flow",
|
|
40
|
+
"name": "Send 25",
|
|
41
|
+
"props": [
|
|
42
|
+
{ "p": "topic", "vt": "str" },
|
|
43
|
+
{ "p": "payload" }
|
|
44
|
+
],
|
|
45
|
+
"topic": "sensor/temperature",
|
|
46
|
+
"payload": "25",
|
|
47
|
+
"payloadType": "num",
|
|
48
|
+
"repeat": "",
|
|
49
|
+
"crontab": "",
|
|
50
|
+
"once": false,
|
|
51
|
+
"onceDelay": 0.1,
|
|
52
|
+
"x": 130,
|
|
53
|
+
"y": 160,
|
|
54
|
+
"wires": [["event-in-cd"]]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "inject-val-30",
|
|
58
|
+
"type": "inject",
|
|
59
|
+
"z": "change-detection-flow",
|
|
60
|
+
"name": "Send 30",
|
|
61
|
+
"props": [
|
|
62
|
+
{ "p": "topic", "vt": "str" },
|
|
63
|
+
{ "p": "payload" }
|
|
64
|
+
],
|
|
65
|
+
"topic": "sensor/temperature",
|
|
66
|
+
"payload": "30",
|
|
67
|
+
"payloadType": "num",
|
|
68
|
+
"repeat": "",
|
|
69
|
+
"crontab": "",
|
|
70
|
+
"once": false,
|
|
71
|
+
"onceDelay": 0.1,
|
|
72
|
+
"x": 130,
|
|
73
|
+
"y": 220,
|
|
74
|
+
"wires": [["event-in-cd"]]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"id": "event-in-cd",
|
|
78
|
+
"type": "event-in",
|
|
79
|
+
"z": "change-detection-flow",
|
|
80
|
+
"name": "",
|
|
81
|
+
"cache": "cache-cd",
|
|
82
|
+
"topicField": "topic",
|
|
83
|
+
"valueField": "payload",
|
|
84
|
+
"x": 330,
|
|
85
|
+
"y": 160,
|
|
86
|
+
"wires": [[]]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "calc-has-changed",
|
|
90
|
+
"type": "event-calc",
|
|
91
|
+
"z": "change-detection-flow",
|
|
92
|
+
"name": "Has Changed?",
|
|
93
|
+
"cache": "cache-cd",
|
|
94
|
+
"inputMappings": [
|
|
95
|
+
{ "name": "temp", "pattern": "sensor/temperature" }
|
|
96
|
+
],
|
|
97
|
+
"expression": "hasChanged('temp')",
|
|
98
|
+
"triggerOn": "any",
|
|
99
|
+
"outputTopic": "calc/has_changed",
|
|
100
|
+
"x": 330,
|
|
101
|
+
"y": 300,
|
|
102
|
+
"wires": [["debug-changed"], []]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "debug-changed",
|
|
106
|
+
"type": "debug",
|
|
107
|
+
"z": "change-detection-flow",
|
|
108
|
+
"name": "hasChanged result",
|
|
109
|
+
"active": true,
|
|
110
|
+
"tosidebar": true,
|
|
111
|
+
"console": false,
|
|
112
|
+
"tostatus": true,
|
|
113
|
+
"complete": "payload",
|
|
114
|
+
"targetType": "msg",
|
|
115
|
+
"statusVal": "payload",
|
|
116
|
+
"statusType": "auto",
|
|
117
|
+
"x": 560,
|
|
118
|
+
"y": 300,
|
|
119
|
+
"wires": []
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "calc-time-since",
|
|
123
|
+
"type": "event-calc",
|
|
124
|
+
"z": "change-detection-flow",
|
|
125
|
+
"name": "Time Since Change (sec)",
|
|
126
|
+
"cache": "cache-cd",
|
|
127
|
+
"inputMappings": [
|
|
128
|
+
{ "name": "temp", "pattern": "sensor/temperature" }
|
|
129
|
+
],
|
|
130
|
+
"expression": "round(timeSinceLastChange('temp') / 1000, 1)",
|
|
131
|
+
"triggerOn": "any",
|
|
132
|
+
"outputTopic": "calc/time_since_change",
|
|
133
|
+
"x": 370,
|
|
134
|
+
"y": 370,
|
|
135
|
+
"wires": [["debug-time-since"], []]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "debug-time-since",
|
|
139
|
+
"type": "debug",
|
|
140
|
+
"z": "change-detection-flow",
|
|
141
|
+
"name": "timeSinceLastChange (s)",
|
|
142
|
+
"active": true,
|
|
143
|
+
"tosidebar": true,
|
|
144
|
+
"console": false,
|
|
145
|
+
"tostatus": true,
|
|
146
|
+
"complete": "payload",
|
|
147
|
+
"targetType": "msg",
|
|
148
|
+
"statusVal": "payload",
|
|
149
|
+
"statusType": "auto",
|
|
150
|
+
"x": 610,
|
|
151
|
+
"y": 370,
|
|
152
|
+
"wires": []
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"id": "calc-prev-value",
|
|
156
|
+
"type": "event-calc",
|
|
157
|
+
"z": "change-detection-flow",
|
|
158
|
+
"name": "Previous Value",
|
|
159
|
+
"cache": "cache-cd",
|
|
160
|
+
"inputMappings": [
|
|
161
|
+
{ "name": "temp", "pattern": "sensor/temperature" }
|
|
162
|
+
],
|
|
163
|
+
"expression": "prev('temp')",
|
|
164
|
+
"triggerOn": "any",
|
|
165
|
+
"outputTopic": "calc/prev_value",
|
|
166
|
+
"x": 340,
|
|
167
|
+
"y": 440,
|
|
168
|
+
"wires": [["debug-prev"], []]
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"id": "debug-prev",
|
|
172
|
+
"type": "debug",
|
|
173
|
+
"z": "change-detection-flow",
|
|
174
|
+
"name": "prev() result",
|
|
175
|
+
"active": true,
|
|
176
|
+
"tosidebar": true,
|
|
177
|
+
"console": false,
|
|
178
|
+
"tostatus": true,
|
|
179
|
+
"complete": "payload",
|
|
180
|
+
"targetType": "msg",
|
|
181
|
+
"statusVal": "payload",
|
|
182
|
+
"statusType": "auto",
|
|
183
|
+
"x": 560,
|
|
184
|
+
"y": 440,
|
|
185
|
+
"wires": []
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"id": "calc-delta",
|
|
189
|
+
"type": "event-calc",
|
|
190
|
+
"z": "change-detection-flow",
|
|
191
|
+
"name": "Delta (current - prev)",
|
|
192
|
+
"cache": "cache-cd",
|
|
193
|
+
"inputMappings": [
|
|
194
|
+
{ "name": "temp", "pattern": "sensor/temperature" }
|
|
195
|
+
],
|
|
196
|
+
"expression": "temp - prev('temp')",
|
|
197
|
+
"triggerOn": "any",
|
|
198
|
+
"outputTopic": "calc/delta",
|
|
199
|
+
"x": 360,
|
|
200
|
+
"y": 510,
|
|
201
|
+
"wires": [["debug-delta"], []]
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"id": "debug-delta",
|
|
205
|
+
"type": "debug",
|
|
206
|
+
"z": "change-detection-flow",
|
|
207
|
+
"name": "delta result",
|
|
208
|
+
"active": true,
|
|
209
|
+
"tosidebar": true,
|
|
210
|
+
"console": false,
|
|
211
|
+
"tostatus": true,
|
|
212
|
+
"complete": "payload",
|
|
213
|
+
"targetType": "msg",
|
|
214
|
+
"statusVal": "payload",
|
|
215
|
+
"statusType": "auto",
|
|
216
|
+
"x": 560,
|
|
217
|
+
"y": 510,
|
|
218
|
+
"wires": []
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"id": "calc-now",
|
|
222
|
+
"type": "event-calc",
|
|
223
|
+
"z": "change-detection-flow",
|
|
224
|
+
"name": "Current Time (now)",
|
|
225
|
+
"cache": "cache-cd",
|
|
226
|
+
"inputMappings": [
|
|
227
|
+
{ "name": "temp", "pattern": "sensor/temperature" }
|
|
228
|
+
],
|
|
229
|
+
"expression": "now()",
|
|
230
|
+
"triggerOn": "any",
|
|
231
|
+
"outputTopic": "calc/now",
|
|
232
|
+
"x": 350,
|
|
233
|
+
"y": 580,
|
|
234
|
+
"wires": [["debug-now"], []]
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"id": "debug-now",
|
|
238
|
+
"type": "debug",
|
|
239
|
+
"z": "change-detection-flow",
|
|
240
|
+
"name": "now() result",
|
|
241
|
+
"active": true,
|
|
242
|
+
"tosidebar": true,
|
|
243
|
+
"console": false,
|
|
244
|
+
"tostatus": true,
|
|
245
|
+
"complete": "payload",
|
|
246
|
+
"targetType": "msg",
|
|
247
|
+
"statusVal": "payload",
|
|
248
|
+
"statusType": "auto",
|
|
249
|
+
"x": 560,
|
|
250
|
+
"y": 580,
|
|
251
|
+
"wires": []
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"id": "comment-cd-1",
|
|
255
|
+
"type": "comment",
|
|
256
|
+
"z": "change-detection-flow",
|
|
257
|
+
"name": "1. Click inject buttons to send values",
|
|
258
|
+
"info": "Send the same value twice to see hasChanged=false.\nSend a different value to see hasChanged=true.",
|
|
259
|
+
"x": 190,
|
|
260
|
+
"y": 40,
|
|
261
|
+
"wires": []
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"id": "comment-cd-2",
|
|
265
|
+
"type": "comment",
|
|
266
|
+
"z": "change-detection-flow",
|
|
267
|
+
"name": "2. Watch debug panel for results of each function",
|
|
268
|
+
"info": "",
|
|
269
|
+
"x": 600,
|
|
270
|
+
"y": 40,
|
|
271
|
+
"wires": []
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"id": "comment-cd-3",
|
|
275
|
+
"type": "comment",
|
|
276
|
+
"z": "change-detection-flow",
|
|
277
|
+
"name": "--- Date/Time Functions ---",
|
|
278
|
+
"info": "hour(), minute(), day(), isWeekday(), isWeekend(), hoursBetween(start, end)",
|
|
279
|
+
"x": 170,
|
|
280
|
+
"y": 660,
|
|
281
|
+
"wires": []
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"id": "calc-hour",
|
|
285
|
+
"type": "event-calc",
|
|
286
|
+
"z": "change-detection-flow",
|
|
287
|
+
"name": "Current Hour",
|
|
288
|
+
"cache": "cache-cd",
|
|
289
|
+
"inputMappings": [
|
|
290
|
+
{ "name": "temp", "pattern": "sensor/temperature" }
|
|
291
|
+
],
|
|
292
|
+
"expression": "hour()",
|
|
293
|
+
"triggerOn": "any",
|
|
294
|
+
"outputTopic": "calc/hour",
|
|
295
|
+
"x": 330,
|
|
296
|
+
"y": 710,
|
|
297
|
+
"wires": [["debug-hour"], []]
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"id": "debug-hour",
|
|
301
|
+
"type": "debug",
|
|
302
|
+
"z": "change-detection-flow",
|
|
303
|
+
"name": "hour() result",
|
|
304
|
+
"active": true,
|
|
305
|
+
"tosidebar": true,
|
|
306
|
+
"console": false,
|
|
307
|
+
"tostatus": true,
|
|
308
|
+
"complete": "payload",
|
|
309
|
+
"targetType": "msg",
|
|
310
|
+
"statusVal": "payload",
|
|
311
|
+
"statusType": "auto",
|
|
312
|
+
"x": 560,
|
|
313
|
+
"y": 710,
|
|
314
|
+
"wires": []
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"id": "calc-day",
|
|
318
|
+
"type": "event-calc",
|
|
319
|
+
"z": "change-detection-flow",
|
|
320
|
+
"name": "Day of Week (0=Sun)",
|
|
321
|
+
"cache": "cache-cd",
|
|
322
|
+
"inputMappings": [
|
|
323
|
+
{ "name": "temp", "pattern": "sensor/temperature" }
|
|
324
|
+
],
|
|
325
|
+
"expression": "day()",
|
|
326
|
+
"triggerOn": "any",
|
|
327
|
+
"outputTopic": "calc/day",
|
|
328
|
+
"x": 350,
|
|
329
|
+
"y": 780,
|
|
330
|
+
"wires": [["debug-day"], []]
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"id": "debug-day",
|
|
334
|
+
"type": "debug",
|
|
335
|
+
"z": "change-detection-flow",
|
|
336
|
+
"name": "day() result",
|
|
337
|
+
"active": true,
|
|
338
|
+
"tosidebar": true,
|
|
339
|
+
"console": false,
|
|
340
|
+
"tostatus": true,
|
|
341
|
+
"complete": "payload",
|
|
342
|
+
"targetType": "msg",
|
|
343
|
+
"statusVal": "payload",
|
|
344
|
+
"statusType": "auto",
|
|
345
|
+
"x": 560,
|
|
346
|
+
"y": 780,
|
|
347
|
+
"wires": []
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"id": "calc-is-weekday",
|
|
351
|
+
"type": "event-calc",
|
|
352
|
+
"z": "change-detection-flow",
|
|
353
|
+
"name": "Is Weekday?",
|
|
354
|
+
"cache": "cache-cd",
|
|
355
|
+
"inputMappings": [
|
|
356
|
+
{ "name": "temp", "pattern": "sensor/temperature" }
|
|
357
|
+
],
|
|
358
|
+
"expression": "isWeekday()",
|
|
359
|
+
"triggerOn": "any",
|
|
360
|
+
"outputTopic": "calc/is_weekday",
|
|
361
|
+
"x": 330,
|
|
362
|
+
"y": 850,
|
|
363
|
+
"wires": [["debug-weekday"], []]
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"id": "debug-weekday",
|
|
367
|
+
"type": "debug",
|
|
368
|
+
"z": "change-detection-flow",
|
|
369
|
+
"name": "isWeekday() result",
|
|
370
|
+
"active": true,
|
|
371
|
+
"tosidebar": true,
|
|
372
|
+
"console": false,
|
|
373
|
+
"tostatus": true,
|
|
374
|
+
"complete": "payload",
|
|
375
|
+
"targetType": "msg",
|
|
376
|
+
"statusVal": "payload",
|
|
377
|
+
"statusType": "auto",
|
|
378
|
+
"x": 570,
|
|
379
|
+
"y": 850,
|
|
380
|
+
"wires": []
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
"id": "calc-business-hours",
|
|
384
|
+
"type": "event-calc",
|
|
385
|
+
"z": "change-detection-flow",
|
|
386
|
+
"name": "Business Hours? (8-18)",
|
|
387
|
+
"cache": "cache-cd",
|
|
388
|
+
"inputMappings": [
|
|
389
|
+
{ "name": "temp", "pattern": "sensor/temperature" }
|
|
390
|
+
],
|
|
391
|
+
"expression": "isWeekday() && hoursBetween(8, 18)",
|
|
392
|
+
"triggerOn": "any",
|
|
393
|
+
"outputTopic": "calc/business_hours",
|
|
394
|
+
"x": 370,
|
|
395
|
+
"y": 920,
|
|
396
|
+
"wires": [["debug-business"], []]
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"id": "debug-business",
|
|
400
|
+
"type": "debug",
|
|
401
|
+
"z": "change-detection-flow",
|
|
402
|
+
"name": "business hours result",
|
|
403
|
+
"active": true,
|
|
404
|
+
"tosidebar": true,
|
|
405
|
+
"console": false,
|
|
406
|
+
"tostatus": true,
|
|
407
|
+
"complete": "payload",
|
|
408
|
+
"targetType": "msg",
|
|
409
|
+
"statusVal": "payload",
|
|
410
|
+
"statusType": "auto",
|
|
411
|
+
"x": 590,
|
|
412
|
+
"y": 920,
|
|
413
|
+
"wires": []
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
"id": "calc-night-shift",
|
|
417
|
+
"type": "event-calc",
|
|
418
|
+
"z": "change-detection-flow",
|
|
419
|
+
"name": "Night Shift? (22-6)",
|
|
420
|
+
"cache": "cache-cd",
|
|
421
|
+
"inputMappings": [
|
|
422
|
+
{ "name": "temp", "pattern": "sensor/temperature" }
|
|
423
|
+
],
|
|
424
|
+
"expression": "hoursBetween(22, 6)",
|
|
425
|
+
"triggerOn": "any",
|
|
426
|
+
"outputTopic": "calc/night_shift",
|
|
427
|
+
"x": 360,
|
|
428
|
+
"y": 990,
|
|
429
|
+
"wires": [["debug-night"], []]
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"id": "debug-night",
|
|
433
|
+
"type": "debug",
|
|
434
|
+
"z": "change-detection-flow",
|
|
435
|
+
"name": "night shift result",
|
|
436
|
+
"active": true,
|
|
437
|
+
"tosidebar": true,
|
|
438
|
+
"console": false,
|
|
439
|
+
"tostatus": true,
|
|
440
|
+
"complete": "payload",
|
|
441
|
+
"targetType": "msg",
|
|
442
|
+
"statusVal": "payload",
|
|
443
|
+
"statusType": "auto",
|
|
444
|
+
"x": 580,
|
|
445
|
+
"y": 990,
|
|
446
|
+
"wires": []
|
|
447
|
+
}
|
|
448
|
+
]
|