node-red-contrib-boolean-logic-ultimate 1.0.62 → 1.0.63

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/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
 
4
4
  # CHANGELOG
5
5
 
6
+ <p>
7
+ <b>Version 1.0.63</b> September 2023<br/>
8
+ - NEW: Comparator node. Compare the values from 2 input messages.</br>
9
+ </p>
6
10
  <p>
7
11
  <b>Version 1.0.62</b> August 2023<br/>
8
12
  - Math node: added "subtract option".</br>
package/README.md CHANGED
@@ -84,7 +84,7 @@ The node can convert arbitrary input values to true/false. It supports Homeassis
84
84
  |Property|Description|
85
85
  |--|--|
86
86
  | 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.* |
87
- | Evaluate | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
87
+ | 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"* |
88
88
  | 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. |
89
89
  | 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.|
90
90
  | 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".|
@@ -118,7 +118,7 @@ The interrupt flows is able to stop the input messages to exiting the node.
118
118
  |Property|Description|
119
119
  |--|--|
120
120
  | 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. |
121
- | With Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
121
+ | 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"* |
122
122
  | 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.|
123
123
 
124
124
 
@@ -190,7 +190,7 @@ The input message is preserved and passed to the output, changing only the topic
190
190
 
191
191
  |Property|Description|
192
192
  |--|--|
193
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
193
+ | 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"* |
194
194
 
195
195
  <br/>
196
196
 
@@ -212,7 +212,7 @@ The input message is preserved and passed to the output, changing only the topic
212
212
 
213
213
  |Property|Description|
214
214
  |--|--|
215
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
215
+ | 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"* |
216
216
 
217
217
  <br/>
218
218
 
@@ -234,7 +234,7 @@ output2 : outputs the inverted value false/true<br/>
234
234
 
235
235
  |Property|Description|
236
236
  |--|--|
237
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
237
+ | 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"* |
238
238
 
239
239
  <br/>
240
240
 
@@ -270,7 +270,7 @@ This is useful if you need to simply send a true or false payload.
270
270
 
271
271
  |Property|Description|
272
272
  |--|--|
273
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
273
+ | 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"* |
274
274
 
275
275
  <br/>
276
276
 
@@ -344,7 +344,7 @@ The pourpose of this node is to send a sequence of pulsed commands to for exampl
344
344
 
345
345
  |Property|Description|
346
346
  |--|--|
347
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
347
+ | 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"* |
348
348
 
349
349
  <br/>
350
350
 
@@ -389,7 +389,7 @@ The pourpose of this node is to do maths on the incoming values. Each incoming m
389
389
 
390
390
  |Property|Description|
391
391
  |--|--|
392
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
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"* |
393
393
 
394
394
  <br/>
395
395
 
@@ -427,7 +427,7 @@ The pourpose of this node is to toggle between true/false, everytime an inboud m
427
427
 
428
428
  |Property|Description|
429
429
  |--|--|
430
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
430
+ | 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"* |
431
431
 
432
432
  <br/>
433
433
 
