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

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.62</b> August 2023<br/>
8
+ - Math node: added "subtract option".</br>
9
+ </p>
6
10
  <p>
7
11
  <b>Version 1.0.61</b> Juli 2023<br/>
8
12
  - Standardization of the help, based on Node-Red directives.</br>
@@ -51,6 +51,7 @@
51
51
  <select type="text" id="node-input-math" placeholder="">
52
52
  <option value="sum">Sum</option>
53
53
  <option value="multiply">Multiply</option>
54
+ <option value="subtract">Subtract</option>
54
55
  </select>
55
56
  </div>
56
57
  </script>
@@ -60,7 +61,8 @@
60
61
 
61
62
  |Property|Description|
62
63
  |--|--|
63
- | 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 | Set the property where the input payload is. *By default, it is *payload*, but you can also specify other properties, for example "payload.value"* |
65
+ | Operation | Operation to be performed. |
64
66
 
65
67
  <br/>
66
68
  <br/>
@@ -75,6 +75,24 @@ module.exports = function (RED) {
75
75
  msg.payload = moltiplicazione; // Sum
76
76
  msg.average = undefined; // Average
77
77
  msg.measurements = quantita; // Topics
78
+ } else if (node.math === "subtract") {
79
+ let values = []
80
+ for (let row in node.topics) {
81
+ if (node.topics.hasOwnProperty(row)) {
82
+ values.push(node.topics[row]);
83
+ }
84
+ }
85
+ function orderReverseNumbers(a, b) {
86
+ return b - a;
87
+ }
88
+ values.sort(orderReverseNumbers)
89
+ let risultato = values[0]
90
+ for (let index = 1; index < values.length; index++) {
91
+ risultato -= values[index];
92
+ }
93
+ msg.payload = risultato; // Sum
94
+ msg.average = risultato / quantita; // Average
95
+ msg.measurements = quantita; // Topics
78
96
  }
79
97
 
80
98
  // overwrite topic if configured
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-boolean-logic-ultimate",
3
- "version": "1.0.61",
3
+ "version": "1.0.62",
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": {