node-red-contrib-boolean-logic-ultimate 1.0.63 → 1.1.1
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 +8 -0
- package/README.md +1 -0
- package/boolean-logic-ultimate/BooleanLogicUltimate.html +12 -1
- package/boolean-logic-ultimate/BooleanLogicUltimate.js +488 -338
- package/boolean-logic-ultimate/Comparator.html +3 -2
- package/boolean-logic-ultimate/Comparator.js +1 -1
- package/boolean-logic-ultimate/FilterUltimate.html +15 -3
- package/boolean-logic-ultimate/FilterUltimate.js +67 -46
- package/boolean-logic-ultimate/InterruptFlowUltimate.html +14 -2
- package/boolean-logic-ultimate/InterruptFlowUltimate.js +155 -93
- package/boolean-logic-ultimate/InvertUltimate.html +13 -4
- package/boolean-logic-ultimate/InvertUltimate.js +74 -46
- package/boolean-logic-ultimate/RailwaySwitchUltimate.html +12 -1
- package/boolean-logic-ultimate/RailwaySwitchUltimate.js +110 -71
- package/boolean-logic-ultimate/SumUltimate.js +1 -0
- package/boolean-logic-ultimate/toggleUltimate.html +12 -2
- package/boolean-logic-ultimate/toggleUltimate.js +1 -1
- package/boolean-logic-ultimate/translator-config.html +63 -0
- package/boolean-logic-ultimate/translator-config.js +8 -0
- package/boolean-logic-ultimate/utils.js +52 -43
- package/package.json +3 -2
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
topic2: {
|
|
19
19
|
value: "", required: true
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
},
|
|
22
22
|
inputs: 1,
|
|
23
23
|
outputs: 1,
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
oneditprepare: function () {
|
|
33
33
|
if ($("#node-input-property").val() === "") $("#node-input-property").val("payload");
|
|
34
|
-
$("#node-input-property").typedInput({ default: 'msg', types: ['msg'] });
|
|
34
|
+
$("#node-input-property").typedInput({ default: 'msg', types: ['msg'] });
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
</script>
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
<label for="node-input-topic2"><i class="icon-tag"></i> Topic 2</label>
|
|
71
71
|
<input type="text" id="node-input-topic2" placeholder="For example, topic 2">
|
|
72
72
|
</div>
|
|
73
|
+
|
|
73
74
|
</script>
|
|
74
75
|
|
|
75
76
|
<script type="text/markdown" data-help-name="Comparator">
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
name: {
|
|
7
7
|
value: "Filter"
|
|
8
8
|
},
|
|
9
|
-
payloadPropName: { value: "payload", required: false }
|
|
9
|
+
payloadPropName: { value: "payload", required: false },
|
|
10
|
+
translatorConfig: { type: "translator-config", required: false }
|
|
10
11
|
},
|
|
11
12
|
inputs: 1,
|
|
12
13
|
outputs: 2,
|
|
@@ -31,14 +32,14 @@
|
|
|
31
32
|
paletteLabel: function () {
|
|
32
33
|
return "FilterUltimate";
|
|
33
34
|
},
|
|
34
|
-
oneditprepare: function () {
|
|
35
|
+
oneditprepare: function () {
|
|
35
36
|
if ($("#node-input-payloadPropName").val() === "") $("#node-input-payloadPropName").val("payload");
|
|
36
37
|
$("#node-input-payloadPropName").typedInput({ default: 'msg', types: ['msg'] });
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
</script>
|
|
40
41
|
|
|
41
|
-
<script type="text/
|
|
42
|
+
<script type="text/html" data-template-name="FilterUltimate">
|
|
42
43
|
<div class="form-row">
|
|
43
44
|
<b>Filter Ultimate</b>    <span style="color:red"><i class="fa fa-question-circle"></i> <a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
|
|
44
45
|
   <span style="color:red"><i class="fa fa-youtube-play"></i> <a target="_blank" href="https://youtu.be/DXfpXRM-LJA"><u>Youtube Sample</u></a></span>
|
|
@@ -53,6 +54,16 @@
|
|
|
53
54
|
<label for="node-input-payloadPropName"><i class="fa fa-ellipsis-h"></i> Input</label>
|
|
54
55
|
<input type="text" id="node-input-payloadPropName">
|
|
55
56
|
</div>
|
|
57
|
+
|
|
58
|
+
<div class="form-row">
|
|
59
|
+
<br />
|
|
60
|
+
<b>Translator</b>
|
|
61
|
+
<br/>
|
|
62
|
+
<label for="node-input-translatorConfig" >
|
|
63
|
+
<font color="green" size="4px"><i class="fa fa-sign-in" aria-hidden="true"></i></font> Input
|
|
64
|
+
</label>
|
|
65
|
+
<input type="text" id="node-input-translatorConfig" />
|
|
66
|
+
</div>
|
|
56
67
|
</script>
|
|
57
68
|
|
|
58
69
|
<script type="text/markdown" data-help-name="FilterUltimate">
|
|
@@ -67,6 +78,7 @@ The input message is preserved and passed to the output, changing only the topic
|
|
|
67
78
|
|Property|Description|
|
|
68
79
|
|--|--|
|
|
69
80
|
| 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"* |
|
|
81
|
+
| Translator Input | Translates the incoming <code>payload</code> value, to true/false. This allows the compatibility with, for example, **HomeAssistant** nodes. |
|
|
70
82
|
|
|
71
83
|
<br/>
|
|
72
84
|
|
|
@@ -1,55 +1,76 @@
|
|
|
1
1
|
module.exports = function (RED) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
function FilterUltimate(config) {
|
|
3
|
+
RED.nodes.createNode(this, config);
|
|
4
|
+
this.config = config;
|
|
5
|
+
var node = this;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
function setNodeStatus({ fill, shape, text }) {
|
|
8
|
+
let dDate = new Date();
|
|
9
|
+
node.status({
|
|
10
|
+
fill: fill,
|
|
11
|
+
shape: shape,
|
|
12
|
+
text:
|
|
13
|
+
text +
|
|
14
|
+
" (" +
|
|
15
|
+
dDate.getDate() +
|
|
16
|
+
", " +
|
|
17
|
+
dDate.toLocaleTimeString() +
|
|
18
|
+
")",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
11
21
|
|
|
22
|
+
setNodeStatus({ fill: "grey", shape: "dot", text: "Waiting" });
|
|
23
|
+
this.on("input", function (msg) {
|
|
24
|
+
const utils = require("./utils.js");
|
|
25
|
+
let sPayload = utils.fetchFromObject(
|
|
26
|
+
msg,
|
|
27
|
+
config.payloadPropName || "payload"
|
|
28
|
+
);
|
|
12
29
|
|
|
13
|
-
|
|
14
|
-
|
|
30
|
+
// 15/11/2021 inform user about undefined topic or payload
|
|
31
|
+
if (sPayload === undefined) {
|
|
32
|
+
setNodeStatus({
|
|
33
|
+
fill: "red",
|
|
34
|
+
shape: "dot",
|
|
35
|
+
text: "Received invalid payload from " + msg.topic || "",
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
15
39
|
|
|
16
|
-
|
|
17
|
-
|
|
40
|
+
var bRes = null;
|
|
41
|
+
try {
|
|
42
|
+
bRes = utils.ToBoolean(
|
|
43
|
+
sPayload,
|
|
44
|
+
RED.nodes.getNode(config.translatorConfig) // Retrieve the config node. It can be null, but it's handled in utils.js
|
|
45
|
+
);
|
|
46
|
+
} catch (error) {}
|
|
18
47
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
48
|
+
if (bRes === undefined || bRes === null) {
|
|
49
|
+
setNodeStatus({
|
|
50
|
+
fill: "red",
|
|
51
|
+
shape: "dot",
|
|
52
|
+
text:
|
|
53
|
+
"Received non convertible boolean value " +
|
|
54
|
+
sPayload +
|
|
55
|
+
" from " +
|
|
56
|
+
msg.topic,
|
|
57
|
+
});
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
24
60
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
bRes = utils.ToBoolean(sPayload);
|
|
29
|
-
} catch (error) {
|
|
30
|
-
}
|
|
61
|
+
// 24/01/2020 Clone input message and replace only payload
|
|
62
|
+
var msgOut = RED.util.cloneMessage(msg);
|
|
63
|
+
msgOut.payload = bRes;
|
|
31
64
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
65
|
+
if (bRes === true) {
|
|
66
|
+
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) true" });
|
|
67
|
+
node.send([msgOut, null]);
|
|
68
|
+
} else if (bRes === false) {
|
|
69
|
+
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) false" });
|
|
70
|
+
node.send([null, msgOut]);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
36
74
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
msgOut.payload = bRes;
|
|
40
|
-
|
|
41
|
-
if (bRes === true) {
|
|
42
|
-
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) true" });
|
|
43
|
-
node.send([msgOut, null]);
|
|
44
|
-
} else if (bRes === false) {
|
|
45
|
-
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) false" });
|
|
46
|
-
node.send([null, msgOut]);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
RED.nodes.registerType("FilterUltimate", FilterUltimate);
|
|
55
|
-
}
|
|
75
|
+
RED.nodes.registerType("FilterUltimate", FilterUltimate);
|
|
76
|
+
};
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
triggertopic: { value: "trigger" },
|
|
8
8
|
initializewith: { value: "1" },
|
|
9
9
|
autoToggle: { value: "0" },
|
|
10
|
-
payloadPropName: { value: "payload", required: false }
|
|
10
|
+
payloadPropName: { value: "payload", required: false },
|
|
11
|
+
translatorConfig: { type: "translator-config", required: false }
|
|
11
12
|
},
|
|
12
13
|
inputs: 1,
|
|
13
14
|
outputs: 1,
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
});
|
|
40
41
|
</script>
|
|
41
42
|
|
|
42
|
-
<script type="text/
|
|
43
|
+
<script type="text/html" data-template-name="InterruptFlowUltimate">
|
|
43
44
|
<div class="form-row">
|
|
44
45
|
<b>Interrupt Flow Ultimate</b>    <span style="color:red"><i class="fa fa-question-circle"></i> <a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
|
|
45
46
|
   <span style="color:red"><i class="fa fa-youtube-play"></i> <a target="_blank" href="https://youtu.be/1T1g0HCeYA8"><u>Youtube Sample</u></a></span>
|
|
@@ -84,6 +85,16 @@
|
|
|
84
85
|
<option value="120">Toggle above option after 120 seconds</option>
|
|
85
86
|
</select>
|
|
86
87
|
</div>
|
|
88
|
+
|
|
89
|
+
<div class="form-row">
|
|
90
|
+
<br />
|
|
91
|
+
<b>Translator</b>
|
|
92
|
+
<br/>
|
|
93
|
+
<label for="node-input-translatorConfig" >
|
|
94
|
+
<font color="green" size="4px"><i class="fa fa-sign-in" aria-hidden="true"></i></font> Input
|
|
95
|
+
</label>
|
|
96
|
+
<input type="text" id="node-input-translatorConfig" />
|
|
97
|
+
</div>
|
|
87
98
|
</script>
|
|
88
99
|
|
|
89
100
|
<script type="text/markdown" data-help-name="InterruptFlowUltimate">
|
|
@@ -96,6 +107,7 @@
|
|
|
96
107
|
| Trigger by topic | Whenever the node receives a payload = false from this topic,it stops output messages to the flow. As soon it receives payload = true from this topic, the output messages start to flow out again. The node will output the current stored message plus an added property "isReplay = true", as soon as it receives a ***msg.play = true*** from this topic. The node will clear the current stored message, as soon as it receives a ***msg.reset = true*** from this topic. |
|
|
97
108
|
| With 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"* |
|
|
98
109
|
| Then | This property, allow you to auto toggle the selected start state (pass or block) after a timer has elapsed. You can choose from some pre-defined delays. If you have, for example, an Homekit-Bridged nodeset with a thermostat node or security system node in your flow, once node-red restarts, these homekit nodes output a default message to the flow. Just put an InterruptFlow node with a "block at start" behaviour and a toggle delay enabled behind homekit nodes, to temporary stop the chained nodes to receive the unwanted startup message.|
|
|
110
|
+
| Translator Input | Translates the incoming <code>payload</code> value, to true/false. This allows the compatibility with, for example, **HomeAssistant** nodes. |
|
|
99
111
|
|
|
100
112
|
<br/>
|
|
101
113
|
|
|
@@ -1,101 +1,163 @@
|
|
|
1
1
|
module.exports = function (RED) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
function InterruptFlowUltimate(config) {
|
|
3
|
+
RED.nodes.createNode(this, config);
|
|
4
|
+
this.config = config;
|
|
5
|
+
var node = this;
|
|
6
|
+
node.currentMsg = {}; // Stores current payload
|
|
7
|
+
node.sTriggerTopic =
|
|
8
|
+
node.config.triggertopic.replace(
|
|
9
|
+
/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,
|
|
10
|
+
""
|
|
11
|
+
) || "trigger"; // Topic controlling the bInviaMessaggio
|
|
12
|
+
node.bInviaMessaggio =
|
|
13
|
+
node.config.initializewith === undefined ||
|
|
14
|
+
node.config.initializewith === "1"
|
|
15
|
+
? true
|
|
16
|
+
: false; // Send the message or not
|
|
17
|
+
node.autoToggle =
|
|
18
|
+
config.autoToggle === undefined ? 0 : parseInt(config.autoToggle); // Auto toggle the selected "initializewith" after a while (useful for homekit bridged, that sends junk after start)
|
|
19
|
+
node.timerAutoToggle = null;
|
|
11
20
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
function setNodeStatus({ fill, shape, text }) {
|
|
22
|
+
let dDate = new Date();
|
|
23
|
+
node.status({
|
|
24
|
+
fill: fill,
|
|
25
|
+
shape: shape,
|
|
26
|
+
text:
|
|
27
|
+
text +
|
|
28
|
+
" (" +
|
|
29
|
+
dDate.getDate() +
|
|
30
|
+
", " +
|
|
31
|
+
dDate.toLocaleTimeString() +
|
|
32
|
+
")",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
setNodeStatus({ fill: "green", shape: "ring", text: "-> pass" });
|
|
17
36
|
|
|
37
|
+
node.alignStatus = () => {
|
|
38
|
+
let sAutoToggle =
|
|
39
|
+
node.autoToggle > 0 ? " (Autotoggle in " + node.autoToggle + "s)" : "";
|
|
40
|
+
if (node.bInviaMessaggio) {
|
|
41
|
+
setNodeStatus({
|
|
42
|
+
fill: "green",
|
|
43
|
+
shape: "dot",
|
|
44
|
+
text: "-> pass" + sAutoToggle,
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
setNodeStatus({
|
|
48
|
+
fill: "red",
|
|
49
|
+
shape: "dot",
|
|
50
|
+
text: "|| stop" + sAutoToggle,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
18
54
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
55
|
+
if (node.autoToggle > 0) {
|
|
56
|
+
node.timerAutoToggle = setTimeout(() => {
|
|
57
|
+
node.autoToggle = 0;
|
|
58
|
+
node.bInviaMessaggio = !node.bInviaMessaggio;
|
|
59
|
+
node.alignStatus();
|
|
60
|
+
}, node.autoToggle * 1000);
|
|
61
|
+
}
|
|
27
62
|
|
|
28
|
-
|
|
29
|
-
node.timerAutoToggle = setTimeout(() => {
|
|
30
|
-
node.autoToggle = 0;
|
|
31
|
-
node.bInviaMessaggio = !node.bInviaMessaggio;
|
|
32
|
-
node.alignStatus();
|
|
33
|
-
}, node.autoToggle * 1000);
|
|
34
|
-
}
|
|
63
|
+
node.alignStatus();
|
|
35
64
|
|
|
36
|
-
|
|
65
|
+
this.on("input", function (msg) {
|
|
66
|
+
var sIncomingTopic = "";
|
|
67
|
+
if (msg.hasOwnProperty("topic")) {
|
|
68
|
+
// 06/11/2019
|
|
69
|
+
if (!msg.hasOwnProperty("topic") || msg.topic === undefined)
|
|
70
|
+
msg.topic = "NoTopicReceived";
|
|
71
|
+
sIncomingTopic = msg.topic.replace(
|
|
72
|
+
/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,
|
|
73
|
+
""
|
|
74
|
+
); // Cut unwanted Characters
|
|
75
|
+
if (sIncomingTopic === node.sTriggerTopic) {
|
|
76
|
+
const utils = require("./utils.js");
|
|
77
|
+
let sPayload = utils.fetchFromObject(
|
|
78
|
+
msg,
|
|
79
|
+
config.payloadPropName || "payload"
|
|
80
|
+
);
|
|
81
|
+
// 15/11/2021 inform user about undefined topic or payload
|
|
82
|
+
if (sPayload === undefined) {
|
|
83
|
+
setNodeStatus({
|
|
84
|
+
fill: "red",
|
|
85
|
+
shape: "dot",
|
|
86
|
+
text: "Received invalid payload from " + msg.topic || "",
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
msg.payload = utils.ToBoolean(
|
|
91
|
+
sPayload,
|
|
92
|
+
RED.nodes.getNode(config.translatorConfig) // Retrieve the config node. It can be null, but it's handled in utils.js; // 15/11/2021 Convert input to boolean.
|
|
93
|
+
);
|
|
94
|
+
if (msg.payload === undefined) return null;
|
|
95
|
+
if (node.timerAutoToggle !== null)
|
|
96
|
+
// 28/01/2022 Stop autotoggle
|
|
97
|
+
clearInterval(node.timerAutoToggle);
|
|
37
98
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
99
|
+
if (msg.hasOwnProperty("play")) {
|
|
100
|
+
if (node.currentMsg.payload !== undefined) {
|
|
101
|
+
node.currentMsg.isReplay = true;
|
|
102
|
+
setNodeStatus({
|
|
103
|
+
fill: "yellow",
|
|
104
|
+
shape: "dot",
|
|
105
|
+
text: "-> replay",
|
|
106
|
+
});
|
|
107
|
+
// Restore previous status
|
|
108
|
+
let t = setTimeout(() => {
|
|
109
|
+
if (node.bInviaMessaggio) {
|
|
110
|
+
setNodeStatus({
|
|
111
|
+
fill: "green",
|
|
112
|
+
shape: "dot",
|
|
113
|
+
text: "-> pass",
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
setNodeStatus({
|
|
117
|
+
fill: "red",
|
|
118
|
+
shape: "dot",
|
|
119
|
+
text: "|| stop (stored last msg)",
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, 1000);
|
|
123
|
+
node.send(node.currentMsg);
|
|
124
|
+
} else {
|
|
125
|
+
setNodeStatus({
|
|
126
|
+
fill: "grey",
|
|
127
|
+
shape: "dot",
|
|
128
|
+
text: "Nothing to replay",
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
} else if (msg.hasOwnProperty("reset")) {
|
|
133
|
+
node.currentMsg = {};
|
|
134
|
+
setNodeStatus({
|
|
135
|
+
fill: "yellow",
|
|
136
|
+
shape: "dot",
|
|
137
|
+
text: "Deleted stored msg",
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
} else if (msg.payload === true) {
|
|
141
|
+
node.bInviaMessaggio = true;
|
|
142
|
+
setNodeStatus({ fill: "green", shape: "dot", text: "-> pass" });
|
|
143
|
+
return;
|
|
144
|
+
} else if (msg.payload === false) {
|
|
145
|
+
node.bInviaMessaggio = false;
|
|
146
|
+
setNodeStatus({
|
|
147
|
+
fill: "red",
|
|
148
|
+
shape: "dot",
|
|
149
|
+
text: "|| stop (stored last msg)",
|
|
150
|
+
});
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
node.currentMsg = RED.util.cloneMessage(msg);
|
|
156
|
+
if (node.bInviaMessaggio) {
|
|
157
|
+
node.send(msg);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
45
161
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// 15/11/2021 inform user about undefined topic or payload
|
|
49
|
-
if (sPayload === undefined ) {
|
|
50
|
-
setNodeStatus({ fill: "red", shape: "dot", text: "Received invalid payload from " + msg.topic || "" });
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
msg.payload = utils.ToBoolean(sPayload); // 15/11/2021 Convert input to boolean.
|
|
54
|
-
|
|
55
|
-
// 28/01/2022 Stop autotoggle
|
|
56
|
-
if (node.timerAutoToggle !== null) clearInterval(node.timerAutoToggle);
|
|
57
|
-
|
|
58
|
-
if (msg.hasOwnProperty("play")) {
|
|
59
|
-
if (node.currentMsg.payload !== undefined) {
|
|
60
|
-
node.currentMsg.isReplay = true;
|
|
61
|
-
setNodeStatus({ fill: "yellow", shape: "dot", text: "-> replay" });
|
|
62
|
-
// Restore previous status
|
|
63
|
-
let t = setTimeout(() => {
|
|
64
|
-
if (node.bInviaMessaggio) {
|
|
65
|
-
setNodeStatus({ fill: "green", shape: "dot", text: "-> pass" });
|
|
66
|
-
} else {
|
|
67
|
-
setNodeStatus({ fill: "red", shape: "dot", text: "|| stop (stored last msg)" });
|
|
68
|
-
}
|
|
69
|
-
}, 1000)
|
|
70
|
-
node.send(node.currentMsg);
|
|
71
|
-
} else {
|
|
72
|
-
setNodeStatus({ fill: "grey", shape: "dot", text: "Nothing to replay" });
|
|
73
|
-
}
|
|
74
|
-
return;
|
|
75
|
-
} else if (msg.hasOwnProperty("reset")) {
|
|
76
|
-
node.currentMsg = {};
|
|
77
|
-
setNodeStatus({ fill: "yellow", shape: "dot", text: "Deleted stored msg" });
|
|
78
|
-
return;
|
|
79
|
-
} else if (msg.payload === true) {
|
|
80
|
-
node.bInviaMessaggio = true;
|
|
81
|
-
setNodeStatus({ fill: "green", shape: "dot", text: "-> pass" });
|
|
82
|
-
return;
|
|
83
|
-
} else if (msg.payload === false) {
|
|
84
|
-
node.bInviaMessaggio = false;
|
|
85
|
-
setNodeStatus({ fill: "red", shape: "dot", text: "|| stop (stored last msg)" });
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
node.currentMsg = RED.util.cloneMessage(msg);
|
|
91
|
-
if (node.bInviaMessaggio) {
|
|
92
|
-
node.send(msg);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
RED.nodes.registerType("InterruptFlowUltimate", InterruptFlowUltimate);
|
|
101
|
-
}
|
|
162
|
+
RED.nodes.registerType("InterruptFlowUltimate", InterruptFlowUltimate);
|
|
163
|
+
};
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
name: {
|
|
7
7
|
value: "Invert"
|
|
8
8
|
},
|
|
9
|
-
payloadPropName: { value: "payload", required: false }
|
|
9
|
+
payloadPropName: { value: "payload", required: false },
|
|
10
|
+
translatorConfig: { type: "translator-config", required: false }
|
|
10
11
|
},
|
|
11
12
|
inputs:1,
|
|
12
13
|
outputs:1,
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
});
|
|
26
27
|
</script>
|
|
27
28
|
|
|
28
|
-
<script type="text/
|
|
29
|
+
<script type="text/html" data-template-name="InvertUltimate">
|
|
29
30
|
<div class="form-row">
|
|
30
31
|
<b>Invert Ultimate</b>    <span style="color:red"><i class="fa fa-question-circle"></i> <a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
|
|
31
32
|
   <span style="color:red"><i class="fa fa-youtube-play"></i> <a target="_blank" href="https://youtu.be/A41x8VevZD8"><u>Youtube Sample</u></a></span>
|
|
@@ -40,6 +41,15 @@
|
|
|
40
41
|
<label for="node-input-payloadPropName"><i class="fa fa-ellipsis-h"></i> Input</label>
|
|
41
42
|
<input type="text" id="node-input-payloadPropName">
|
|
42
43
|
</div>
|
|
44
|
+
<div class="form-row">
|
|
45
|
+
<br />
|
|
46
|
+
<b>Translator</b>
|
|
47
|
+
<br />
|
|
48
|
+
<label for="node-input-translatorConfig">
|
|
49
|
+
<font color="green" size="4px"><i class="fa fa-sign-in" aria-hidden="true"></i></font> Input
|
|
50
|
+
</label>
|
|
51
|
+
<input type="text" id="node-input-translatorConfig" />
|
|
52
|
+
</div>
|
|
43
53
|
</script>
|
|
44
54
|
|
|
45
55
|
<script type="text/markdown" data-help-name="InvertUltimate">
|
|
@@ -50,11 +60,10 @@ The input message is preserved and passed to the output, changing only the topic
|
|
|
50
60
|
|Property|Description|
|
|
51
61
|
|--|--|
|
|
52
62
|
| 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"* |
|
|
63
|
+
| Translator Input | Translates the incoming <code>payload</code> value, to true/false. This allows the compatibility with, for example, **HomeAssistant** nodes. |
|
|
53
64
|
|
|
54
65
|
<br/>
|
|
55
66
|
|
|
56
|
-
[SEE THE README FOR FULL HELP AND SAMPLES](https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate)
|
|
57
|
-
|
|
58
67
|
[Find it useful?](https://www.paypal.me/techtoday)
|
|
59
68
|
|
|
60
69
|
</script>
|