node-red-contrib-boolean-logic-ultimate 1.1.19 → 1.1.20
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
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
|
|
2
1
|

|
|
3
2
|
|
|
4
3
|
[![NPM version][npm-version-image]][npm-url]
|
|
4
|
+
|
|
5
5
|
[![NPM downloads per month][npm-downloads-month-image]][npm-url]
|
|
6
|
+
|
|
6
7
|
[![NPM downloads total][npm-downloads-total-image]][npm-url]
|
|
8
|
+
|
|
7
9
|
[![MIT License][license-image]][license-url]
|
|
10
|
+
|
|
8
11
|
[](https://standardjs.com)
|
|
12
|
+
|
|
9
13
|
[](https://www.paypal.me/techtoday)
|
|
14
|
+
|
|
10
15
|
[![youtube][youtube-image]][youtube-url]
|
|
11
16
|
|
|
12
17
|
A set of Node-RED enhanced boolean logic and utility nodes, with persistent values after reboot. Compatible also with Homeassistant values.
|
|
@@ -15,19 +20,21 @@ A set of Node-RED enhanced boolean logic and utility nodes, with persistent valu
|
|
|
15
20
|
<br/>
|
|
16
21
|
|
|
17
22
|
## CHANGELOG
|
|
18
|
-
|
|
23
|
+
|
|
24
|
+
- See <a href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/blob/master/CHANGELOG.md">here the changelog</a>
|
|
19
25
|
|
|
20
26
|
<br/>
|
|
21
27
|
<br/>
|
|
22
28
|
|
|
23
29
|
### HOME ASSISTANT COMPATIBLES INPUT VALUES
|
|
30
|
+
|
|
24
31
|
Other than true/false, all nodes accepts [Homeassistant](https://www.home-assistant.io) output strings.
|
|
32
|
+
|
|
25
33
|
You can **even add your own input translation word list**, thanks to the translator-config node.
|
|
26
34
|
|
|
27
35
|
<br/>
|
|
28
36
|
<br/>
|
|
29
37
|
|
|
30
|
-
|
|
31
38
|
# BOOLEAN LOGIC
|
|
32
39
|
|
|
33
40
|
<img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/img/bl1.png' width='60%'>
|
|
@@ -47,11 +54,15 @@ You can **even add your own input translation word list**, thanks to the transla
|
|
|
47
54
|
</details>
|
|
48
55
|
|
|
49
56
|
The node performs Boolean logic on the incoming payloads.<br/>
|
|
57
|
+
|
|
50
58
|
The node expects a fixed number of topics (configured in the settings) on which it will operate. It will only output a value
|
|
59
|
+
|
|
51
60
|
when it has seen the expected number of topics. If it ever sees more than the configured number of topics it will log a message then reset its state and start over.<br/>
|
|
61
|
+
|
|
52
62
|
The input message is preserved and passed to the output, changing only the topic and the payload.
|
|
53
63
|
|
|
54
64
|
The node performs some checks on the incoming boolean payloads and outputs all results at the same time, as follow:<br/>
|
|
65
|
+
|
|
55
66
|
- Output "AND": true or false<br/>
|
|
56
67
|
- Output "OR": true or false<br/>
|
|
57
68
|
- Output "XOR": true or false<br/>
|
|
@@ -59,34 +70,32 @@ The node performs some checks on the incoming boolean payloads and outputs all r
|
|
|
59
70
|
If you need ***"NAND"*** or ***"NOR"*** gate, just put an **InvertUltimate** node respectively after the "AND" or "OR" output.
|
|
60
71
|
|
|
61
72
|
The node can have a persistent input: the input values are retained after a node-red reboot. That means, that if you reboot your node-red, you don't need to wait all inputs to arrive and initialize the node, before the node can output a payload.<br/>
|
|
62
|
-
You can also set the default values of the topic inputs.<br/>
|
|
63
|
-
The node can convert arbitrary input values to true/false. It supports Homeassistant string to boolean conversion as well. For enabling auto conversion, please be sure to disable **Reject non boolean (true/false) input values** <br/>
|
|
64
73
|
|
|
74
|
+
You can also set the default values of the topic inputs.<br/>
|
|
65
75
|
|
|
76
|
+
The node can convert arbitrary input values to true/false. It supports Homeassistant string to boolean conversion as well. For enabling auto conversion, please be sure to disable **Reject non boolean (true/false) input values** <br/>
|
|
66
77
|
|
|
67
78
|
### NODE CONFIGURATION
|
|
68
79
|
|
|
69
|
-
|Property|Description|
|
|
70
|
-
|
|
71
|
-
| Inputs count
|
|
72
|
-
| Evaluate
|
|
73
|
-
| Filter output
|
|
74
|
-
| Trigger mode
|
|
75
|
-
| If input states are undefined
|
|
76
|
-
| Remember latest input values after reboot
|
|
80
|
+
| Property | Description |
|
|
81
|
+
| -------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
82
|
+
| Inputs count | Set the number of different topics to be evaluated. The node will output a message to the flow, after this number of *different* topics arrives. *Remember: each input topic must be different. For example, if you set this field to 3, the node expects 3 different topics.* |
|
|
83
|
+
| Evaluate | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
84
|
+
| Filter output | **Output both 'true' and 'false'** results: Standard behaviour, the node will output <b>true</b> and <b>false</b> whenever it receives an input and calculate the boolean logics as output. **Output only 'true'** results: whenever the node receives an input, it outputs a payload <b>true</b> only if the result of the logic is true. <b>False</b> results are filtered out. |
|
|
85
|
+
| Trigger mode | **All topics**: standard behaviour, the node will evaluate each input topic and ouputs the values. At each input change, it will output a msg on the flow. **Single topic + eval other inputs**: the node evaluates all the input topics, but only whenever it receives a msg input with the **specified topic**, it outputs a msg to the flow. |
|
|
86
|
+
| If input states are undefined | Every time you create a node or modify the node, all inputs are set to undefined. This means that the node will wait the arrive of all topics (for example 3 topics, if you've selected 3 topics in the option), before it can output a payload. This can be a problem if your logic must be operative as soon as you deploy the flow. To overcome this problem, you can "initialize" all the undefined inputs with True or False. **Leave undefined**: Standard behaviour, the node will wait all the "undefined" topics to arrive, then starts a flow with the result. **True or False**: The node is immediately operative, by force the initialization of the "undefined" inputs with "true" or "false". |
|
|
87
|
+
| Remember latest input values after reboot | If checked, the input values are retained after a node-red reboot. That means, that if you reboot your node-red, you don't need to wait all inputs to arrive and initialize the node, before the node can output a payload. Every time you modify the node's config, <b>the retained values are cleared</b>. |
|
|
77
88
|
| Reject non boolean (true/false) input values | If checked, the node will accept only boolean true/false values. Otherwise, it will try to convert the payload value to a logic true/false boolean. |
|
|
78
|
-
| Delay evaluation (ms)
|
|
89
|
+
| Delay evaluation (ms) | Delays the evaluation until this time (in milliseconds) is elapsed. Each time a message or "topic trigger message" (see **Trigger mode**) arrives, the delay is restarted. This option is useful for debouncing pourposes or simply for adding some delay. For example, you can turn on a light if the room is occupied for a long time, allowing people to fast transit repeatedly, without the need of turning the light on. Another example, if you have many sensors changing state rapidly, you can wait until these sensor reach a quiet state, then evaluate the inputs. |
|
|
79
90
|
|
|
80
91
|
<br/>
|
|
81
92
|
|
|
82
93
|
**INPUT MSG TO THE NODE**
|
|
83
94
|
|
|
84
|
-
|Input msg|Description|
|
|
85
|
-
|
|
86
|
-
| msg.reset = true | Resets all saved input values to undefined
|
|
87
|
-
| msg.inputcount
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
| Input msg | Description |
|
|
96
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------- |
|
|
97
|
+
| msg.reset = true | Resets all saved input values to undefined |
|
|
98
|
+
| msg.inputcount | Changes the inputs count property. For example, <b>msg.inputcount = 3</b> Whenever you lower the inputcount from a higher number to a lower one, for example from 3 to 2, it's suggested to do a <b>msg.reset=true</b> to reset all stored input values. |
|
|
90
99
|
|
|
91
100
|
<br/>
|
|
92
101
|
<br/>
|
|
@@ -100,25 +109,22 @@ The interrupt flows is able to stop the input messages to exiting the node.
|
|
|
100
109
|
|
|
101
110
|
### NODE CONFIGURATION
|
|
102
111
|
|
|
103
|
-
|Property|Description|
|
|
104
|
-
|
|
112
|
+
| Property | Description |
|
|
113
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------- |
|
|
105
114
|
| Trigger by topic | Whenever the node receives a payload = false from this topic,it stops output messages to the flow. As soon it receives payload = true from this topic, the output messages start to flow out again. The node will output the current stored message plus an added property "isReplay = true", as soon as it receives a ***msg.play = true*** from this topic. The node will clear the current stored message, as soon as it receives a ***msg.reset = true*** from this topic. |
|
|
106
|
-
| With Input
|
|
107
|
-
| Then
|
|
108
|
-
|
|
115
|
+
| With Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
116
|
+
| Then | This property, allow you to auto toggle the selected start state (pass or block) after a timer has elapsed. You can choose from some pre-defined delays. If you have, for example, an Homekit-Bridged nodeset with a thermostat node or security system node in your flow, once node-red restarts, these homekit nodes output a default message to the flow. Just put an InterruptFlow node with a "block at start" behaviour and a toggle delay enabled behind homekit nodes, to temporary stop the chained nodes to receive the unwanted startup message. |
|
|
109
117
|
|
|
110
118
|
<br/>
|
|
111
119
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
120
|
**INPUT MSG WITH "TRIGGER" TOPIC**
|
|
118
121
|
|
|
119
122
|
Pass <code>msg.payload = true</code> to allow messages to pass through</br>
|
|
123
|
+
|
|
120
124
|
Pass <code>msg.payload = false</code> to prevent messages from passing through</br>
|
|
125
|
+
|
|
121
126
|
Pass <code>msg.play = true</code> from a message having the "trigger" topic, to replay the last stored message</br>
|
|
127
|
+
|
|
122
128
|
Pass <code>msg.reset = true</code> from a message having the "trigger" topic, to clear the last stored message</br>
|
|
123
129
|
|
|
124
130
|
<code>
|
|
@@ -150,6 +156,7 @@ See the example below.<br/>
|
|
|
150
156
|
<br/>
|
|
151
157
|
|
|
152
158
|
In this other example, you can see the property "play" in action. This property allow you to replay the last previously stored message.<br/>
|
|
159
|
+
|
|
153
160
|
This allow to save the state of a node and then replay it back whenever you want.<br/>
|
|
154
161
|
|
|
155
162
|
<img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/img/if1.png' width='60%'>
|
|
@@ -169,17 +176,17 @@ This allow to save the state of a node and then replay it back whenever you want
|
|
|
169
176
|
# INVERT ULTIMATE
|
|
170
177
|
|
|
171
178
|
Outputs the inverted input. For example true -> false<br />
|
|
179
|
+
|
|
172
180
|
The input message is preserved and passed to the output, changing only the topic and the payload. If the input message has it's own topic, it'll be preserved as well.<br/>
|
|
173
181
|
|
|
174
182
|
### NODE CONFIGURATION
|
|
175
183
|
|
|
176
|
-
|Property|Description|
|
|
177
|
-
|
|
178
|
-
| Input
|
|
184
|
+
| Property | Description |
|
|
185
|
+
| -------- | ---------------------------------------------------------------------------------------------------- |
|
|
186
|
+
| Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
179
187
|
|
|
180
188
|
<br/>
|
|
181
189
|
|
|
182
|
-
|
|
183
190
|
<br/>
|
|
184
191
|
<br/>
|
|
185
192
|
<br/>
|
|
@@ -189,19 +196,21 @@ The input message is preserved and passed to the output, changing only the topic
|
|
|
189
196
|
# FILTER ULTIMATE
|
|
190
197
|
|
|
191
198
|
This node has 2 outputs.<br />
|
|
199
|
+
|
|
192
200
|
If the input payload is true, the node will send <code>true</code> on output 1 and nothing on output 2<br />
|
|
201
|
+
|
|
193
202
|
If the input payload is false, the node will send nothing on output 1 and <code>false</code> on output 2<br />
|
|
203
|
+
|
|
194
204
|
The input message is preserved and passed to the output, changing only the topic and the payload. If the input message has it's own topic, it'll be preserved as well.<br/>
|
|
195
205
|
|
|
196
206
|
### NODE CONFIGURATION
|
|
197
207
|
|
|
198
|
-
|Property|Description|
|
|
199
|
-
|
|
200
|
-
| Input
|
|
208
|
+
| Property | Description |
|
|
209
|
+
| -------- | ---------------------------------------------------------------------------------------------------- |
|
|
210
|
+
| Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
201
211
|
|
|
202
212
|
<br/>
|
|
203
213
|
|
|
204
|
-
|
|
205
214
|
<br/>
|
|
206
215
|
<br/>
|
|
207
216
|
<br/>
|
|
@@ -211,27 +220,30 @@ The input message is preserved and passed to the output, changing only the topic
|
|
|
211
220
|
# BLINKER ULTIMATE
|
|
212
221
|
|
|
213
222
|
The pourpose of this node is to blink a led or something.<br />
|
|
223
|
+
|
|
214
224
|
output1 : outputs the value true/false<br/>
|
|
225
|
+
|
|
215
226
|
output2 : outputs the inverted value false/true<br/>
|
|
227
|
+
|
|
216
228
|
<br/>
|
|
217
229
|
|
|
218
230
|
### NODE CONFIGURATION
|
|
219
231
|
|
|
220
|
-
|Property|Description|
|
|
221
|
-
|
|
222
|
-
| Input
|
|
232
|
+
| Property | Description |
|
|
233
|
+
| -------- | ---------------------------------------------------------------------------------------------------- |
|
|
234
|
+
| Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
223
235
|
|
|
224
236
|
<br/>
|
|
225
237
|
|
|
226
|
-
|
|
227
238
|
Pass <code>msg.payload = true</code> to start blinking</br>
|
|
239
|
+
|
|
228
240
|
Pass <code>msg.payload = false</code> to stop blinking</br>
|
|
241
|
+
|
|
229
242
|
Pass <code>msg.interval = 2000</code> to change the blinking interval</br>
|
|
230
243
|
|
|
231
244
|
- output1 stop behavior : when the blinker receives the stop message, you can select the behavior of the output1<br/>
|
|
232
245
|
- output2 stop behavior : when the blinker receives the stop message, you can select the behavior of the output2<br/>
|
|
233
246
|
|
|
234
|
-
|
|
235
247
|
<img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/img/blinker.png' width='60%'>
|
|
236
248
|
|
|
237
249
|
<details><summary>CLICK HERE, copy and paste it into your flow</summary>
|
|
@@ -249,17 +261,17 @@ Pass <code>msg.interval = 2000</code> to change the blinking interval</br>
|
|
|
249
261
|
# SIMPLE OUTPUT ULTIMATE
|
|
250
262
|
|
|
251
263
|
The pourpose of this node is to send a message with payload TRUE on the first output and FALSE on second output, independently from the msg input.<br />
|
|
264
|
+
|
|
252
265
|
This is useful if you need to simply send a true or false payload.
|
|
253
266
|
|
|
254
267
|
### NODE CONFIGURATION
|
|
255
268
|
|
|
256
|
-
|Property|Description|
|
|
257
|
-
|
|
258
|
-
| Input
|
|
269
|
+
| Property | Description |
|
|
270
|
+
| -------- | ---------------------------------------------------------------------------------------------------- |
|
|
271
|
+
| Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
259
272
|
|
|
260
273
|
<br/>
|
|
261
274
|
|
|
262
|
-
|
|
263
275
|
<img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/img/SimpleOutput.png' width='60%'>
|
|
264
276
|
|
|
265
277
|
<details><summary>CLICK HERE, copy and paste it into your flow</summary>
|
|
@@ -277,6 +289,7 @@ This is useful if you need to simply send a true or false payload.
|
|
|
277
289
|
# INJECT ULTIMATE
|
|
278
290
|
|
|
279
291
|
The pourpose of this node is to send a message with payload TRUE on the first output, FALSE on second output and a TOGGLE (true/false) on the third output, by pressing the pushbutton.<br />
|
|
292
|
+
|
|
280
293
|
This is useful if you need to simply test your flow.
|
|
281
294
|
|
|
282
295
|
<img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/img/Inject.png' width='60%'>
|
|
@@ -327,15 +340,16 @@ The pourpose of this node is to send a sequence of pulsed commands to for exampl
|
|
|
327
340
|
|
|
328
341
|
### NODE CONFIGURATION
|
|
329
342
|
|
|
330
|
-
|Property|Description|
|
|
331
|
-
|
|
332
|
-
| Input
|
|
343
|
+
| Property | Description |
|
|
344
|
+
| -------- | ---------------------------------------------------------------------------------------------------- |
|
|
345
|
+
| Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
333
346
|
|
|
334
347
|
<br/>
|
|
335
348
|
|
|
336
|
-
|
|
337
349
|
**Avaiable Commands**<br />
|
|
350
|
+
|
|
338
351
|
Commands are to be wrote in the format: command:value. For example ***send:200***, ***wait:2000***. Each row represents a command.<br />
|
|
352
|
+
|
|
339
353
|
<br /><b>send</b><br />
|
|
340
354
|
sends a value. For example: ***send:true*** or ***send:100*** or ***send:Hello***<br />
|
|
341
355
|
<br /><b>wait</b><br />
|
|
@@ -347,7 +361,9 @@ comment. For example: ***// This opens the garage***. The comment are ignored, s
|
|
|
347
361
|
<br />
|
|
348
362
|
|
|
349
363
|
Pass <code>msg.payload = true</code> to the node to start the sequence</br>
|
|
364
|
+
|
|
350
365
|
Pass <code>msg.payload = false</code> to the node to stop the running sequence</br>
|
|
366
|
+
|
|
351
367
|
<br />
|
|
352
368
|
|
|
353
369
|
- Output: the node outputs a message you specified in the command textbox<br/>
|
|
@@ -362,7 +378,6 @@ Pass <code>msg.payload = false</code> to the node to stop the running sequence</
|
|
|
362
378
|
|
|
363
379
|
The pourpose of this node is to do maths on the incoming values. Each incoming message MUST HAVE OWN TOPIC.<br />
|
|
364
380
|
|
|
365
|
-
|
|
366
381
|
<img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/img/sum.png' width='60%'>
|
|
367
382
|
<details><summary>CLICK HERE, copy and paste it into your flow</summary>
|
|
368
383
|
<code>
|
|
@@ -372,13 +387,12 @@ The pourpose of this node is to do maths on the incoming values. Each incoming m
|
|
|
372
387
|
|
|
373
388
|
### NODE CONFIGURATION
|
|
374
389
|
|
|
375
|
-
|Property|Description|
|
|
376
|
-
|
|
377
|
-
| Input
|
|
390
|
+
| Property | Description |
|
|
391
|
+
| -------- | ---------------------------------------------------------------------------------------------------- |
|
|
392
|
+
| Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
378
393
|
|
|
379
394
|
<br/>
|
|
380
395
|
|
|
381
|
-
|
|
382
396
|
**INPUT**<br />
|
|
383
397
|
|
|
384
398
|
<br /><b>msg.reset</b><br />
|
|
@@ -398,6 +412,7 @@ resets the values to zero.
|
|
|
398
412
|
</pre>
|
|
399
413
|
|
|
400
414
|
br/>
|
|
415
|
+
|
|
401
416
|
<br/>
|
|
402
417
|
<br/>
|
|
403
418
|
<br/>
|
|
@@ -407,12 +422,11 @@ br/>
|
|
|
407
422
|
|
|
408
423
|
The pourpose of this node is to toggle between true/false, everytime an inboud message arrives.<br />
|
|
409
424
|
|
|
410
|
-
|
|
411
425
|
### NODE CONFIGURATION
|
|
412
426
|
|
|
413
|
-
|Property|Description|
|
|
414
|
-
|
|
415
|
-
| Input
|
|
427
|
+
| Property | Description |
|
|
428
|
+
| -------- | ---------------------------------------------------------------------------------------------------- |
|
|
429
|
+
| Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
416
430
|
|
|
417
431
|
<br/>
|
|
418
432
|
|
|
@@ -434,26 +448,30 @@ The railway switcher, redirect the incoming messages to one ot the avaiable outp
|
|
|
434
448
|
|
|
435
449
|
### NODE CONFIGURATION
|
|
436
450
|
|
|
437
|
-
|
|
438
|
-
|
|
|
439
|
-
|--|--|
|
|
451
|
+
| Property | Description |
|
|
452
|
+
| -------------- | ---------------------------------------------------------------------------------------------------- |
|
|
440
453
|
| Switcher topic | Whenever the node receives a payload from this **topic**, it redirects the input messages to a choosen output PIN. |
|
|
441
|
-
| With Input
|
|
442
|
-
| Translator
|
|
454
|
+
| With Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
455
|
+
| Translator | Translates the incoming <code>payload</code> value. This allows the compatibility with, for example, **HomeAssistant** nodes. |
|
|
443
456
|
|
|
444
457
|
### Inputs
|
|
445
458
|
|
|
446
459
|
The *Switcher topic* controls where the railway switch must be switched, between the output PINs.
|
|
460
|
+
|
|
447
461
|
Once an output PIN has been choosen, all messages passing through the node will be deviated to te choosen output PIN.
|
|
448
462
|
|
|
449
463
|
: topic (string|number) : this is the topic of the switcher message.
|
|
464
|
+
|
|
450
465
|
: payload (number|boolean) : this is the ouput PIN selector, base 0 (0 is the first output PIN).
|
|
451
466
|
|
|
452
467
|
### JSON switcher message
|
|
453
468
|
|
|
454
469
|
Take the example where you choosen such properties:
|
|
470
|
+
|
|
455
471
|
**Switcher topic**: "switcher"
|
|
472
|
+
|
|
456
473
|
**With Input**: "payload"
|
|
474
|
+
|
|
457
475
|
this JSON input message redirects all input messages to the first PIN
|
|
458
476
|
|
|
459
477
|
```json
|
|
@@ -462,8 +480,9 @@ this JSON input message redirects all input messages to the first PIN
|
|
|
462
480
|
payload:0
|
|
463
481
|
}
|
|
464
482
|
```
|
|
483
|
+
|
|
465
484
|
this JSON input message redirects all input messages to the second PIN
|
|
466
|
-
|
|
485
|
+
|
|
467
486
|
```json
|
|
468
487
|
{
|
|
469
488
|
topic:"switcher",
|
|
@@ -472,7 +491,7 @@ this JSON input message redirects all input messages to the second PIN
|
|
|
472
491
|
```
|
|
473
492
|
|
|
474
493
|
this JSON input message redirects all input messages to the third PIN, and so on...
|
|
475
|
-
|
|
494
|
+
|
|
476
495
|
```json
|
|
477
496
|
{
|
|
478
497
|
topic:"switcher",
|
|
@@ -487,18 +506,46 @@ See the example below.<br/>
|
|
|
487
506
|
<img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/img/railwaySwitch.png' width='60%'>
|
|
488
507
|
|
|
489
508
|
Copy and paste it into your flow
|
|
509
|
+
|
|
490
510
|
```javascript
|
|
491
511
|
[{"id":"8243309f7c926112","type":"RailwaySwitchUltimate","z":"aa3efc585a6c7b9b","name":"Railway Switch","triggertopic":"switcher","initializewith":"3","payloadPropName":"payload","translatorConfig":"","x":350,"y":260,"wires":[["7f5a2c19a9ef64c8"],["5a35a650b225d910"],[],[],[]]},{"id":"d7bbc077bc20f4ea","type":"InjectUltimate","z":"aa3efc585a6c7b9b","name":"Junction switcher to Rail 0","topic":"","curVal":true,"outputJSON":"{ \n\t\"payload\":0,\n\t\"topic\":\"switcher\"\n}","x":350,"y":80,"wires":[[],[],[],["8243309f7c926112"]]},{"id":"5656d0c2ba66ed5e","type":"InjectUltimate","z":"aa3efc585a6c7b9b","name":"Junction switcher to Rail 1","topic":"","curVal":true,"outputJSON":"{ \n\t\"payload\":\"1\",\n\t\"topic\":\"switcher\"\n}","x":350,"y":160,"wires":[[],[],[],["8243309f7c926112"]]},{"id":"2253336fa8374c78","type":"InjectUltimate","z":"aa3efc585a6c7b9b","name":"Train","topic":"","curVal":true,"outputJSON":"{ \n\t\"payload\":\"hello\",\n\t\"topic\":\"I'm a train!\"\n}","x":110,"y":280,"wires":[["8243309f7c926112"],[],[],[]]},{"id":"7f5a2c19a9ef64c8","type":"debug","z":"aa3efc585a6c7b9b","name":"Rail 0","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":590,"y":260,"wires":[]},{"id":"5a35a650b225d910","type":"debug","z":"aa3efc585a6c7b9b","name":"Rail 1","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":590,"y":300,"wires":[]}]
|
|
492
512
|
```
|
|
493
513
|
|
|
514
|
+
<br/>
|
|
515
|
+
<br/>
|
|
516
|
+
<br/>
|
|
517
|
+
<br/>
|
|
518
|
+
|
|
519
|
+
# KALMAN FILTER ULTIMATE
|
|
520
|
+
|
|
521
|
+
## Outputs the Kalman filtered input.
|
|
522
|
+
|
|
523
|
+
Please refer to [this](https://github.com/wouterbulten/kalmanjs) link, on how it works.
|
|
524
|
+
|
|
494
525
|
|
|
495
526
|
|
|
527
|
+

|
|
528
|
+
|
|
529
|
+
| Property | Description |
|
|
530
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------- |
|
|
531
|
+
| Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
532
|
+
| r,q | Kalman's parameters to be set. |
|
|
533
|
+
| Translator Input | Translates the incoming <code>payload</code> value, to true/false. This allows the compatibility with, for example, **HomeAssistant** nodes. |
|
|
534
|
+
|
|
535
|
+
<br/>
|
|
496
536
|
|
|
497
537
|
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
|
|
538
|
+
|
|
498
539
|
[license-url]: https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/LICENSE
|
|
540
|
+
|
|
499
541
|
[npm-url]: https://npmjs.org/package/node-red-contrib-boolean-logic-ultimate
|
|
542
|
+
|
|
500
543
|
[npm-version-image]: https://img.shields.io/npm/v/node-red-contrib-boolean-logic-ultimate.svg
|
|
544
|
+
|
|
501
545
|
[npm-downloads-month-image]: https://img.shields.io/npm/dm/node-red-contrib-boolean-logic-ultimate.svg
|
|
546
|
+
|
|
502
547
|
[npm-downloads-total-image]: https://img.shields.io/npm/dt/node-red-contrib-boolean-logic-ultimate.svg
|
|
548
|
+
|
|
503
549
|
[youtube-image]: https://img.shields.io/badge/Visit%20me-youtube-red
|
|
550
|
+
|
|
504
551
|
[youtube-url]: https://youtube.com/playlist?list=PL9Yh1bjbLAYoRH4IyQB7EL5srHAihiKpy
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('KalmanFilterUltimate', {
|
|
3
|
+
category: 'Boolean Logic Ultimate',
|
|
4
|
+
color: '#ff8080',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: {
|
|
7
|
+
value: "Kalman"
|
|
8
|
+
},
|
|
9
|
+
payloadPropName: { value: "payload", required: false },
|
|
10
|
+
translatorConfig: { type: "translator-config", required: false },
|
|
11
|
+
r: { value: 0.01 },
|
|
12
|
+
q: { value: 3 }
|
|
13
|
+
},
|
|
14
|
+
inputs: 1,
|
|
15
|
+
outputs: 1,
|
|
16
|
+
icon: "swap.png",
|
|
17
|
+
label:
|
|
18
|
+
function () {
|
|
19
|
+
return this.name || "KalmanFilter";
|
|
20
|
+
},
|
|
21
|
+
paletteLabel: function () {
|
|
22
|
+
return "KalmanFilter";
|
|
23
|
+
},
|
|
24
|
+
oneditprepare: function () {
|
|
25
|
+
if ($("#node-input-payloadPropName").val() === "") $("#node-input-payloadPropName").val("payload");
|
|
26
|
+
$("#node-input-payloadPropName").typedInput({ default: 'msg', types: ['msg'] });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<script type="text/html" data-template-name="KalmanFilterUltimate">
|
|
32
|
+
<div class="form-row">
|
|
33
|
+
<b>Kalman Filter Ultimate</b>    <span style="color:red"><i class="fa fa-question-circle"></i> <a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
|
|
34
|
+
   <span style="color:red"><i class="fa fa-youtube-play"></i> <a target="_blank" href="https://youtu.be/A41x8VevZD8"><u>Youtube Sample</u></a></span>
|
|
35
|
+
<br/>
|
|
36
|
+
<br/>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="form-row">
|
|
39
|
+
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
|
40
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
41
|
+
</div>
|
|
42
|
+
<div class="form-row">
|
|
43
|
+
<label for="node-input-payloadPropName"><i class="fa fa-ellipsis-h"></i> Input</label>
|
|
44
|
+
<input type="text" id="node-input-payloadPropName">
|
|
45
|
+
</div>
|
|
46
|
+
<div class="form-row">
|
|
47
|
+
<label for="node-input-r"><i class="icon-tag"></i> R</label>
|
|
48
|
+
<input type="text" id="node-input-r" placeholder="0.01">
|
|
49
|
+
</div>
|
|
50
|
+
<div class="form-row">
|
|
51
|
+
<label for="node-input-q"><i class="icon-tag"></i> Q</label>
|
|
52
|
+
<input type="text" id="node-input-q" placeholder="3">
|
|
53
|
+
</div>
|
|
54
|
+
<div class="form-row">
|
|
55
|
+
<br />
|
|
56
|
+
<b>Translator</b>
|
|
57
|
+
<br />
|
|
58
|
+
<label for="node-input-translatorConfig">
|
|
59
|
+
<font color="green" size="4px"><i class="fa fa-sign-in" aria-hidden="true"></i></font> Input
|
|
60
|
+
</label>
|
|
61
|
+
<input type="text" id="node-input-translatorConfig" />
|
|
62
|
+
</div>
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<script type="text/markdown" data-help-name="KalmanFilterUltimate">
|
|
66
|
+
<p>Outputs the Kalman filtered input.</p>
|
|
67
|
+
|
|
68
|
+
Please refer to [this](https://github.com/wouterbulten/kalmanjs) link, on how it works.
|
|
69
|
+
|
|
70
|
+
|Property|Description|
|
|
71
|
+
|--|--|
|
|
72
|
+
| Input | It's the msg property to be evaluated. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
|
|
73
|
+
| r,q | Kalman's parameters to be set. |
|
|
74
|
+
| Translator Input | Translates the incoming <code>payload</code> value, to true/false. This allows the compatibility with, for example, **HomeAssistant** nodes. |
|
|
75
|
+
|
|
76
|
+
<br/>
|
|
77
|
+
|
|
78
|
+
[Find it useful?](https://www.paypal.me/techtoday)
|
|
79
|
+
|
|
80
|
+
</script>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module.exports = function (RED) {
|
|
2
|
+
function KalmanFilterUltimate(config) {
|
|
3
|
+
RED.nodes.createNode(this, config);
|
|
4
|
+
this.config = config;
|
|
5
|
+
var node = this;
|
|
6
|
+
const KalmanFilter = require('kalmanjs');
|
|
7
|
+
try {
|
|
8
|
+
var kalmanFilter = new KalmanFilter({ R: config.R || 0.01, Q: config.Q || 3 });
|
|
9
|
+
} catch (error) {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
function setNodeStatus({ fill, shape, text }) {
|
|
14
|
+
let dDate = new Date();
|
|
15
|
+
node.status({
|
|
16
|
+
fill: fill,
|
|
17
|
+
shape: shape,
|
|
18
|
+
text:
|
|
19
|
+
text +
|
|
20
|
+
" (" +
|
|
21
|
+
dDate.getDate() +
|
|
22
|
+
", " +
|
|
23
|
+
dDate.toLocaleTimeString() +
|
|
24
|
+
")",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setNodeStatus({ fill: "grey", shape: "dot", text: "Waiting" });
|
|
29
|
+
|
|
30
|
+
this.on("input", function (msg) {
|
|
31
|
+
// 11/11/2021 Clone input message and replace only relevant topics
|
|
32
|
+
const utils = require("./utils.js");
|
|
33
|
+
let sPayload = utils.fetchFromObject(
|
|
34
|
+
msg,
|
|
35
|
+
config.payloadPropName || "payload"
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// 15/11/2021 inform user about undefined topic or payload
|
|
39
|
+
if (sPayload === undefined) {
|
|
40
|
+
setNodeStatus({
|
|
41
|
+
fill: "red",
|
|
42
|
+
shape: "dot",
|
|
43
|
+
text: "Received invalid payload from " + msg.topic || "",
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
if (sPayload instanceof Array) {
|
|
50
|
+
msg.payload = sPayload.map(function (v) {
|
|
51
|
+
return kalmanFilter.filter(v);
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
msg.payload = kalmanFilter.filter(sPayload);
|
|
55
|
+
}
|
|
56
|
+
setNodeStatus({
|
|
57
|
+
fill: "green",
|
|
58
|
+
shape: "dot",
|
|
59
|
+
text: msg.payload,
|
|
60
|
+
});
|
|
61
|
+
} catch (error) {
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
node.send(msg);
|
|
65
|
+
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
RED.nodes.registerType("KalmanFilterUltimate", KalmanFilterUltimate);
|
|
70
|
+
};
|
|
Binary file
|
package/img/image.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-boolean-logic-ultimate",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"description": "A set of Node-RED enhanced boolean logic and utility nodes, flow interruption, blinker, invert, filter, toggle etc.., with persistent values after reboot. Compatible also with Homeassistant values.",
|
|
5
5
|
"author": "Supergiovane (https://github.com/Supergiovane)",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"fs": "0.0.1-security",
|
|
8
|
-
"path": ">=0.12.7"
|
|
8
|
+
"path": ">=0.12.7",
|
|
9
|
+
"kalmanjs": "1.1.0"
|
|
9
10
|
},
|
|
10
11
|
"keywords": [
|
|
11
12
|
"node-red",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"toggleUltimate": "boolean-logic-ultimate/toggleUltimate.js",
|
|
35
36
|
"RailwaySwitchUltimate": "boolean-logic-ultimate/RailwaySwitchUltimate.js",
|
|
36
37
|
"Comparator": "boolean-logic-ultimate/Comparator.js",
|
|
38
|
+
"KalmanFilterUltimate": "boolean-logic-ultimate/KalmanFilterUltimate.js",
|
|
37
39
|
"translator-config": "boolean-logic-ultimate/translator-config.js"
|
|
38
40
|
}
|
|
39
41
|
}
|