smart-nodes 0.3.28 → 0.3.30
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/examples/counter.json +496 -0
- package/examples/counter.png +0 -0
- package/hysteresis/hysteresis.js +29 -24
- package/package.json +1 -1
- package/shutter-complex-control/shutter-complex-control.html +6 -6
- package/shutter-control/shutter-control.html +26 -0
- package/shutter-control/shutter-control.js +9 -4
- package/smart_helper.js +3 -12
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "9d9c978b675debee",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "Counter",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "",
|
|
8
|
+
"env": []
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "e688cfeb6611c84b",
|
|
12
|
+
"type": "smart_counter",
|
|
13
|
+
"z": "9d9c978b675debee",
|
|
14
|
+
"name": "",
|
|
15
|
+
"start": "2",
|
|
16
|
+
"step": 1,
|
|
17
|
+
"min": 0,
|
|
18
|
+
"max": 10,
|
|
19
|
+
"out_message": "{}",
|
|
20
|
+
"out_message_type": "null",
|
|
21
|
+
"save_state": false,
|
|
22
|
+
"resend_on_start": false,
|
|
23
|
+
"x": 340,
|
|
24
|
+
"y": 400,
|
|
25
|
+
"wires": [
|
|
26
|
+
[
|
|
27
|
+
"d4751bd39159215b"
|
|
28
|
+
]
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "981a467110229178",
|
|
33
|
+
"type": "inject",
|
|
34
|
+
"z": "9d9c978b675debee",
|
|
35
|
+
"name": "",
|
|
36
|
+
"props": [
|
|
37
|
+
{
|
|
38
|
+
"p": "topic",
|
|
39
|
+
"vt": "str"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"repeat": "",
|
|
43
|
+
"crontab": "",
|
|
44
|
+
"once": false,
|
|
45
|
+
"onceDelay": 0.1,
|
|
46
|
+
"topic": "up",
|
|
47
|
+
"x": 90,
|
|
48
|
+
"y": 60,
|
|
49
|
+
"wires": [
|
|
50
|
+
[
|
|
51
|
+
"e688cfeb6611c84b"
|
|
52
|
+
]
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"id": "d0fe44c296895bb4",
|
|
57
|
+
"type": "inject",
|
|
58
|
+
"z": "9d9c978b675debee",
|
|
59
|
+
"name": "",
|
|
60
|
+
"props": [
|
|
61
|
+
{
|
|
62
|
+
"p": "topic",
|
|
63
|
+
"vt": "str"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"p": "payload"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"repeat": "",
|
|
70
|
+
"crontab": "",
|
|
71
|
+
"once": false,
|
|
72
|
+
"onceDelay": 0.1,
|
|
73
|
+
"topic": "up",
|
|
74
|
+
"payload": "1.5",
|
|
75
|
+
"payloadType": "num",
|
|
76
|
+
"x": 90,
|
|
77
|
+
"y": 100,
|
|
78
|
+
"wires": [
|
|
79
|
+
[
|
|
80
|
+
"e688cfeb6611c84b"
|
|
81
|
+
]
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": "fb0d3b14cb350bac",
|
|
86
|
+
"type": "inject",
|
|
87
|
+
"z": "9d9c978b675debee",
|
|
88
|
+
"name": "",
|
|
89
|
+
"props": [
|
|
90
|
+
{
|
|
91
|
+
"p": "topic",
|
|
92
|
+
"vt": "str"
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"repeat": "",
|
|
96
|
+
"crontab": "",
|
|
97
|
+
"once": false,
|
|
98
|
+
"onceDelay": 0.1,
|
|
99
|
+
"topic": "down",
|
|
100
|
+
"x": 90,
|
|
101
|
+
"y": 200,
|
|
102
|
+
"wires": [
|
|
103
|
+
[
|
|
104
|
+
"e688cfeb6611c84b"
|
|
105
|
+
]
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "3ebc2099e2955079",
|
|
110
|
+
"type": "inject",
|
|
111
|
+
"z": "9d9c978b675debee",
|
|
112
|
+
"name": "",
|
|
113
|
+
"props": [
|
|
114
|
+
{
|
|
115
|
+
"p": "topic",
|
|
116
|
+
"vt": "str"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"p": "payload"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"repeat": "",
|
|
123
|
+
"crontab": "",
|
|
124
|
+
"once": false,
|
|
125
|
+
"onceDelay": 0.1,
|
|
126
|
+
"topic": "down",
|
|
127
|
+
"payload": "1.5",
|
|
128
|
+
"payloadType": "num",
|
|
129
|
+
"x": 100,
|
|
130
|
+
"y": 240,
|
|
131
|
+
"wires": [
|
|
132
|
+
[
|
|
133
|
+
"e688cfeb6611c84b"
|
|
134
|
+
]
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "3ce443c4ac24ac14",
|
|
139
|
+
"type": "inject",
|
|
140
|
+
"z": "9d9c978b675debee",
|
|
141
|
+
"name": "",
|
|
142
|
+
"props": [
|
|
143
|
+
{
|
|
144
|
+
"p": "topic",
|
|
145
|
+
"vt": "str"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"p": "payload"
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
"repeat": "",
|
|
152
|
+
"crontab": "",
|
|
153
|
+
"once": false,
|
|
154
|
+
"onceDelay": 0.1,
|
|
155
|
+
"topic": "up",
|
|
156
|
+
"payload": "2",
|
|
157
|
+
"payloadType": "num",
|
|
158
|
+
"x": 90,
|
|
159
|
+
"y": 140,
|
|
160
|
+
"wires": [
|
|
161
|
+
[
|
|
162
|
+
"e688cfeb6611c84b"
|
|
163
|
+
]
|
|
164
|
+
]
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"id": "f1e7118e2776a3b5",
|
|
168
|
+
"type": "inject",
|
|
169
|
+
"z": "9d9c978b675debee",
|
|
170
|
+
"name": "",
|
|
171
|
+
"props": [
|
|
172
|
+
{
|
|
173
|
+
"p": "topic",
|
|
174
|
+
"vt": "str"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"p": "payload"
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"repeat": "",
|
|
181
|
+
"crontab": "",
|
|
182
|
+
"once": false,
|
|
183
|
+
"onceDelay": 0.1,
|
|
184
|
+
"topic": "down",
|
|
185
|
+
"payload": "2",
|
|
186
|
+
"payloadType": "num",
|
|
187
|
+
"x": 90,
|
|
188
|
+
"y": 280,
|
|
189
|
+
"wires": [
|
|
190
|
+
[
|
|
191
|
+
"e688cfeb6611c84b"
|
|
192
|
+
]
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"id": "aca51576a155a17e",
|
|
197
|
+
"type": "inject",
|
|
198
|
+
"z": "9d9c978b675debee",
|
|
199
|
+
"name": "",
|
|
200
|
+
"props": [
|
|
201
|
+
{
|
|
202
|
+
"p": "topic",
|
|
203
|
+
"vt": "str"
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
"repeat": "",
|
|
207
|
+
"crontab": "",
|
|
208
|
+
"once": false,
|
|
209
|
+
"onceDelay": 0.1,
|
|
210
|
+
"topic": "reset",
|
|
211
|
+
"x": 90,
|
|
212
|
+
"y": 340,
|
|
213
|
+
"wires": [
|
|
214
|
+
[
|
|
215
|
+
"e688cfeb6611c84b"
|
|
216
|
+
]
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"id": "e20ea88652567f8b",
|
|
221
|
+
"type": "inject",
|
|
222
|
+
"z": "9d9c978b675debee",
|
|
223
|
+
"name": "",
|
|
224
|
+
"props": [
|
|
225
|
+
{
|
|
226
|
+
"p": "topic",
|
|
227
|
+
"vt": "str"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"p": "payload"
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
"repeat": "",
|
|
234
|
+
"crontab": "",
|
|
235
|
+
"once": false,
|
|
236
|
+
"onceDelay": 0.1,
|
|
237
|
+
"topic": "reset",
|
|
238
|
+
"payload": "1.5",
|
|
239
|
+
"payloadType": "num",
|
|
240
|
+
"x": 100,
|
|
241
|
+
"y": 420,
|
|
242
|
+
"wires": [
|
|
243
|
+
[
|
|
244
|
+
"e688cfeb6611c84b"
|
|
245
|
+
]
|
|
246
|
+
]
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"id": "a5bf6b4a5422e218",
|
|
250
|
+
"type": "inject",
|
|
251
|
+
"z": "9d9c978b675debee",
|
|
252
|
+
"name": "",
|
|
253
|
+
"props": [
|
|
254
|
+
{
|
|
255
|
+
"p": "topic",
|
|
256
|
+
"vt": "str"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"p": "payload"
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
"repeat": "",
|
|
263
|
+
"crontab": "",
|
|
264
|
+
"once": false,
|
|
265
|
+
"onceDelay": 0.1,
|
|
266
|
+
"topic": "reset",
|
|
267
|
+
"payload": "99",
|
|
268
|
+
"payloadType": "num",
|
|
269
|
+
"x": 100,
|
|
270
|
+
"y": 460,
|
|
271
|
+
"wires": [
|
|
272
|
+
[
|
|
273
|
+
"e688cfeb6611c84b"
|
|
274
|
+
]
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"id": "134cf7d0045dc970",
|
|
279
|
+
"type": "inject",
|
|
280
|
+
"z": "9d9c978b675debee",
|
|
281
|
+
"name": "",
|
|
282
|
+
"props": [
|
|
283
|
+
{
|
|
284
|
+
"p": "topic",
|
|
285
|
+
"vt": "str"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"p": "payload"
|
|
289
|
+
}
|
|
290
|
+
],
|
|
291
|
+
"repeat": "",
|
|
292
|
+
"crontab": "",
|
|
293
|
+
"once": false,
|
|
294
|
+
"onceDelay": 0.1,
|
|
295
|
+
"topic": "reset",
|
|
296
|
+
"payload": "-20",
|
|
297
|
+
"payloadType": "num",
|
|
298
|
+
"x": 100,
|
|
299
|
+
"y": 380,
|
|
300
|
+
"wires": [
|
|
301
|
+
[
|
|
302
|
+
"e688cfeb6611c84b"
|
|
303
|
+
]
|
|
304
|
+
]
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"id": "d4751bd39159215b",
|
|
308
|
+
"type": "debug",
|
|
309
|
+
"z": "9d9c978b675debee",
|
|
310
|
+
"name": "debug 69",
|
|
311
|
+
"active": true,
|
|
312
|
+
"tosidebar": true,
|
|
313
|
+
"console": false,
|
|
314
|
+
"tostatus": false,
|
|
315
|
+
"complete": "false",
|
|
316
|
+
"statusVal": "",
|
|
317
|
+
"statusType": "auto",
|
|
318
|
+
"x": 540,
|
|
319
|
+
"y": 400,
|
|
320
|
+
"wires": []
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"id": "b482f484beca8147",
|
|
324
|
+
"type": "inject",
|
|
325
|
+
"z": "9d9c978b675debee",
|
|
326
|
+
"name": "",
|
|
327
|
+
"props": [
|
|
328
|
+
{
|
|
329
|
+
"p": "topic",
|
|
330
|
+
"vt": "str"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"p": "payload"
|
|
334
|
+
}
|
|
335
|
+
],
|
|
336
|
+
"repeat": "",
|
|
337
|
+
"crontab": "",
|
|
338
|
+
"once": false,
|
|
339
|
+
"onceDelay": 0.1,
|
|
340
|
+
"topic": "set_min",
|
|
341
|
+
"payload": "1",
|
|
342
|
+
"payloadType": "num",
|
|
343
|
+
"x": 100,
|
|
344
|
+
"y": 520,
|
|
345
|
+
"wires": [
|
|
346
|
+
[
|
|
347
|
+
"e688cfeb6611c84b"
|
|
348
|
+
]
|
|
349
|
+
]
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"id": "c5010817a050f00a",
|
|
353
|
+
"type": "inject",
|
|
354
|
+
"z": "9d9c978b675debee",
|
|
355
|
+
"name": "",
|
|
356
|
+
"props": [
|
|
357
|
+
{
|
|
358
|
+
"p": "topic",
|
|
359
|
+
"vt": "str"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"p": "payload"
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
"repeat": "",
|
|
366
|
+
"crontab": "",
|
|
367
|
+
"once": false,
|
|
368
|
+
"onceDelay": 0.1,
|
|
369
|
+
"topic": "set_min",
|
|
370
|
+
"payload": "5",
|
|
371
|
+
"payloadType": "num",
|
|
372
|
+
"x": 100,
|
|
373
|
+
"y": 560,
|
|
374
|
+
"wires": [
|
|
375
|
+
[
|
|
376
|
+
"e688cfeb6611c84b"
|
|
377
|
+
]
|
|
378
|
+
]
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"id": "acdebaad4d5ac676",
|
|
382
|
+
"type": "inject",
|
|
383
|
+
"z": "9d9c978b675debee",
|
|
384
|
+
"name": "",
|
|
385
|
+
"props": [
|
|
386
|
+
{
|
|
387
|
+
"p": "topic",
|
|
388
|
+
"vt": "str"
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
"p": "payload"
|
|
392
|
+
}
|
|
393
|
+
],
|
|
394
|
+
"repeat": "",
|
|
395
|
+
"crontab": "",
|
|
396
|
+
"once": false,
|
|
397
|
+
"onceDelay": 0.1,
|
|
398
|
+
"topic": "set_max",
|
|
399
|
+
"payload": "10",
|
|
400
|
+
"payloadType": "num",
|
|
401
|
+
"x": 110,
|
|
402
|
+
"y": 620,
|
|
403
|
+
"wires": [
|
|
404
|
+
[
|
|
405
|
+
"e688cfeb6611c84b"
|
|
406
|
+
]
|
|
407
|
+
]
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"id": "c84d97247ebee93d",
|
|
411
|
+
"type": "inject",
|
|
412
|
+
"z": "9d9c978b675debee",
|
|
413
|
+
"name": "",
|
|
414
|
+
"props": [
|
|
415
|
+
{
|
|
416
|
+
"p": "topic",
|
|
417
|
+
"vt": "str"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"p": "payload"
|
|
421
|
+
}
|
|
422
|
+
],
|
|
423
|
+
"repeat": "",
|
|
424
|
+
"crontab": "",
|
|
425
|
+
"once": false,
|
|
426
|
+
"onceDelay": 0.1,
|
|
427
|
+
"topic": "set_max",
|
|
428
|
+
"payload": "15",
|
|
429
|
+
"payloadType": "num",
|
|
430
|
+
"x": 110,
|
|
431
|
+
"y": 660,
|
|
432
|
+
"wires": [
|
|
433
|
+
[
|
|
434
|
+
"e688cfeb6611c84b"
|
|
435
|
+
]
|
|
436
|
+
]
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"id": "45b8638dc828680c",
|
|
440
|
+
"type": "inject",
|
|
441
|
+
"z": "9d9c978b675debee",
|
|
442
|
+
"name": "",
|
|
443
|
+
"props": [
|
|
444
|
+
{
|
|
445
|
+
"p": "topic",
|
|
446
|
+
"vt": "str"
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
"p": "payload"
|
|
450
|
+
}
|
|
451
|
+
],
|
|
452
|
+
"repeat": "",
|
|
453
|
+
"crontab": "",
|
|
454
|
+
"once": false,
|
|
455
|
+
"onceDelay": 0.1,
|
|
456
|
+
"topic": "set_step",
|
|
457
|
+
"payload": "1",
|
|
458
|
+
"payloadType": "num",
|
|
459
|
+
"x": 100,
|
|
460
|
+
"y": 720,
|
|
461
|
+
"wires": [
|
|
462
|
+
[
|
|
463
|
+
"e688cfeb6611c84b"
|
|
464
|
+
]
|
|
465
|
+
]
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
"id": "aee3a2499977b9b6",
|
|
469
|
+
"type": "inject",
|
|
470
|
+
"z": "9d9c978b675debee",
|
|
471
|
+
"name": "",
|
|
472
|
+
"props": [
|
|
473
|
+
{
|
|
474
|
+
"p": "topic",
|
|
475
|
+
"vt": "str"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"p": "payload"
|
|
479
|
+
}
|
|
480
|
+
],
|
|
481
|
+
"repeat": "",
|
|
482
|
+
"crontab": "",
|
|
483
|
+
"once": false,
|
|
484
|
+
"onceDelay": 0.1,
|
|
485
|
+
"topic": "set_step",
|
|
486
|
+
"payload": "2",
|
|
487
|
+
"payloadType": "num",
|
|
488
|
+
"x": 100,
|
|
489
|
+
"y": 760,
|
|
490
|
+
"wires": [
|
|
491
|
+
[
|
|
492
|
+
"e688cfeb6611c84b"
|
|
493
|
+
]
|
|
494
|
+
]
|
|
495
|
+
}
|
|
496
|
+
]
|
|
Binary file
|
package/hysteresis/hysteresis.js
CHANGED
|
@@ -87,34 +87,39 @@ module.exports = function (RED)
|
|
|
87
87
|
let result = getResult(value);
|
|
88
88
|
let out_msg = null;
|
|
89
89
|
|
|
90
|
-
//
|
|
91
|
-
if (result)
|
|
92
|
-
out_msg = createMessage(out_higher, config.out_higher_type, msg, value);
|
|
93
|
-
else
|
|
94
|
-
out_msg = createMessage(out_lower, config.out_lower_type, msg, value);
|
|
95
|
-
|
|
96
|
-
// Overwrite automatic values, if not already defined
|
|
97
|
-
if (typeof out_msg.payload === "undefined")
|
|
98
|
-
out_msg.payload = result ?? node_settings.last_result;
|
|
99
|
-
|
|
100
|
-
// Separate outputs if needed
|
|
101
|
-
if (outputs == 2)
|
|
90
|
+
// No change, nothing to send
|
|
91
|
+
if (result !== null)
|
|
102
92
|
{
|
|
93
|
+
// Get custom output message
|
|
103
94
|
if (result)
|
|
104
|
-
out_msg =
|
|
95
|
+
out_msg = createMessage(out_higher, config.out_higher_type, msg, value);
|
|
105
96
|
else
|
|
106
|
-
out_msg =
|
|
97
|
+
out_msg = createMessage(out_lower, config.out_lower_type, msg, value);
|
|
98
|
+
|
|
99
|
+
// Overwrite automatic values, if not already defined
|
|
100
|
+
if (typeof out_msg.payload === "undefined")
|
|
101
|
+
out_msg.payload = result ?? node_settings.last_result;
|
|
102
|
+
|
|
103
|
+
// Separate outputs if needed
|
|
104
|
+
if (outputs == 2)
|
|
105
|
+
{
|
|
106
|
+
if (result)
|
|
107
|
+
out_msg = [out_msg, null];
|
|
108
|
+
else
|
|
109
|
+
out_msg = [null, out_msg];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Send only if needed
|
|
113
|
+
if (send_only_change == false || node_settings.last_result != result)
|
|
114
|
+
node.send(out_msg);
|
|
115
|
+
|
|
116
|
+
node_settings.last_result = result;
|
|
107
117
|
}
|
|
108
118
|
|
|
109
|
-
// Send only if needed
|
|
110
|
-
if (send_only_change == false || node_settings.last_result != result)
|
|
111
|
-
node.send(out_msg);
|
|
112
|
-
|
|
113
119
|
node_settings.last_value = value;
|
|
114
|
-
node_settings.last_result = result;
|
|
115
120
|
node_settings.last_message = out_msg;
|
|
116
121
|
|
|
117
|
-
setStatus();
|
|
122
|
+
setStatus(result === null);
|
|
118
123
|
|
|
119
124
|
if (config.save_state)
|
|
120
125
|
smart_context.set(node.id, node_settings);
|
|
@@ -137,14 +142,14 @@ module.exports = function (RED)
|
|
|
137
142
|
return null;
|
|
138
143
|
}
|
|
139
144
|
|
|
140
|
-
let setStatus =
|
|
145
|
+
let setStatus = noChange =>
|
|
141
146
|
{
|
|
142
|
-
if (
|
|
147
|
+
if (noChange)
|
|
148
|
+
node.status({ fill: node_settings.last_result ? "green" : "red", shape: "ring", text: helper.getCurrentTimeForStatus() + ": No change by value " + node_settings.last_value + "" });
|
|
149
|
+
else if (node_settings.last_result === true)
|
|
143
150
|
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Turned higher by value " + node_settings.last_value + "" });
|
|
144
151
|
else if (node_settings.last_result === false)
|
|
145
152
|
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Turned lower by value " + node_settings.last_value + "" });
|
|
146
|
-
else
|
|
147
|
-
node.status({ fill: node_settings.last_result ? "green" : "red", shape: "ring", text: helper.getCurrentTimeForStatus() + ": No change by value " + node_settings.last_value + "" });
|
|
148
153
|
}
|
|
149
154
|
|
|
150
155
|
let createMessage = (out_msg, out_type, msg, value) =>
|
package/package.json
CHANGED
|
@@ -242,16 +242,16 @@
|
|
|
242
242
|
<div style="max-width: 450px;">Diese Node kann über die eingegebenen Wörter gesteuert werden. Mehrere Wörter werden durch ein Komma getrennt.</div>
|
|
243
243
|
</div>
|
|
244
244
|
<div class="form-row">
|
|
245
|
-
<label for="node-input-max_time_up"><i class="fa fa-clock-o"></i> Zeit auf
|
|
246
|
-
<input id="node-input-max_time_up" placeholder="
|
|
245
|
+
<label for="node-input-max_time_up"><i class="fa fa-clock-o"></i> Zeit auf</label>
|
|
246
|
+
<input id="node-input-max_time_up" placeholder="Komplette Fahrt auf" /> s
|
|
247
247
|
</div>
|
|
248
248
|
<div class="form-row">
|
|
249
|
-
<label for="node-input-max_time_down"><i class="fa fa-clock-o"></i> Zeit ab
|
|
250
|
-
<input id="node-input-max_time_down" placeholder="
|
|
249
|
+
<label for="node-input-max_time_down"><i class="fa fa-clock-o"></i> Zeit ab</label>
|
|
250
|
+
<input id="node-input-max_time_down" placeholder="Komplette Fahrt ab" /> s
|
|
251
251
|
</div>
|
|
252
252
|
<div class="form-row">
|
|
253
|
-
<label for="node-input-revert_time_ms"><i class="fa fa-clock-o"></i> Pause Wechsel
|
|
254
|
-
<input id="node-input-revert_time_ms" placeholder="Pause zwischen
|
|
253
|
+
<label for="node-input-revert_time_ms"><i class="fa fa-clock-o"></i> Pause Wechsel</label>
|
|
254
|
+
<input id="node-input-revert_time_ms" placeholder="Pause zwischen Wechsel" /> ms
|
|
255
255
|
</div>
|
|
256
256
|
<div class="form-row">
|
|
257
257
|
<label for="node-input-alarm_action"><i class="fa fa-exclamation-triangle"></i> Alarm Aktion</label>
|
|
@@ -139,6 +139,7 @@
|
|
|
139
139
|
defaults: {
|
|
140
140
|
name: { value: "" },
|
|
141
141
|
exec_text_names: { value: "" },
|
|
142
|
+
short_time_on_ms: { value: 200 },
|
|
142
143
|
links: { value: [], type: "smart_central-control[]" }
|
|
143
144
|
},
|
|
144
145
|
inputs: 1,
|
|
@@ -154,6 +155,19 @@
|
|
|
154
155
|
let node = this;
|
|
155
156
|
onEditPrepare(this, ["smart_central-control"]);
|
|
156
157
|
initTreeList(node, ["smart_central-control"]);
|
|
158
|
+
|
|
159
|
+
$("#node-input-short_time_on_ms").spinner({
|
|
160
|
+
min: 10,
|
|
161
|
+
change: function (event, ui)
|
|
162
|
+
{
|
|
163
|
+
var value = parseInt(this.value);
|
|
164
|
+
value = isNaN(value) ? 0 : value;
|
|
165
|
+
value = Math.max(value, parseInt($(this).attr("aria-valuemin")));
|
|
166
|
+
// value = Math.min(value, parseInt($(this).attr("aria-valuemax")));
|
|
167
|
+
if (value !== this.value)
|
|
168
|
+
$(this).spinner("value", value);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
157
171
|
},
|
|
158
172
|
onadd: function ()
|
|
159
173
|
{
|
|
@@ -174,6 +188,10 @@
|
|
|
174
188
|
<input id="node-input-exec_text_names" type="text" />
|
|
175
189
|
<div style="max-width: 450px;">Diese Node kann über die eingegebenen Wörter gesteuert werden. Mehrere Wörter werden durch ein Komma getrennt.</div>
|
|
176
190
|
</div>
|
|
191
|
+
<div class="form-row">
|
|
192
|
+
<label for="node-input-short_time_on_ms"><i class="fa fa-clock-o"></i> Zeit kurz</label>
|
|
193
|
+
<input id="node-input-short_time_on_ms" placeholder="200" /> ms
|
|
194
|
+
</div>
|
|
177
195
|
<span><i class="fa fa-link"></i>Dieser Baustein wird von folgenden Zentralbausteinen gesteuert:</span>
|
|
178
196
|
<div class="form-row node-input-link-row node-input-link-rows"></div>
|
|
179
197
|
</script>
|
|
@@ -220,6 +238,14 @@
|
|
|
220
238
|
</td>
|
|
221
239
|
<td>Nein</td>
|
|
222
240
|
</tr>
|
|
241
|
+
<tr>
|
|
242
|
+
<td><code>short_up_down</code></td>
|
|
243
|
+
<td>
|
|
244
|
+
Sendet bei <code>msg.payload = false</code> einen kurzen Hochfahrbefehl und bei <code>msg.payload = true</code> einen kurzen Runterfahrbefehl.<br/>
|
|
245
|
+
Es wird dabei die im Baustein hinterlegte Zeit verwendet. Diese kann aber durch setzen von <code>msg.time_on = 1500</code> oder <code>msg.time_on = "1.5s"</code> einmalig überschrieben werden.
|
|
246
|
+
</td>
|
|
247
|
+
<td>Nein</td>
|
|
248
|
+
</tr>
|
|
223
249
|
<tr>
|
|
224
250
|
<td><code>up</code></td>
|
|
225
251
|
<td>Sendet einen Hochfahrbefehl, falls der Rollladen nicht bereits nach oben fährt. Ggf. wird vorher noch ein Stop-Befehl gesendet.</td>
|
|
@@ -23,6 +23,7 @@ module.exports = function (RED)
|
|
|
23
23
|
}, smart_context.get(node.id));
|
|
24
24
|
|
|
25
25
|
// dynamic config
|
|
26
|
+
let short_time_on_ms = config.short_time_on_ms || 200;
|
|
26
27
|
|
|
27
28
|
// runtime values
|
|
28
29
|
let is_running = false; // remember if shutter is running, this is only recognized when starting within this control or position 0% or 100% is reached.
|
|
@@ -60,7 +61,7 @@ module.exports = function (RED)
|
|
|
60
61
|
var real_topic = helper.getTopicName(msg.topic);
|
|
61
62
|
|
|
62
63
|
// set default topic
|
|
63
|
-
if (!["status", "status_position", "up_down", "up", "up_stop", "down", "down_stop", "stop", "toggle", "position"].includes(real_topic))
|
|
64
|
+
if (!["status", "status_position", "up_down", "up", "up_stop", "down", "down_stop", "stop", "toggle", "position", "short_up_down"].includes(real_topic))
|
|
64
65
|
real_topic = "toggle";
|
|
65
66
|
|
|
66
67
|
// skip if button is released
|
|
@@ -110,6 +111,10 @@ module.exports = function (RED)
|
|
|
110
111
|
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Down" });
|
|
111
112
|
return;
|
|
112
113
|
|
|
114
|
+
case "short_up_down":
|
|
115
|
+
handleTopic({ topic: msg.payload ? "down" : "up", time_on: msg.time_on ?? short_time_on_ms });
|
|
116
|
+
return;
|
|
117
|
+
|
|
113
118
|
case "up":
|
|
114
119
|
node_settings.last_direction_up = true;
|
|
115
120
|
is_running = true;
|
|
@@ -122,7 +127,7 @@ module.exports = function (RED)
|
|
|
122
127
|
is_running = false;
|
|
123
128
|
resultStop = true;
|
|
124
129
|
stopAutoOff();
|
|
125
|
-
node.status({ fill: "
|
|
130
|
+
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Stopped" });
|
|
126
131
|
break;
|
|
127
132
|
|
|
128
133
|
case "down":
|
|
@@ -168,7 +173,7 @@ module.exports = function (RED)
|
|
|
168
173
|
let timeMs = helper.getTimeInMsFromString(msg.time_on);
|
|
169
174
|
if (isNaN(timeMs))
|
|
170
175
|
{
|
|
171
|
-
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Invalid time_on value send: " + msg.time_on });
|
|
176
|
+
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Invalid time_on value send: '" + msg.time_on + "'" });
|
|
172
177
|
return;
|
|
173
178
|
}
|
|
174
179
|
|
|
@@ -184,7 +189,7 @@ module.exports = function (RED)
|
|
|
184
189
|
node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": Wait " + (timeMs / 1000).toFixed(1) + " sec for auto off" });
|
|
185
190
|
max_time_on_timeout = setTimeout(() =>
|
|
186
191
|
{
|
|
187
|
-
node.status({ fill: "
|
|
192
|
+
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Stopped" });
|
|
188
193
|
is_running = false;
|
|
189
194
|
node.send([null, { payload: true }, null]);
|
|
190
195
|
notifyCentral(false);
|
package/smart_helper.js
CHANGED
|
@@ -83,7 +83,7 @@ module.exports = {
|
|
|
83
83
|
*/
|
|
84
84
|
getTimeInMs(value, unit)
|
|
85
85
|
{
|
|
86
|
-
value =
|
|
86
|
+
value = parseFloat(value);
|
|
87
87
|
if (isNaN(value) || value == 0)
|
|
88
88
|
return 0;
|
|
89
89
|
|
|
@@ -157,22 +157,13 @@ module.exports = {
|
|
|
157
157
|
return 0;
|
|
158
158
|
|
|
159
159
|
// Split 123min into ["123", "min"]
|
|
160
|
-
let values = value.match(/^([0-9]+)(ms|s|sec|m|min|h)?$/)
|
|
160
|
+
let values = value.match(/^([0-9]+[,.]?[0-9]*)(ms|s|sec|m|min|h|)?$/);
|
|
161
161
|
|
|
162
162
|
// string doesn't match
|
|
163
163
|
if (values == null)
|
|
164
164
|
return 0;
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
if (values.length == 2)
|
|
168
|
-
return this.getTimeInMs(values[1], "ms");
|
|
169
|
-
|
|
170
|
-
// default is ms
|
|
171
|
-
if (values.length == 3)
|
|
172
|
-
return this.getTimeInMs(values[1], values[2]);
|
|
173
|
-
|
|
174
|
-
// Something went wrong
|
|
175
|
-
return 0;
|
|
166
|
+
return this.getTimeInMs(values[1].replace(",", "."), values[2] || "ms");
|
|
176
167
|
},
|
|
177
168
|
|
|
178
169
|
/**
|