@@ -452,7 +452,7 @@ The railway switcher, switches the input msg flow to one ot the two outputs (upp
452
452
  |Property|Description|
453
453
  |--|--|
454
454
  | Switcher topic | Whenever the node receives a payload from this **topic**, it switches the input messages to an output. |
455
- | With Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
455
+ | 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"* |
456
456
  | Then | This property, allow you to auto toggle the selected start state after some time. |
457
457
 
458
458
  <br/>
@@ -86,7 +86,7 @@
86
86
 
87
87
  |Property|Description|
88
88
  |--|--|
89
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
89
+ | 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"* |
90
90
 
91
91
  <br/>
92
92
 
@@ -218,7 +218,7 @@
218
218
  |Property|Description|
219
219
  |--|--|
220
220
  | 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.* |
221
- | Evaluate | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
221
+ | 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"* |
222
222
 
223
223
  <br/>
224
224
 
@@ -0,0 +1,101 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('Comparator', {
3
+ category: 'boolean logic ultimate',
4
+ color: '#ff8080',
5
+ defaults: {
6
+ name: {
7
+ value: "Comparator"
8
+ },
9
+ property: {
10
+ value: "payload"
11
+ },
12
+ math: {
13
+ value: "==="
14
+ },
15
+ topic1: {
16
+ value: "", required: true
17
+ },
18
+ topic2: {
19
+ value: "", required: true
20
+ },
21
+ },
22
+ inputs: 1,
23
+ outputs: 1,
24
+ icon: "font-awesome/fa-arrows-v",
25
+ label:
26
+ function () {
27
+ return this.name || "Comparator";
28
+ },
29
+ paletteLabel: function () {
30
+ return "ComparatorUltimate";
31
+ },
32
+ oneditprepare: function () {
33
+ if ($("#node-input-property").val() === "") $("#node-input-property").val("payload");
34
+ $("#node-input-property").typedInput({ default: 'msg', types: ['msg'] });
35
+ }
36
+ });
37
+ </script>
38
+
39
+ <script type="text/html" data-template-name="Comparator">
40
+ <div class="form-row">
41
+ <b>Comparator</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/fDRsQPu3bG4"><u>Youtube Sample</u></a></span>
42
+ <br/>
43
+ <br/>
44
+ </div>
45
+ <div class="form-row">
46
+ <label for="node-input-name"><i class="icon-tag"></i> Name</label>
47
+ <input type="text" id="node-input-name" placeholder="Topic">
48
+ </div>
49
+ <hr/>
50
+ <div class="form-row">
51
+ <label for="node-input-property"><i class="icon-tag"></i> Input</label>
52
+ <input type="text" id="node-input-property" placeholder="payload">
53
+ </div>
54
+ <div class="form-row">
55
+ <label for="node-input-topic1"><i class="icon-tag"></i> Topic 1</label>
56
+ <input type="text" id="node-input-topic1" placeholder="For example, topic 1">
57
+ </div>
58
+ <div class="form-row">
59
+ <label for="node-input-math"><i class="icon-tag"></i> Operation</label>
60
+ <select type="text" id="node-input-math" placeholder="">
61
+ <option value="===">=== (equals)</option>
62
+ <option value="!==">!== (not equals)</option>
63
+ <option value=">=">></option>
64
+ <option value="<="><</option>
65
+ <option value=">=">>=</option>
66
+ <option value="<="><=</option>
67
+ </select>
68
+ </div>
69
+ <div class="form-row">
70
+ <label for="node-input-topic2"><i class="icon-tag"></i> Topic 2</label>
71
+ <input type="text" id="node-input-topic2" placeholder="For example, topic 2">
72
+ </div>
73
+ </script>
74
+
75
+ <script type="text/markdown" data-help-name="Comparator">
76
+ <p>The Comparator, compares two msg values and outputs true/false.</p>
77
+
78
+ |Property|Description|
79
+ |--|--|
80
+ | Name | It's the node name. This will be also the output topic. |
81
+ | 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"*. It **must** be a numeric value. The node will try to automatically convert numeric values expressed as strings, to real numbers. |
82
+ | Topic 1 | It's the topic to be evaluated against the second topic. |
83
+ | Comparator | It's the comparator. It compares the Topic 1 against the Topic 2. |
84
+ | Topic 2 | It's the second topic to be evaluated against the first topic. |
85
+
86
+ <br/>
87
+
88
+ ### Outputs
89
+
90
+ 1. Standard output
91
+ : payload (boolean) : the standard output of the command.
92
+
93
+ ### Details
94
+
95
+ `msg.payload` is used as the payload of the published message. I'ts true or false based on the result of the compare operation.
96
+
97
+ <br/>
98
+
99
+ [Find it useful?](https://www.paypal.me/techtoday)
100
+
101
+ </script>
@@ -0,0 +1,99 @@
1
+ module.exports = function (RED) {
2
+ function Comparator(config) {
3
+ RED.nodes.createNode(this, config);
4
+ var node = this;
5
+ node.config = config;
6
+ node.math = config.math === undefined ? "===" : config.math;
7
+ node.topic1Value = undefined;
8
+ node.topic2Value = undefined;
9
+
10
+ function setNodeStatus({ fill, shape, text }) {
11
+ let dDate = new Date();
12
+ node.status({
13
+ fill: fill,
14
+ shape: shape,
15
+ text:
16
+ text +
17
+ " (" +
18
+ dDate.getDate() +
19
+ ", " +
20
+ dDate.toLocaleTimeString() +
21
+ ")",
22
+ });
23
+ }
24
+
25
+ setNodeStatus({ fill: "grey", shape: "dot", text: "" });
26
+
27
+ function fetchFromObject(obj, prop) {
28
+ if (obj === undefined) {
29
+ return undefined;
30
+ }
31
+
32
+ var _index = prop.indexOf(".");
33
+ if (_index > -1) {
34
+ return fetchFromObject(
35
+ obj[prop.substring(0, _index)],
36
+ prop.substr(_index + 1)
37
+ );
38
+ }
39
+
40
+ return obj[prop];
41
+ }
42
+
43
+ node.on("input", function (msg) {
44
+ if (!msg.hasOwnProperty("topic")) {
45
+ setNodeStatus({
46
+ fill: "red",
47
+ shape: "ring",
48
+ text: "Incoming msg without topic! Please set the topic.",
49
+ });
50
+ return;
51
+ }
52
+
53
+ try {
54
+ let props = ([] = node.config.property.split("."));
55
+ let ret = fetchFromObject(msg, node.config.property);
56
+ if (ret !== undefined) {
57
+ ret = Number(ret);
58
+
59
+ // Sum
60
+ if (!isNaN(ret) && isFinite(ret)) {
61
+ if (msg.topic === node.config.topic1) node.topic1Value = ret;
62
+ if (msg.topic === node.config.topic2) node.topic2Value = ret;
63
+
64
+ if (
65
+ node.topic1Value === undefined ||
66
+ node.topic2Value === undefined
67
+ ) {
68
+ setNodeStatus({
69
+ fill: "blue",
70
+ shape: "ring",
71
+ text: "Waiting for valid topics.",
72
+ });
73
+ return;
74
+ }
75
+
76
+ if (eval(node.topic1Value + node.math + node.topic2Value)) {
77
+ //msg.inputmsg = RED.util.cloneMessage(msg);
78
+ msg.topic = node.config.name;
79
+ msg.payload = true;
80
+ } else {
81
+ msg.payload = false;
82
+ }
83
+ msg.topic = node.config.name;
84
+ node.send(msg);
85
+ setNodeStatus({
86
+ fill: "green",
87
+ shape: "dot",
88
+ text: "Done " + msg.payload,
89
+ });
90
+ }
91
+ }
92
+ } catch (error) {
93
+ setNodeStatus({ fill: "red", shape: "ring", text: error.message });
94
+ }
95
+ });
96
+ }
97
+
98
+ RED.nodes.registerType("Comparator", Comparator);
99
+ };
@@ -66,7 +66,7 @@ The input message is preserved and passed to the output, changing only the topic
66
66
 
67
67
  |Property|Description|
68
68
  |--|--|
69
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
69
+ | 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"* |
70
70
 
71
71
  <br/>
72
72
 
@@ -88,7 +88,7 @@
88
88
 
89
89
  |Property|Description|
90
90
  |--|--|
91
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
91
+ | 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"* |
92
92
 
93
93
  * Avaiable Commands
94
94
 
@@ -94,7 +94,7 @@
94
94
  |Property|Description|
95
95
  |--|--|
96
96
  | 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. |
97
- | With Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
97
+ | 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"* |
98
98
  | 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.|
99
99
 
100
100
  <br/>
@@ -49,7 +49,7 @@ The input message is preserved and passed to the output, changing only the topic
49
49
 
50
50
  |Property|Description|
51
51
  |--|--|
52
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
52
+ | 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"* |
53
53
 
54
54
  <br/>
55
55
 
@@ -93,7 +93,7 @@
93
93
  |Property|Description|
94
94
  |--|--|
95
95
  | Switcher topic | Whenever the node receives a payload from this **topic**, it switches the input messages to an output. |
96
- | With Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
96
+ | 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"* |
97
97
  | Then | This property, allow you to auto toggle the selected start state after some time. |
98
98
 
99
99
  * Input messages
@@ -53,7 +53,7 @@ This is useful if you need to simply send a true or false payload.
53
53
 
54
54
  |Property|Description|
55
55
  |--|--|
56
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
56
+ | 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"* |
57
57
 
58
58
  <br/>
59
59
 
@@ -61,7 +61,7 @@
61
61
 
62
62
  |Property|Description|
63
63
  |--|--|
64
- | Input | Set the property where the input payload is. *By default, it is *payload*, but you can also specify other properties, for example "payload.value"* |
64
+ | 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"* |
65
65
  | Operation | Operation to be performed. |
66
66
 
67
67
  <br/>
@@ -64,7 +64,7 @@
64
64
 
65
65
  |Property|Description|
66
66
  |--|--|
67
- | Input | Set the property where the input payload is. *By default, it is "payload", but you can also specify other properties, for example "payload.value"* |
67
+ | 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"* |
68
68
 
69
69
  * Input message
70
70
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-boolean-logic-ultimate",
3
- "version": "1.0.62",
3
+ "version": "1.0.63",
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": {
@@ -32,7 +32,8 @@
32
32
  "ImpulseUltimate": "boolean-logic-ultimate/ImpulseUltimate.js",
33
33
  "SumUltimate": "boolean-logic-ultimate/SumUltimate.js",
34
34
  "toggleUltimate": "boolean-logic-ultimate/toggleUltimate.js",
35
- "RailwaySwitchUltimate": "boolean-logic-ultimate/RailwaySwitchUltimate.js"
35
+ "RailwaySwitchUltimate": "boolean-logic-ultimate/RailwaySwitchUltimate.js",
36
+ "Comparator": "boolean-logic-ultimate/Comparator.js"
36
37
  }
37
38
  }
38
39
  }