@mschaeffler/node-red-logic 0.2.1 → 0.3.0
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/README.md +2 -0
- package/logic_bool.html +8 -1
- package/logic_bool.js +9 -2
- package/math_number.html +8 -1
- package/math_number.js +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,6 +58,7 @@ The message property to be used as payload can be defined with the `Property` pr
|
|
|
58
58
|
|config| type | description |
|
|
59
59
|
|:-----|:-------|:----------------------------------|
|
|
60
60
|
|Property| string | defines the message property to be used as payload.|
|
|
61
|
+
|Status|boolean|shows the actual value as a node status.|
|
|
61
62
|
|
|
62
63
|
### or
|
|
63
64
|
|
|
@@ -146,6 +147,7 @@ The message property to be used as payload can be defined with the `Property` pr
|
|
|
146
147
|
|config| type | description |
|
|
147
148
|
|:-----|:-------|:----------------------------------|
|
|
148
149
|
|Property| string | defines the message property to be used as payload.|
|
|
150
|
+
|Status|boolean|shows the actual value as a node status.|
|
|
149
151
|
|
|
150
152
|
### reduce
|
|
151
153
|
|
package/logic_bool.html
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
color: "#C0DEED",
|
|
5
5
|
defaults: {
|
|
6
6
|
name:{value:""},
|
|
7
|
-
property:{value:"payload",required:true}
|
|
7
|
+
property:{value:"payload",required:true},
|
|
8
|
+
showState:{value:false}
|
|
8
9
|
},
|
|
9
10
|
inputs:1,
|
|
10
11
|
outputs:1,
|
|
@@ -35,6 +36,10 @@
|
|
|
35
36
|
<input type="text" id="node-input-property">
|
|
36
37
|
<input type="hidden" id="node-input-property-type">
|
|
37
38
|
</div>
|
|
39
|
+
<div class="form-row">
|
|
40
|
+
<label for="node-input-showStatus"><i class="fa-star-o"></i> Status</label>
|
|
41
|
+
<input type="checkbox" id="node-input-showState" style="display:inline-block; width:20px; vertical-align:baseline;">
|
|
42
|
+
</div>
|
|
38
43
|
</script>
|
|
39
44
|
|
|
40
45
|
<script type="text/html" data-help-name="tobool">
|
|
@@ -76,6 +81,8 @@
|
|
|
76
81
|
<dl class="message-properties">
|
|
77
82
|
<dt>Property <span class="property-type">string</span></dt>
|
|
78
83
|
<dd> defines the message property to be used as payload.</dd>
|
|
84
|
+
<dt>Status <span class="property-type">boolean</span></dt>
|
|
85
|
+
<dd> shows the actual value as a node status.</dd>
|
|
79
86
|
</dl>
|
|
80
87
|
|
|
81
88
|
</script>
|
package/logic_bool.js
CHANGED
|
@@ -6,18 +6,25 @@ module.exports = function(RED) {
|
|
|
6
6
|
//this.config = config;
|
|
7
7
|
var node = this;
|
|
8
8
|
this.property = config.property || "payload";
|
|
9
|
+
this.showState = config.showState;
|
|
9
10
|
|
|
10
11
|
node.on('input', function(msg,send,done) {
|
|
11
12
|
msg.payload = tools.property2boolean( RED.util.getMessageProperty( msg, node.property ) );
|
|
12
13
|
|
|
13
14
|
if( msg.payload !== null )
|
|
14
15
|
{
|
|
15
|
-
|
|
16
|
+
if( node.showState )
|
|
17
|
+
{
|
|
18
|
+
node.status( msg.payload );
|
|
19
|
+
}
|
|
16
20
|
send( msg );
|
|
17
21
|
}
|
|
18
22
|
else
|
|
19
23
|
{
|
|
20
|
-
node.
|
|
24
|
+
if( node.showState )
|
|
25
|
+
{
|
|
26
|
+
node.status( "error" );
|
|
27
|
+
}
|
|
21
28
|
}
|
|
22
29
|
done();
|
|
23
30
|
});
|
package/math_number.html
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
color: "#C0DEED",
|
|
5
5
|
defaults: {
|
|
6
6
|
name:{value:""},
|
|
7
|
-
property:{value:"payload",required:true}
|
|
7
|
+
property:{value:"payload",required:true},
|
|
8
|
+
showState:{value:false}
|
|
8
9
|
},
|
|
9
10
|
inputs:1,
|
|
10
11
|
outputs:1,
|
|
@@ -35,6 +36,10 @@
|
|
|
35
36
|
<input type="text" id="node-input-property">
|
|
36
37
|
<input type="hidden" id="node-input-property-type">
|
|
37
38
|
</div>
|
|
39
|
+
<div class="form-row">
|
|
40
|
+
<label for="node-input-showStatus"><i class="fa-star-o"></i> Status</label>
|
|
41
|
+
<input type="checkbox" id="node-input-showState" style="display:inline-block; width:20px; vertical-align:baseline;">
|
|
42
|
+
</div>
|
|
38
43
|
</script>
|
|
39
44
|
|
|
40
45
|
<script type="text/html" data-help-name="tonumber">
|
|
@@ -62,6 +67,8 @@
|
|
|
62
67
|
<dl class="message-properties">
|
|
63
68
|
<dt>Property <span class="property-type">string</span></dt>
|
|
64
69
|
<dd> defines the message property to be used as payload.</dd>
|
|
70
|
+
<dt>Status <span class="property-type">boolean</span></dt>
|
|
71
|
+
<dd> shows the actual value as a node status.</dd>
|
|
65
72
|
</dl>
|
|
66
73
|
|
|
67
74
|
</script>
|
package/math_number.js
CHANGED
|
@@ -4,19 +4,26 @@ module.exports = function(RED) {
|
|
|
4
4
|
RED.nodes.createNode(this,config);
|
|
5
5
|
//this.config = config;
|
|
6
6
|
var node = this;
|
|
7
|
-
this.property = config.property
|
|
7
|
+
this.property = config.property ?? "payload";
|
|
8
|
+
this.showState = config.showState;
|
|
8
9
|
|
|
9
10
|
node.on('input', function(msg,send,done) {
|
|
10
11
|
msg.payload = Number( RED.util.getMessageProperty( msg, node.property ) );
|
|
11
12
|
|
|
12
13
|
if( ! isNaN( msg.payload ) )
|
|
13
14
|
{
|
|
14
|
-
|
|
15
|
+
if( node.showState )
|
|
16
|
+
{
|
|
17
|
+
node.status( msg.payload );
|
|
18
|
+
}
|
|
15
19
|
send( msg );
|
|
16
20
|
}
|
|
17
21
|
else
|
|
18
22
|
{
|
|
19
|
-
node.
|
|
23
|
+
if( node.showState )
|
|
24
|
+
{
|
|
25
|
+
node.status( "not a Number" );
|
|
26
|
+
}
|
|
20
27
|
}
|
|
21
28
|
done();
|
|
22
29
|
});
|
package/package.json
CHANGED