node-red-contrib-boolean-logic-ultimate 1.1.9 → 1.1.12

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,14 @@
3
3
 
4
4
  # CHANGELOG
5
5
 
6
+ <p>
7
+ <b>Version 1.1.12</b> Mai 2024<br/>
8
+ - FIX: fixed the empty JSON for old injectUltimate nodes.</br>
9
+ </p>
10
+ <p>
11
+ <b>Version 1.1.11</b> Mai 2024<br/>
12
+ - NEW: inject node now can inject a JSON as well.</br>
13
+ </p>
6
14
  <p>
7
15
  <b>Version 1.1.9</b> Mai 2024<br/>
8
16
  - 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,35 @@
53
54
  function () {
54
55
  return this.name + " " + this.topic;
55
56
  },
57
+ oneditprepare: function () {
58
+ var node = this;
59
+
60
+ if (node.outputJSON === undefined || node.outputJSON === '') node.outputJSON = '{ \n\t"payload":"hello",\n\t"topic":"1"\n}';
61
+ node.editor = RED.editor.createEditor({
62
+ id: 'node-input-editoroutputJSON',
63
+ mode: 'ace/mode/json',
64
+ value: node.outputJSON
65
+ });
66
+ if ($("#node-input-payloadPropName").val() === "") $("#node-input-payloadPropName").val("payload");
67
+ },
68
+ oneditsave: function () {
69
+ var node = this;
70
+ node.outputJSON = node.editor.getValue();
71
+ node.editor.destroy();
72
+ delete node.editor;
73
+ },
74
+ oneditcancel: function () {
75
+ var node = this;
76
+ node.editor.destroy();
77
+ delete node.editor;
78
+ },
56
79
  paletteLabel: function () {
57
80
  return "InjectUltimate";
58
81
  }
59
82
  });
60
83
  </script>
61
84
 
62
- <script type="text/x-red" data-template-name="InjectUltimate">
85
+ <script type="text/html" data-template-name="InjectUltimate">
63
86
  <div class="form-row">
64
87
  <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
88
  &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 +97,31 @@
74
97
  <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
75
98
  <input type="text" id="node-input-topic" placeholder="Topic">
76
99
  </div>
100
+ <div class="form-row" >
101
+ <label style="width:300px;" for="node-input-outputJSON"><i class="fa fa-tasks"></i> JSON</label>
102
+ <div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-editoroutputJSON"></div>
103
+ </div>
77
104
  </script>
78
105
 
79
106
  <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>
107
+ <p>The pourpose of this node is to send a msg to all output pins at once.</p>
108
+
109
+ **Configuration**
110
+
111
+ |Property|Description|
112
+ |--|--|
113
+ | Name | Node name.|
114
+ | Topic | The msg output topic. It can be overridden by the JSON field, but only in the output pin #4.|
115
+ | JSON | The pin #4 will output this JSON message.|
116
+
117
+ ### Output
81
118
 
82
- This is useful if you need to simply test your flow.
119
+ - pin1 : true
120
+ - pin2 : false
121
+ - pin3 : toggle
122
+ - pin4 : json object
123
+ <br/>
124
+ <br/>
83
125
 
84
126
 
85
127
  [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 === '') ? '{ \n\t"payload":"hello",\n\t"topic":"1"\n}' : 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.trace });
41
+ RED.log.error("injectUltimate: node.outputJSON = JSON.parse(node.outputJSON) error:" + error.trace);
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.12",
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": {