node-red-contrib-boolean-logic-ultimate 1.0.52 → 1.0.53
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,11 @@
|
|
|
3
3
|
|
|
4
4
|
# CHANGELOG
|
|
5
5
|
|
|
6
|
+
<p>
|
|
7
|
+
<b>Version 1.0.53</b> June 2022<br/>
|
|
8
|
+
- NEW: Math Ultimate. The old "Sum" node, now has become a math node, you can peform multipication other than sum.</br>
|
|
9
|
+
- Updated README with samples of Math node.
|
|
10
|
+
</p>
|
|
6
11
|
<p>
|
|
7
12
|
<b>Version 1.0.52</b> Mai 2022<br/>
|
|
8
13
|
- NEW: Railway Switcher Ultimate: new node to switch the input message to an output pin (https://youtu.be/1SjYE7d04u4).</br>
|
package/README.md
CHANGED
|
@@ -328,14 +328,14 @@ Pass <code>msg.payload = false</code> to the node to stop the running sequence</
|
|
|
328
328
|
<br/>
|
|
329
329
|
<br/>
|
|
330
330
|
|
|
331
|
-
#
|
|
331
|
+
# MATH ULTIMATE
|
|
332
332
|
|
|
333
|
-
The pourpose of this node is to
|
|
333
|
+
The pourpose of this node is to do maths on the incoming values. Each incoming message MUST HAVE OWN TOPIC.<br />
|
|
334
334
|
|
|
335
335
|
<img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/img/sum.png' width='60%'>
|
|
336
336
|
<details><summary>CLICK HERE, copy and paste it into your flow</summary>
|
|
337
337
|
<code>
|
|
338
|
-
[{"id":"05b6ce0cb476abd5","type":"SumUltimate","z":"
|
|
338
|
+
[{"id":"05b6ce0cb476abd5","type":"SumUltimate","z":"2bf641f4b8742755","name":"Multiply","property":"payload","math":"multiply","x":400,"y":180,"wires":[["567aa6a9719e463e"]]},{"id":"6744e01b88d820b9","type":"inject","z":"2bf641f4b8742755","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Wh Washing machine","payload":"10","payloadType":"num","x":190,"y":180,"wires":[["05b6ce0cb476abd5"]]},{"id":"75823dbc7db78c3c","type":"inject","z":"2bf641f4b8742755","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Cost per KWh","payload":"20","payloadType":"num","x":160,"y":220,"wires":[["05b6ce0cb476abd5"]]},{"id":"567aa6a9719e463e","type":"debug","z":"2bf641f4b8742755","name":"Result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":180,"wires":[]},{"id":"1793931ba218bc1d","type":"inject","z":"2bf641f4b8742755","name":"Reset","props":[{"p":"reset","v":"","vt":"date"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":260,"wires":[["05b6ce0cb476abd5"]]},{"id":"0b3277af03f546d4","type":"comment","z":"2bf641f4b8742755","name":"Getting results, (Sum, Multiply etc...) from the MATH node.","info":"","x":270,"y":140,"wires":[]}]
|
|
339
339
|
</code>
|
|
340
340
|
</details>
|
|
341
341
|
|
|
@@ -350,9 +350,9 @@ resets the values to zero.
|
|
|
350
350
|
|
|
351
351
|
<pre>
|
|
352
352
|
{
|
|
353
|
-
"payload": 30, // This is the
|
|
354
|
-
"topic": "
|
|
355
|
-
"average": 15, // This is the
|
|
353
|
+
"payload": 30, // This is the math result
|
|
354
|
+
"topic": "MyMath", // Node Topic
|
|
355
|
+
"average": 15, // This is the AVERAGE, in case of SUM
|
|
356
356
|
"measurements": 2 // This is the number of topics that have been evaluated
|
|
357
357
|
}
|
|
358
358
|
</pre>
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
color: '#ff8080',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: {
|
|
7
|
-
value: "
|
|
7
|
+
value: "Math"
|
|
8
8
|
},
|
|
9
9
|
property: {
|
|
10
10
|
value: "payload"
|
|
11
|
+
},
|
|
12
|
+
math: {
|
|
13
|
+
value: "sum"
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
},
|
|
@@ -16,29 +19,36 @@
|
|
|
16
19
|
icon: "font-awesome/fa-plus",
|
|
17
20
|
label:
|
|
18
21
|
function () {
|
|
19
|
-
return this.name || "
|
|
22
|
+
return this.name || "Math";
|
|
20
23
|
},
|
|
21
24
|
paletteLabel: function () {
|
|
22
|
-
return "
|
|
25
|
+
return "MathUltimate";
|
|
23
26
|
}
|
|
24
27
|
});
|
|
25
28
|
</script>
|
|
26
29
|
|
|
27
30
|
<script type="text/x-red" data-template-name="SumUltimate">
|
|
28
31
|
<div class="form-row">
|
|
29
|
-
<b>
|
|
32
|
+
<b>Math 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>
|
|
30
33
|
   <span style="color:red"><i class="fa fa-youtube-play"></i> <a target="_blank" href="https://youtu.be/jLIbQgmRzuc"><u>Youtube Sample</u></a></span>
|
|
31
34
|
<br/>
|
|
32
35
|
<br/>
|
|
33
36
|
</div>
|
|
34
37
|
<div class="form-row">
|
|
35
|
-
<label for="node-input-name"><i class="icon-tag"></i>
|
|
36
|
-
<input type="text" id="node-input-name" placeholder="
|
|
38
|
+
<label for="node-input-name"><i class="icon-tag"></i> Topic</label>
|
|
39
|
+
<input type="text" id="node-input-name" placeholder="Topic">
|
|
37
40
|
</div>
|
|
38
41
|
<div class="form-row">
|
|
39
|
-
<label for="node-input-property"><i class="icon-tag"></i>
|
|
42
|
+
<label for="node-input-property"><i class="icon-tag"></i> Use msg.</label>
|
|
40
43
|
<input type="text" id="node-input-property" placeholder="payload">
|
|
41
44
|
</div>
|
|
45
|
+
<div class="form-row">
|
|
46
|
+
<label for="node-input-math"><i class="icon-tag"></i> Operation</label>
|
|
47
|
+
<select type="text" id="node-input-math" placeholder="">
|
|
48
|
+
<option value="sum">Sum</option>
|
|
49
|
+
<option value="multiply">Multiply</option>
|
|
50
|
+
</select>
|
|
51
|
+
</div>
|
|
42
52
|
</script>
|
|
43
53
|
|
|
44
54
|
<script type="text/x-red" data-help-name="SumUltimate">
|
|
@@ -3,6 +3,7 @@ module.exports = function (RED) {
|
|
|
3
3
|
RED.nodes.createNode(this, config);
|
|
4
4
|
this.config = config;
|
|
5
5
|
var node = this;
|
|
6
|
+
node.math = config.math === undefined ? "sum" : config.math;
|
|
6
7
|
this.topics = {};
|
|
7
8
|
|
|
8
9
|
function setNodeStatus({ fill, shape, text }) {
|
|
@@ -52,14 +53,29 @@ module.exports = function (RED) {
|
|
|
52
53
|
node.topics[msg.topic.toString()] = ret;
|
|
53
54
|
|
|
54
55
|
var quantita = 0;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
|
|
57
|
+
if (node.math === "sum") {
|
|
58
|
+
let somma = Object.keys(node.topics).reduce(function (a, b) {
|
|
59
|
+
++quantita;
|
|
60
|
+
return a + node.topics[b];
|
|
61
|
+
}, 0);
|
|
62
|
+
msg.payload = somma; // Sum
|
|
63
|
+
msg.average = somma / quantita; // Average
|
|
64
|
+
msg.measurements = quantita; // Topics
|
|
65
|
+
} else if (node.math === "multiply") {
|
|
66
|
+
let moltiplicazione = Object.keys(node.topics).reduce(function (a, b) {
|
|
67
|
+
try {
|
|
68
|
+
++quantita;
|
|
69
|
+
return (a > 0 ? a : 1) * node.topics[b]; // Avoid returning zero everytime
|
|
70
|
+
} catch (error) {
|
|
71
|
+
setNodeStatus({ fill: "red", shape: "ring", text: "Error " + error.message });
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
}, 0);
|
|
75
|
+
msg.payload = moltiplicazione; // Sum
|
|
76
|
+
msg.average = undefined; // Average
|
|
77
|
+
msg.measurements = quantita; // Topics
|
|
78
|
+
}
|
|
63
79
|
|
|
64
80
|
// overwrite topic if configured
|
|
65
81
|
if (config.name) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-boolean-logic-ultimate",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.53",
|
|
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 ON and OFF values.",
|
|
5
5
|
"author": "Supergiovane (https://github.com/Supergiovane)",
|
|
6
6
|
"dependencies": {
|