node-red-contrib-boolean-logic-ultimate 1.0.46 → 1.0.50

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
@@ -1,6 +1,22 @@
1
1
  # node-red-contrib-boolean-logic-ultimate
2
2
  [![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://www.paypal.me/techtoday)
3
3
 
4
+ <p>
5
+ <b>Version 1.0.50</b> February 2022<br/>
6
+ - NEW: Added Youtube example for each node. You can find the link in the config window of each one and hede the playlist https://youtube.com/playlist?list=PL9Yh1bjbLAYoRH4IyQB7EL5srHAihiKpy.</br>
7
+ </p>
8
+ <p>
9
+ <b>Version 1.0.48</b> February 2022<br/>
10
+ - NEW: TOGGLE node: Simple toggle node.</br>
11
+ </p>
12
+ <p>
13
+ <b>Version 1.0.48</b> February 2022<br/>
14
+ - NEW: SUM node: this new node makes sum, average and measurement count.</br>
15
+ </p>
16
+ <p>
17
+ <b>Version 1.0.47</b> February 2022<br/>
18
+ - NEW: Interrupt Flow: the node now stores the last message, even if in the "stop" state.</br>
19
+ </p>
4
20
  <p>
5
21
  <b>Version 1.0.46</b> February 2022<br/>
6
22
  - NEW: Interrupt Flow: msg.reset will delete the stored message.</br>
package/README.md CHANGED
@@ -8,11 +8,11 @@
8
8
  [![MIT License][license-image]][license-url]
9
9
  [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
10
10
  [![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://www.paypal.me/techtoday)
11
- [![Facebook][facebook-image]][facebook-url]
11
+ [![youtube][youtube-image]][youtube-url]
12
12
 
13
13
  A set of Node-RED enhanced boolean logic, with persisten values after reboot and more.
14
14
 
15
- > Wellcome! First of all thank you for your interest in my nodes. This is a set of logic nodes, to overcome the simplicity of the default node-red boolean logic nodes.
15
+ > Welcome! First of all thank you for your interest in my nodes. This is a set of logic nodes, to overcome the simplicity of the default node-red boolean logic nodes.
16
16
  Hope you enjoy that and if you're in trouble, please ask!
17
17
 
18
18
  <br/>
@@ -323,6 +323,57 @@ Pass <code>msg.payload = false</code> to the node to stop the running sequence</
323
323
 
324
324
  - Output: the node outputs a message you specified in the command textbox<br/>
325
325
 
326
+ <br/>
327
+ <br/>
328
+ <br/>
329
+ <br/>
330
+ <br/>
331
+
332
+ # SUM ULTIMATE
333
+
334
+ The pourpose of this node is to sum the incoming values. Each incoming message MUST HAVE OWN TOPIC.<br />
335
+
336
+ <img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/img/sum.png' width='60%'>
337
+ <details><summary>CLICK HERE, copy and paste it into your flow</summary>
338
+ <code>
339
+ [{"id":"05b6ce0cb476abd5","type":"SumUltimate","z":"d8fbf871e381cf2c","name":"Sum","property":"payload","x":550,"y":160,"wires":[["567aa6a9719e463e","34fbca5daf8b9fab","e3c2a45a0b77af8f"]]},{"id":"6744e01b88d820b9","type":"inject","z":"d8fbf871e381cf2c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Watt Table Lamp","payload":"10","payloadType":"num","x":250,"y":140,"wires":[["05b6ce0cb476abd5"]]},{"id":"75823dbc7db78c3c","type":"inject","z":"d8fbf871e381cf2c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Watt Washing machine","payload":"20","payloadType":"num","x":270,"y":180,"wires":[["05b6ce0cb476abd5"]]},{"id":"567aa6a9719e463e","type":"debug","z":"d8fbf871e381cf2c","name":"Sum","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":160,"wires":[]},{"id":"1793931ba218bc1d","type":"inject","z":"d8fbf871e381cf2c","name":"Reset","props":[{"p":"reset","v":"","vt":"date"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":240,"wires":[["05b6ce0cb476abd5"]]},{"id":"0b3277af03f546d4","type":"comment","z":"d8fbf871e381cf2c","name":"Getting Sum, Average etc. from the SUM node.","info":"","x":320,"y":100,"wires":[]},{"id":"34fbca5daf8b9fab","type":"debug","z":"d8fbf871e381cf2c","name":"Average","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"average","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":200,"wires":[]},{"id":"e3c2a45a0b77af8f","type":"debug","z":"d8fbf871e381cf2c","name":"Measurements","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"measurements","targetType":"msg","statusVal":"","statusType":"auto","x":720,"y":240,"wires":[]}]
340
+ </code>
341
+ </details>
342
+
343
+ **INPUT**<br />
344
+
345
+ <br /><b>msg.reset</b><br />
346
+ resets the values to zero.
347
+
348
+ <br />
349
+
350
+ - Output: the node outputs a message as follows:<br/>
351
+
352
+ <pre>
353
+ {
354
+ "payload": 30, // This is the SUM
355
+ "topic": "Sum", // Node Topic
356
+ "average": 15, // This is the AVERAVE
357
+ "measurements": 2 // This is the number of topics that have been evaluated
358
+ }
359
+ </pre>
360
+
361
+ br/>
362
+ <br/>
363
+ <br/>
364
+ <br/>
365
+ <br/>
366
+
367
+ # TOGGLE ULTIMATE
368
+
369
+ The pourpose of this node is to toggle between true/false the payload of every incoming message.<br />
370
+
371
+
372
+ **INPUT**<br />
373
+
374
+ Any message that arrives on input, will be passwd through to the output with the payload toggled between true and false.
375
+
376
+
326
377
 
327
378
  [license-image]: https://img.shields.io/badge/license-MIT-blue.svg
328
379
  [license-url]: https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/LICENSE
@@ -330,5 +381,5 @@ Pass <code>msg.payload = false</code> to the node to stop the running sequence</
330
381
  [npm-version-image]: https://img.shields.io/npm/v/node-red-contrib-boolean-logic-ultimate.svg
331
382
  [npm-downloads-month-image]: https://img.shields.io/npm/dm/node-red-contrib-boolean-logic-ultimate.svg
332
383
  [npm-downloads-total-image]: https://img.shields.io/npm/dt/node-red-contrib-boolean-logic-ultimate.svg
333
- [facebook-image]: https://img.shields.io/badge/Visit%20me-Facebook-blue
334
- [facebook-url]: https://www.facebook.com/supergiovaneDev
384
+ [youtube-image]: https://img.shields.io/badge/Visit%20me-youtube-red
385
+ [youtube-url]: https://youtube.com/playlist?list=PL9Yh1bjbLAYoRH4IyQB7EL5srHAihiKpy
@@ -37,7 +37,8 @@
37
37
  <script type="text/x-red" data-template-name="BlinkerUltimate">
38
38
  <div class="form-row">
39
39
  <b>Blinker Ultimate</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-question-circle"></i>&nbsp<a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
40
- <br/>
40
+ &nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/HtMoutMFB6A"><u>Youtube Sample</u></a></span>
41
+ <br/>
41
42
  <br/>
42
43
  </div>
43
44
  <div class="form-row">
@@ -118,6 +118,7 @@
118
118
  <script type="text/x-red" data-template-name="BooleanLogicUltimate">
119
119
  <div class="form-row">
120
120
  <b>Boolean Logic Ultimate</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-question-circle"></i>&nbsp<a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
121
+ &nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/6En2WiWKsXM"><u>Youtube Sample</u></a></span>
121
122
  <br/>
122
123
  <br/>
123
124
  </div>
@@ -36,6 +36,7 @@
36
36
  <script type="text/x-red" data-template-name="FilterUltimate">
37
37
  <div class="form-row">
38
38
  <b>Filter Ultimate</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-question-circle"></i>&nbsp<a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
39
+ &nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/DXfpXRM-LJA"><u>Youtube Sample</u></a></span>
39
40
  <br/>
40
41
  <br/>
41
42
  </div>
@@ -50,7 +50,8 @@
50
50
  <script type="text/x-red" data-template-name="ImpulseUltimate">
51
51
  <div class="form-row">
52
52
  <b>Impulse Ultimate</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-question-circle"></i>&nbsp<a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
53
- <br/>
53
+ &nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/PdLEWtKsNv8"><u>Youtube Sample</u></a></span>
54
+ <br/>
54
55
  <br/>
55
56
  </div>
56
57
  <div class="form-row">
@@ -62,8 +62,9 @@
62
62
  <script type="text/x-red" data-template-name="InjectUltimate">
63
63
  <div class="form-row">
64
64
  <b>Inject Ultimate</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-question-circle"></i>&nbsp<a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
65
+ &nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/sYc6L5QQrTw"><u>Youtube Sample</u></a></span>
65
66
  <br/>
66
- <br/>
67
+ <br/>
67
68
  </div>
68
69
  <div class="form-row">
69
70
  <label for="node-input-name"><i class="icon-tag"></i> Name</label>
@@ -37,6 +37,7 @@
37
37
  <script type="text/x-red" data-template-name="InterruptFlowUltimate">
38
38
  <div class="form-row">
39
39
  <b>Interrupt Flow Ultimate</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-question-circle"></i>&nbsp<a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
40
+ &nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/1T1g0HCeYA8"><u>Youtube Sample</u></a></span>
40
41
  <br/>
41
42
  <br/>
42
43
  </div>
@@ -86,8 +86,8 @@ module.exports = function (RED) {
86
86
  }
87
87
  }
88
88
  }
89
+ node.currentMsg = RED.util.cloneMessage(msg);
89
90
  if (node.bInviaMessaggio) {
90
- node.currentMsg = RED.util.cloneMessage(msg);
91
91
  node.send(msg);
92
92
  }
93
93
  });
@@ -23,6 +23,7 @@
23
23
  <script type="text/x-red" data-template-name="InvertUltimate">
24
24
  <div class="form-row">
25
25
  <b>Invert Ultimate</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-question-circle"></i>&nbsp<a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
26
+ &nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/A41x8VevZD8"><u>Youtube Sample</u></a></span>
26
27
  <br/>
27
28
  <br/>
28
29
  </div>
@@ -36,7 +36,8 @@
36
36
  <script type="text/x-red" data-template-name="SimpleOutputUltimate">
37
37
  <div class="form-row">
38
38
  <b>Simple Output Ultimate</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-question-circle"></i>&nbsp<a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
39
- <br/>
39
+ &nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/tCKolVculuw"><u>Youtube Sample</u></a></span>
40
+ <br/>
40
41
  <br/>
41
42
  </div>
42
43
  <div class="form-row">
@@ -27,7 +27,8 @@
27
27
  <script type="text/x-red" data-template-name="StatusUltimate">
28
28
  <div class="form-row">
29
29
  <b>Status Ultimate</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-question-circle"></i>&nbsp<a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
30
- <br/>
30
+ &nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/m3p06PN3rTI"><u>Youtube Sample</u></a></span>
31
+ <br/>
31
32
  <br/>
32
33
  </div>
33
34
  <div class="form-row">
@@ -0,0 +1,55 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('SumUltimate', {
3
+ category: 'boolean logic ultimate',
4
+ color: '#ff8080',
5
+ defaults: {
6
+ name: {
7
+ value: "Sum"
8
+ },
9
+ property: {
10
+ value: "payload"
11
+ }
12
+
13
+ },
14
+ inputs: 1,
15
+ outputs: 1,
16
+ icon: "font-awesome/fa-plus",
17
+ label:
18
+ function () {
19
+ return this.name || "Sum";
20
+ },
21
+ paletteLabel: function () {
22
+ return "SumUltimate";
23
+ }
24
+ });
25
+ </script>
26
+
27
+ <script type="text/x-red" data-template-name="SumUltimate">
28
+ <div class="form-row">
29
+ <b>Status Ultimate</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-question-circle"></i>&nbsp<a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
30
+ &nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/jLIbQgmRzuc"><u>Youtube Sample</u></a></span>
31
+ <br/>
32
+ <br/>
33
+ </div>
34
+ <div class="form-row">
35
+ <label for="node-input-name"><i class="icon-tag"></i> Name</label>
36
+ <input type="text" id="node-input-name" placeholder="Name">
37
+ </div>
38
+ <div class="form-row">
39
+ <label for="node-input-property"><i class="icon-tag"></i> Sum msg.</label>
40
+ <input type="text" id="node-input-property" placeholder="payload">
41
+ </div>
42
+ </script>
43
+
44
+ <script type="text/x-red" data-help-name="SumUltimate">
45
+ <p>
46
+ SEE THE README FOR HELP CONFIGURING THE NODE
47
+ </p>
48
+
49
+ <p>
50
+ <a href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate" target="_blank">Click here to learn how to configure the node.</a>
51
+ </p>
52
+
53
+ <a href="https://www.paypal.me/techtoday" target="_blank"><img src='https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square' width='30%'></a>
54
+
55
+ </script>
@@ -0,0 +1,88 @@
1
+ module.exports = function (RED) {
2
+ function SumUltimate(config) {
3
+ RED.nodes.createNode(this, config);
4
+ this.config = config;
5
+ var node = this;
6
+ this.topics = {};
7
+
8
+ function setNodeStatus({ fill, shape, text }) {
9
+ var dDate = new Date();
10
+ node.status({ fill: fill, shape: shape, text: text + " (" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")" })
11
+ }
12
+
13
+ setNodeStatus({ fill: "grey", shape: "dot", text: "" });
14
+
15
+ function fetchFromObject(obj, prop) {
16
+
17
+ if (obj === undefined) {
18
+ return undefined;
19
+ }
20
+
21
+ var _index = prop.indexOf('.')
22
+ if (_index > -1) {
23
+ return fetchFromObject(obj[prop.substring(0, _index)], prop.substr(_index + 1));
24
+ }
25
+
26
+ return obj[prop];
27
+ }
28
+
29
+ this.on('input', function (msg) {
30
+
31
+ // handle reset
32
+ if (msg.hasOwnProperty("reset")) {
33
+ node.topics = {};
34
+ setNodeStatus({ fill: "grey", shape: "ring", text: "Reset" });
35
+ return;
36
+ }
37
+
38
+ if (!msg.hasOwnProperty("topic")) {
39
+ setNodeStatus({ fill: "red", shape: "ring", text: "Incoming msg without topic! Please set the topic." });
40
+ return;
41
+ }
42
+
43
+ try {
44
+ let props = [] = this.config.property.split(".");
45
+ let ret = fetchFromObject(msg, this.config.property);
46
+ if (ret !== undefined) {
47
+
48
+ ret = Number(ret);
49
+
50
+ // Sum
51
+ if (!isNaN(ret) && isFinite(ret)) {
52
+ node.topics[msg.topic.toString()] = ret;
53
+
54
+ var quantita = 0;
55
+ var somma = Object.keys(node.topics).reduce(function (a, b) {
56
+ ++quantita;
57
+ return a + node.topics[b];
58
+ }, 0);
59
+
60
+ msg.payload = somma; // Sum
61
+ msg.average = somma / quantita; // Average
62
+ msg.measurements = quantita; // Topics
63
+
64
+ // overwrite topic if configured
65
+ if (config.name) {
66
+ msg.topic = config.name;
67
+ }
68
+ }
69
+
70
+ // everything else
71
+ else {
72
+ setNodeStatus({ fill: "red", shape: "ring", text: "Not a number" });
73
+ }
74
+
75
+ } else {
76
+ setNodeStatus({ fill: "red", shape: "ring", text: this.config.property + " is undefined." });
77
+ }
78
+ } catch (error) {
79
+ setNodeStatus({ fill: "red", shape: "ring", text: error.message });
80
+ }
81
+ setNodeStatus({ fill: "green", shape: "dot", text: "Sum " + msg.payload });
82
+ node.send(msg);
83
+ });
84
+
85
+ }
86
+
87
+ RED.nodes.registerType("SumUltimate", SumUltimate);
88
+ }
@@ -0,0 +1,64 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('toggleUltimate', {
3
+ category: 'boolean logic ultimate',
4
+ color: '#ff8080',
5
+ defaults: {
6
+ name: {
7
+ value: "Toggle"
8
+ },
9
+ valueToToggle: { value: "true" }
10
+ },
11
+ inputs: 1,
12
+ outputs: 1,
13
+ icon: "serial.png",
14
+ label:
15
+ function () {
16
+ return this.name || "Toggle";
17
+ },
18
+ paletteLabel: function () {
19
+ return "toggleUltimate";
20
+ }
21
+ });
22
+ </script>
23
+
24
+ <script type="text/x-red" data-template-name="toggleUltimate">
25
+ <div class="form-row">
26
+ <b>Toggle Ultimate</b>&nbsp&nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-question-circle"></i>&nbsp<a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
27
+ &nbsp&nbsp&nbsp<span style="color:red"><i class="fa fa-youtube-play"></i>&nbsp<a target="_blank" href="https://youtu.be/VijkMBpt_CM"><u>Youtube Sample</u></a></span>
28
+ <br/>
29
+ <br/>
30
+ </div>
31
+ <div class="form-row">
32
+ <label for="node-input-name"><i class="icon-tag"></i> Name</label>
33
+ <input type="text" id="node-input-name" placeholder="Name">
34
+ </div>
35
+ <div class="form-row">
36
+ <label style="width:160px" for="node-input-valueToToggle"><i class="fa fa-toggle-on"></i> Initial value</label>
37
+ <select type="text" id="node-input-valueToToggle" placeholder="">
38
+ <option value="true">Initialize wiht True</option>
39
+ <option value="false">Initialize with False</option>
40
+ </select>
41
+ </div>
42
+ <!-- <div class="form-row">
43
+ <input type="checkbox" id="node-input-homeAssitantBoolean" style="display:inline-block; width:auto; vertical-align:top;">
44
+ &nbsp;
45
+ <label style="width:85%" for="node-input-homeAssitantBoolean">
46
+ <i class="fa fa-home"></i>&nbsp;Output Home Assistant "on"/"off" instead of true/false
47
+ </label>
48
+ </div> -->
49
+
50
+
51
+ </script>
52
+
53
+ <script type="text/x-red" data-help-name="toggleUltimate">
54
+ <p>
55
+ SEE THE README FOR HELP CONFIGURING THE NODE
56
+ </p>
57
+
58
+ <p>
59
+ <a href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate" target="_blank">Click here to learn how to configure the node.</a>
60
+ </p>
61
+
62
+ <a href="https://www.paypal.me/techtoday" target="_blank"><img src='https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square' width='30%'></a>
63
+
64
+ </script>
@@ -0,0 +1,71 @@
1
+ module.exports = function (RED) {
2
+ function toggleUltimate(config) {
3
+ RED.nodes.createNode(this, config);
4
+ this.config = config;
5
+ var node = this;
6
+ node.valueToToggle = config.valueToToggle === undefined ? true : ToBoolean(config.valueToToggle);
7
+
8
+ function setNodeStatus({ fill, shape, text }) {
9
+ var dDate = new Date();
10
+ node.status({ fill: fill, shape: shape, text: text + " (" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")" })
11
+ }
12
+
13
+ setNodeStatus({ fill: "grey", shape: "dot", text: "Waiting" });
14
+
15
+ this.on('input', function (msg) {
16
+
17
+
18
+ // 15/11/2021 inform user about undefined topic or payload
19
+ if (!msg.hasOwnProperty("payload") || msg.payload === undefined || msg.payload === null) {
20
+ setNodeStatus({ fill: "red", shape: "dot", text: "Received invalid payload from " + msg.topic || "" });
21
+ return;
22
+ }
23
+
24
+ node.valueToToggle = !node.valueToToggle;
25
+
26
+ var msgOUT = RED.util.cloneMessage(msg);
27
+ try {
28
+ msgOUT.payload = node.valueToToggle;
29
+ setNodeStatus({ fill: "green", shape: "dot", text: "(Send) " + msgOUT.payload });
30
+ node.send(msgOUT);
31
+ } catch (error) {
32
+ setNodeStatus({ fill: "red", shape: "dot", text: "Unable to invert the input payload " + bRes });
33
+ }
34
+
35
+ });
36
+
37
+
38
+
39
+ function ToBoolean(value) {
40
+ var res = false;
41
+ var decimal = /^\s*[+-]{0,1}\s*([\d]+(\.[\d]*)*)\s*$/
42
+
43
+ if (typeof value === 'boolean') {
44
+ res = value;
45
+ }
46
+ else if (typeof value === 'number' || typeof value === 'string') {
47
+
48
+ if (typeof value === "string" && value.toLowerCase() === "on") return true;
49
+ if (typeof value === "string" && value.toLowerCase() === "off") return false;
50
+
51
+ // Is it formated as a decimal number?
52
+ if (decimal.test(value)) {
53
+ var v = parseFloat(value);
54
+ res = v != 0;
55
+ }
56
+ else {
57
+ res = value.toLowerCase() === "true";
58
+ }
59
+ }
60
+
61
+ return res;
62
+ };
63
+
64
+
65
+
66
+ }
67
+
68
+
69
+
70
+ RED.nodes.registerType("toggleUltimate", toggleUltimate);
71
+ }
package/img/sum.png ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-boolean-logic-ultimate",
3
- "version": "1.0.46",
3
+ "version": "1.0.50",
4
4
  "description": "A set of Node-RED enhanced boolean logic node, flow interruption node, blinker node, invert node, filter node, with persisten values after reboot and more.",
5
5
  "author": "Supergiovane (https://github.com/Supergiovane)",
6
6
  "dependencies": {
@@ -29,7 +29,9 @@
29
29
  "SimpleOutputUltimate": "boolean-logic-ultimate/SimpleOutputUltimate.js",
30
30
  "InjectUltimate": "boolean-logic-ultimate/InjectUltimate.js",
31
31
  "StatusUltimate": "boolean-logic-ultimate/StatusUltimate.js",
32
- "ImpulseUltimate": "boolean-logic-ultimate/ImpulseUltimate.js"
32
+ "ImpulseUltimate": "boolean-logic-ultimate/ImpulseUltimate.js",
33
+ "SumUltimate": "boolean-logic-ultimate/SumUltimate.js",
34
+ "toggleUltimate": "boolean-logic-ultimate/toggleUltimate.js"
33
35
  }
34
36
  }
35
37
  }