node-red-contrib-boolean-logic-ultimate 1.1.8 → 1.1.11

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
@@ -4,7 +4,15 @@
4
4
  # CHANGELOG
5
5
 
6
6
  <p>
7
- <b>Version 1.1.7</b> Mai 2024<br/>
7
+ <b>Version 1.1.11</b> Mai 2024<br/>
8
+ - NEW: inject node now can inject a JSON as well.</br>
9
+ </p>
10
+ <p>
11
+ <b>Version 1.1.9</b> Mai 2024<br/>
12
+ - Added samples and better description of the Math's node (in particular, to the subract function).</br>
13
+ </p>
14
+ <p>
15
+ <b>Version 1.1.8</b> Mai 2024<br/>
8
16
  - FIX Comparator node: fixed wrong results using minor and major comparator.</br>
9
17
  </p>
10
18
  <p>
package/README.md CHANGED
@@ -1,6 +1,5 @@
1
- # node-red-contrib-boolean-logic-ultimate
2
1
 
3
- ![Sample Node](img/logo.png)
2
+ ![Logo](img/logo.png)
4
3
 
5
4
  [![NPM version][npm-version-image]][npm-url]
6
5
  [![NPM downloads per month][npm-downloads-month-image]][npm-url]
@@ -10,7 +10,7 @@
10
10
  inputs: 1,
11
11
  outputs: 1,
12
12
  outputLabels: function (i) {
13
-
13
+
14
14
  },
15
15
  icon: "feed.svg",
16
16
  label:
@@ -11,11 +11,12 @@
11
11
  },
12
12
  curVal: {
13
13
  value: true,
14
- }
14
+ },
15
+ outputJSON: { value: '{ \n\t"payload":"hello",\n\t"topic":"1"\n}' },
15
16
  },
16
17
  inputs: 0,
17
- outputs: 3,
18
- outputLabels: ["True", "False", "Toggle"],
18
+ outputs: 4,
19
+ outputLabels: ["True", "False", "Toggle", "JSON"],
19
20
  icon: "inject.svg",
20
21
  button: {
21
22
  onclick: function () {
@@ -53,13 +54,34 @@
53
54
  function () {
54
55
  return this.name + " " + this.topic;
55
56
  },
57
+ oneditprepare: function () {
58
+ var node = this;
59
+ node.editor = RED.editor.createEditor({
60
+ id: 'node-input-editoroutputJSON',
61
+ mode: 'ace/mode/json',
62
+ value: node.outputJSON
63
+ });
64
+ if ($("#node-input-payloadPropName").val() === "") $("#node-input-payloadPropName").val("payload");
65
+
66
+ },
67
+ oneditsave: function () {
68
+ var node = this;
69
+ node.outputJSON = node.editor.getValue();
70
+ node.editor.destroy();
71
+ delete node.editor;
72
+ },
73
+ oneditcancel: function () {
74
+ var node = this;
75
+ node.editor.destroy();
76
+ delete node.editor;
77
+ },
56
78
  paletteLabel: function () {
57
79
  return "InjectUltimate";
58
80
  }
59
81
  });
60
82
  </script>
61
83
 
62
- <script type="text/x-red" data-template-name="InjectUltimate">
84
+ <script type="text/html" data-template-name="InjectUltimate">
63
85
  <div class="form-row">
64
86
  <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
87
  &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>
@@ -74,12 +96,31 @@
74
96
  <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
75
97
  <input type="text" id="node-input-topic" placeholder="Topic">
76
98
  </div>
99
+ <div class="form-row" >
100
+ <label style="width:300px;" for="node-input-outputJSON"><i class="fa fa-tasks"></i> JSON</label>
101
+ <div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-editoroutputJSON"></div>
102
+ </div>
77
103
  </script>
78
104
 
79
105
  <script type="text/markdown" data-help-name="InjectUltimate">
80
- <p>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.</p>
106
+ <p>The pourpose of this node is to send a msg to all output pins at once.</p>
107
+
108
+ **Configuration**
109
+
110
+ |Property|Description|
111
+ |--|--|
112
+ | Name | Node name.|
113
+ | Topic | The msg output topic. It can be overridden by the JSON field, but only in the output pin #4.|
114
+ | JSON | The pin #4 will output this JSON message.|
115
+
116
+ ### Output
81
117
 
82
- This is useful if you need to simply test your flow.
118
+ - pin1 : true
119
+ - pin2 : false
120
+ - pin3 : toggle
121
+ - pin4 : json object
122
+ <br/>
123
+ <br/>
83
124
 
84
125
 
