node-red-contrib-boolean-logic-ultimate 1.1.9 → 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
@@ -3,6 +3,10 @@
3
3
 
4
4
  # CHANGELOG
5
5
 
6
+ <p>
7
+ <b>Version 1.1.11</b> Mai 2024<br/>
8
+ - NEW: inject node now can inject a JSON as well.</br>
9
+ </p>
6
10
  <p>
7
11
  <b>Version 1.1.9</b> Mai 2024<br/>
8
12
  - Added samples and better description of the Math's node (in particular, to the subract function).</br>
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 }) {
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.9",
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": {