@mschaeffler/node-red-logic 0.1.0 → 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 +5 -0
- package/logic_and.html +8 -1
- package/logic_and.js +3 -1
- package/logic_bool.html +8 -1
- package/logic_bool.js +9 -2
- package/logic_or.html +8 -1
- package/logic_or.js +2 -0
- package/math_number.html +8 -1
- package/math_number.js +10 -3
- package/math_reduce.html +8 -1
- package/math_reduce.js +2 -0
- 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
|
|
|
@@ -87,6 +88,7 @@ The message property to be used as payload can be defined with the `Property` pr
|
|
|
87
88
|
|
|
88
89
|
|config| type | description |
|
|
89
90
|
|:-----|:-------|:----------------------------------|
|
|
91
|
+
|Topic | string | defines the topic for the output message.|
|
|
90
92
|
|Property| string | defines the message property to be used as payload.|
|
|
91
93
|
|min. Data|number|min. amount of topics to generate an output.|
|
|
92
94
|
|
|
@@ -118,6 +120,7 @@ The message property to be used as payload can be defined with the `Property` pr
|
|
|
118
120
|
|
|
119
121
|
|config| type | description |
|
|
120
122
|
|:-----|:-------|:----------------------------------|
|
|
123
|
+
|Topic | string | defines the topic for the output message.|
|
|
121
124
|
|Property| string | defines the message property to be used as payload.|
|
|
122
125
|
|min. Data|number|min. amount of topics to generate an output.|
|
|
123
126
|
|
|
@@ -144,6 +147,7 @@ The message property to be used as payload can be defined with the `Property` pr
|
|
|
144
147
|
|config| type | description |
|
|
145
148
|
|:-----|:-------|:----------------------------------|
|
|
146
149
|
|Property| string | defines the message property to be used as payload.|
|
|
150
|
+
|Status|boolean|shows the actual value as a node status.|
|
|
147
151
|
|
|
148
152
|
### reduce
|
|
149
153
|
|
|
@@ -173,6 +177,7 @@ The message property to be used as payload can be defined with the `Property` pr
|
|
|
173
177
|
|
|
174
178
|
|config| type | description |
|
|
175
179
|
|:-----|:-------|:----------------------------------|
|
|
180
|
+
|Topic | string | defines the topic for the output message.|
|
|
176
181
|
|Property| string | defines the message property to be used as payload.|
|
|
177
182
|
|min. Mean|number|min. amount of values for the arithmatic mean of one topic.|
|
|
178
183
|
|max. Mean|number|max. amount of values for the arithmatic mean of one topic.|
|
package/logic_and.html
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
color: "#C0DEED",
|
|
5
5
|
defaults: {
|
|
6
6
|
name:{value:""},
|
|
7
|
+
topic:{value:""},
|
|
7
8
|
property:{value:"payload", required:true},
|
|
8
9
|
minData:{value:"1", required:true, validate:function(v){
|
|
9
10
|
return v!=='' && !isNaN(v) && Number(v)>0;
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
outputs:1,
|
|
14
15
|
icon: "font-awesome/fa-chevron-up",
|
|
15
16
|
label: function() {
|
|
16
|
-
return this.name||"and";
|
|
17
|
+
return this.name||this.topic||"and";
|
|
17
18
|
},
|
|
18
19
|
inputLabels: 'input',
|
|
19
20
|
outputLabels: 'and',
|
|
@@ -32,6 +33,10 @@
|
|
|
32
33
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
33
34
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
34
35
|
</div>
|
|
36
|
+
<div class="form-row">
|
|
37
|
+
<label for="node-input-topic"><i class="fa fa-envelope-o"></i> Topic</label>
|
|
38
|
+
<input type="text" id="node-input-topic" placeholder="Topic">
|
|
39
|
+
</div>
|
|
35
40
|
<div class="form-row">
|
|
36
41
|
<label for="node-input-input"><i class="fa fa-ellipsis-h"></i> Eigenschaft</label>
|
|
37
42
|
<input type="text" id="node-input-property">
|
|
@@ -72,6 +77,8 @@
|
|
|
72
77
|
<h3>Parameter</h3>
|
|
73
78
|
|
|
74
79
|
<dl class="message-properties">
|
|
80
|
+
<dt>Topic <span class="property-type">string</span></dt>
|
|
81
|
+
<dd> defines the topic for the output message.</dd>
|
|
75
82
|
<dt>Property <span class="property-type">string</span></dt>
|
|
76
83
|
<dd> defines the message property to be used as payload.</dd>
|
|
77
84
|
<dt>min. Data <span class="property-type">number</span></dt>
|
package/logic_and.js
CHANGED
|
@@ -6,18 +6,20 @@ module.exports = function(RED) {
|
|
|
6
6
|
//this.config = config;
|
|
7
7
|
var node = this;
|
|
8
8
|
var context = this.context();
|
|
9
|
+
this.topic = config.topic;
|
|
9
10
|
this.property = config.property || "payload";
|
|
10
11
|
this.minData = Number( config.minData );
|
|
11
12
|
|
|
12
13
|
node.on('input', function(msg,send,done) {
|
|
13
14
|
const payload = tools.property2boolean( RED.util.getMessageProperty( msg, node.property ) );
|
|
14
15
|
|
|
15
|
-
if( payload
|
|
16
|
+
if( payload !== null )
|
|
16
17
|
{
|
|
17
18
|
let data = context.get( "data" ) ?? {};
|
|
18
19
|
data[msg.topic] = payload;
|
|
19
20
|
context.set( "data", data );
|
|
20
21
|
|
|
22
|
+
msg.topic = node.topic;
|
|
21
23
|
msg.payload = true;
|
|
22
24
|
msg.count = 0;
|
|
23
25
|
for( const item in data )
|
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/logic_or.html
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
color: "#C0DEED",
|
|
5
5
|
defaults: {
|
|
6
6
|
name:{value:""},
|
|
7
|
+
topic:{value:""},
|
|
7
8
|
property:{value:"payload", required:true},
|
|
8
9
|
minData:{value:"1", required:true, validate:function(v){
|
|
9
10
|
return v!=='' && !isNaN(v) && Number(v)>0;
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
outputs:1,
|
|
14
15
|
icon: "font-awesome/fa-chevron-down",
|
|
15
16
|
label: function() {
|
|
16
|
-
return this.name||"or";
|
|
17
|
+
return this.name||this.topic||"or";
|
|
17
18
|
},
|
|
18
19
|
inputLabels: 'input',
|
|
19
20
|
outputLabels: 'or',
|
|
@@ -32,6 +33,10 @@
|
|
|
32
33
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
33
34
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
34
35
|
</div>
|
|
36
|
+
<div class="form-row">
|
|
37
|
+
<label for="node-input-topic"><i class="fa fa-envelope-o"></i> Topic</label>
|
|
38
|
+
<input type="text" id="node-input-topic" placeholder="Topic">
|
|
39
|
+
</div>
|
|
35
40
|
<div class="form-row">
|
|
36
41
|
<label for="node-input-input"><i class="fa fa-ellipsis-h"></i> Eigenschaft</label>
|
|
37
42
|
<input type="text" id="node-input-property">
|
|
@@ -72,6 +77,8 @@
|
|
|
72
77
|
<h3>Parameter</h3>
|
|
73
78
|
|
|
74
79
|
<dl class="message-properties">
|
|
80
|
+
<dt>Topic <span class="property-type">string</span></dt>
|
|
81
|
+
<dd> defines the topic for the output message.</dd>
|
|
75
82
|
<dt>Property <span class="property-type">string</span></dt>
|
|
76
83
|
<dd> defines the message property to be used as payload.</dd>
|
|
77
84
|
<dt>min. Data <span class="property-type">number</span></dt>
|
package/logic_or.js
CHANGED
|
@@ -6,6 +6,7 @@ module.exports = function(RED) {
|
|
|
6
6
|
//this.config = config;
|
|
7
7
|
var node = this;
|
|
8
8
|
var context = this.context();
|
|
9
|
+
this.topic = config.topic;
|
|
9
10
|
this.property = config.property || "payload";
|
|
10
11
|
this.minData = Number( config.minData );
|
|
11
12
|
|
|
@@ -18,6 +19,7 @@ module.exports = function(RED) {
|
|
|
18
19
|
data[msg.topic] = payload;
|
|
19
20
|
context.set( "data", data );
|
|
20
21
|
|
|
22
|
+
msg.topic = node.topic;
|
|
21
23
|
msg.payload = false;
|
|
22
24
|
msg.count = 0;
|
|
23
25
|
for( const item in data )
|
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/math_reduce.html
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
color: "#C0DEED",
|
|
5
5
|
defaults: {
|
|
6
6
|
name:{value:""},
|
|
7
|
+
topic:{value:""},
|
|
7
8
|
property:{value:"payload", required:true},
|
|
8
9
|
minMean:{value:"1", required:true, validate:function(v){
|
|
9
10
|
return v!=='' && !isNaN(v) && Number(v)>0;}
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
}
|
|
32
33
|
},
|
|
33
34
|
label: function() {
|
|
34
|
-
return this.name||this.algo||"reduce";
|
|
35
|
+
return this.name||this.topic||this.algo||"reduce";
|
|
35
36
|
},
|
|
36
37
|
inputLabels: 'input',
|
|
37
38
|
outputLabels: 'output',
|
|
@@ -62,6 +63,10 @@
|
|
|
62
63
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
63
64
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
64
65
|
</div>
|
|
66
|
+
<div class="form-row">
|
|
67
|
+
<label for="node-input-topic"><i class="fa fa-envelope-o"></i> Topic</label>
|
|
68
|
+
<input type="text" id="node-input-topic" placeholder="Topic">
|
|
69
|
+
</div>
|
|
65
70
|
<div class="form-row">
|
|
66
71
|
<label for="node-input-input"><i class="fa fa-ellipsis-h"></i> Eigenschaft</label>
|
|
67
72
|
<input type="text" id="node-input-property">
|
|
@@ -114,6 +119,8 @@
|
|
|
114
119
|
<h3>Parameter</h3>
|
|
115
120
|
|
|
116
121
|
<dl class="message-properties">
|
|
122
|
+
<dt>Topic <span class="property-type">string</span></dt>
|
|
123
|
+
<dd> defines the topic for the output message.</dd>
|
|
117
124
|
<dt>Property <span class="property-type">string</span></dt>
|
|
118
125
|
<dd> defines the message property to be used as payload.</dd>
|
|
119
126
|
<dt>min. Mean <span class="property-type">number</span></dt>
|
package/math_reduce.js
CHANGED
|
@@ -5,6 +5,7 @@ module.exports = function(RED) {
|
|
|
5
5
|
//this.config = config;
|
|
6
6
|
var node = this;
|
|
7
7
|
var context = this.context();
|
|
8
|
+
this.topic = config.topic;
|
|
8
9
|
this.property = config.property || "payload";
|
|
9
10
|
this.minMean = Number( config.minMean );
|
|
10
11
|
this.maxMean = Number( config.maxMean );
|
|
@@ -27,6 +28,7 @@ module.exports = function(RED) {
|
|
|
27
28
|
item.push( payload )
|
|
28
29
|
data[msg.topic] = item;
|
|
29
30
|
|
|
31
|
+
msg.topic = node.topic;
|
|
30
32
|
msg.count = 0;
|
|
31
33
|
switch( node.algo )
|
|
32
34
|
{
|
package/package.json
CHANGED