85
126
  [SEE THE README FOR FULL HELP AND SAMPLES](https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate)
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  module.exports = function (RED) {
2
4
  function InjectUltimate(config) {
3
5
  RED.nodes.createNode(this, config);
@@ -5,6 +7,7 @@ module.exports = function (RED) {
5
7
  var node = this;
6
8
  node.curVal = true;
7
9
  node.topic = config.topic || "Inject";
10
+ node.outputJSON = config.outputJSON === undefined ? "{}" : config.outputJSON;
8
11
  setNodeStatus({ fill: "grey", shape: "dot", text: "Waiting" });
9
12
 
10
13
 
@@ -16,7 +19,7 @@ module.exports = function (RED) {
16
19
  res.sendStatus(200);
17
20
  } catch (err) {
18
21
  res.sendStatus(500);
19
- node.error(RED._("InjectUltimate.failed", { error: err.toString() }));
22
+ node.error(RED._("InjectUltimate.failed, error:" + err.message));
20
23
  }
21
24
  } else {
22
25
  res.sendStatus(404);
@@ -30,7 +33,14 @@ module.exports = function (RED) {
30
33
  let msgFalse = { payload: false, topic: node.topic };
31
34
  let msgToggled = { payload: node.curVal, topic: node.topic };
32
35
  node.curVal = !node.curVal;
33
- node.send([msgTrue, msgFalse, msgToggled]);
36
+ try {
37
+ node.outputJSON = JSON.parse(node.outputJSON);
38
+ if (node.outputJSON.topic === undefined) node.outputJSON.topic = node.topic; // Add topic if not present
39
+ } catch (error) {
40
+ setNodeStatus({ fill: "red", shape: "dot", text: "JSON error " + error.message });
41
+ RED.log.error("node.outputJSON = JSON.parse(node.outputJSON) error:" + error.message);
42
+ }
43
+ node.send([msgTrue, msgFalse, msgToggled, node.outputJSON]);
34
44
  }
35
45
 
36
46
  function setNodeStatus({ fill, shape, text }) {
@@ -63,7 +63,7 @@
63
63
  </div>
64
64
  <div class="form-row" id="divSubtractFirst" hidden>
65
65
  <label for="node-input-subtractstartfrom"><i class="icon-tag"></i> Subtract from</label>
66
- <input type="text" id="node-input-subtractstartfrom" placeholder="Type the msg.topic. See the help.">
66
+ <input type="text" id="node-input-subtractstartfrom" placeholder="See the help.">
67
67
  </div>
68
68
  </script>
69
69
 
@@ -74,9 +74,24 @@
74
74
  |--|--|
75
75
  | 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"* |
76
76
  | Operation | Operation to be performed. |
77
- | Subtract from | Only visible when the *operation* is **subtract**. It's the *msg.topic* of the message containing the value from wich start subtracting. |
77
+ | Subtract from | Only visible when the *operation* is **subtract**. It's the *msg.topic value* of the message containing the payload from wich the node starts subtracting. For example, if the incoming msg has ***msg.topic = 'startNumber'***, you must write only **startNumber** in the *Subtract from* field. |
78
78
 
79
79
  <br/>
80
+
81
+ ### Inputs
82
+
83
+ : reset (any) : by passing msg.reset, the node will reset all values and sarts from scratch.
84
+ : topic (string) : the topic identifying the incoming message. Each incoming msg, must have a different topic.
85
+ : payload (number) : the payload containing the number. If you've changed the incoming evaluation property in the ***Input*** field, the number to be evaluated must be put in such message's property, instead of the *payload* property.
86
+
87
+ ### Example of "subtract"
88
+
89
+ Copy this code and paste it in to your flow.
90
+
91
+ ```json
92
+ [{"id":"430cc033ed140940","type":"inject","z":"1050ddfb1ce105e8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"a","payload":"20","payloadType":"num","x":110,"y":140,"wires":[["97d95d92ddf4bf08"]]},{"id":"514067713f250a42","type":"inject","z":"1050ddfb1ce105e8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"startNumber","payload":"100","payloadType":"num","x":140,"y":100,"wires":[["97d95d92ddf4bf08"]]},{"id":"97d95d92ddf4bf08","type":"SumUltimate","z":"1050ddfb1ce105e8","name":"Subtract","property":"payload","math":"subtract","subtractstartfrom":"startNumber","x":320,"y":140,"wires":[["c55f332fe2dadc53"]]},{"id":"c55f332fe2dadc53","type":"debug","z":"1050ddfb1ce105e8","name":"Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":140,"wires":[]},{"id":"fe0ac0d4cd660a65","type":"inject","z":"1050ddfb1ce105e8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"b","payload":"10","payloadType":"num","x":110,"y":180,"wires":[["97d95d92ddf4bf08"]]},{"id":"3de15e77a932a0eb","type":"inject","z":"1050ddfb1ce105e8","name":"Reset","props":[{"p":"reset","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":110,"y":220,"wires":[["97d95d92ddf4bf08"]]}]
93
+ ```
94
+
80
95
  <br/>
81
96
 
82
97
  [SEE THE README FOR FULL HELP AND SAMPLES](https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate)
package/img/logo.png CHANGED
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-boolean-logic-ultimate",
3
- "version": "1.1.8",
3
+ "version": "1.1.11",
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": {