@mschaeffler/node-red-logic 0.0.7 → 0.2.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/README.md +107 -8
- package/counter.html +6 -1
- package/logic_and.html +38 -2
- package/logic_and.js +3 -1
- package/logic_bool.html +36 -1
- package/logic_or.html +38 -2
- package/logic_or.js +2 -0
- package/math_number.html +22 -1
- package/math_reduce.html +46 -2
- package/math_reduce.js +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,9 +12,20 @@ $ npm install @mschaeffler/node-red-logic
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### counter
|
|
16
|
+
|
|
17
|
+
A node that just count the messages.
|
|
18
|
+
|
|
19
|
+
#### Output
|
|
20
|
+
|
|
21
|
+
|msg. | type | description |
|
|
22
|
+
|:-------|:-------|:----------------------------------|
|
|
23
|
+
|count | number | number of messages.|
|
|
24
|
+
|
|
25
|
+
### to bool
|
|
16
26
|
|
|
17
27
|
Converts payload to a bool value:
|
|
28
|
+
|
|
18
29
|
|type|value|is converted to|
|
|
19
30
|
|:---|:----|:--------------|
|
|
20
31
|
|bool|false|false|
|
|
@@ -50,41 +61,129 @@ The message property to be used as payload can be defined with the `Property` pr
|
|
|
50
61
|
|
|
51
62
|
### or
|
|
52
63
|
|
|
53
|
-
.
|
|
64
|
+
Combines two or more boolean vales with the `or` operator.
|
|
65
|
+
|
|
66
|
+
The input values are converted as described in the `to bool` node.
|
|
54
67
|
|
|
55
68
|
#### Input
|
|
56
69
|
|
|
57
|
-
.
|
|
70
|
+
The different inputs are differentiated by topics.
|
|
71
|
+
|
|
72
|
+
The message property to be used as payload can be defined with the `Property` property.
|
|
58
73
|
|
|
59
74
|
|msg. | type | description |
|
|
60
75
|
|:-------|:-------|:----------------------------------|
|
|
61
|
-
|topic | string |
|
|
76
|
+
|topic | string | name of the input channel. |
|
|
62
77
|
|payload | boolean| input value for `topic`. |
|
|
63
78
|
|
|
64
79
|
#### Output
|
|
65
80
|
|
|
66
|
-
.
|
|
67
|
-
|
|
68
81
|
|msg. | type | description |
|
|
69
82
|
|:-------|:-------|:----------------------------------|
|
|
70
83
|
|payload | boolean | result of `or` of all input topics.|
|
|
84
|
+
|count | number | number of data elements.|
|
|
71
85
|
|
|
72
86
|
#### Parameters
|
|
73
87
|
|
|
74
88
|
|config| type | description |
|
|
75
89
|
|:-----|:-------|:----------------------------------|
|
|
76
|
-
|
|
|
90
|
+
|Topic | string | defines the topic for the output message.|
|
|
91
|
+
|Property| string | defines the message property to be used as payload.|
|
|
92
|
+
|min. Data|number|min. amount of topics to generate an output.|
|
|
77
93
|
|
|
78
94
|
### and
|
|
79
95
|
|
|
80
|
-
.
|
|
96
|
+
Combines two or more boolean vales with the `and` operator.
|
|
97
|
+
|
|
98
|
+
The input values are converted as described in the `to bool` node.
|
|
99
|
+
|
|
100
|
+
#### Input
|
|
101
|
+
|
|
102
|
+
The different inputs are differentiated by topics.
|
|
103
|
+
|
|
104
|
+
The message property to be used as payload can be defined with the `Property` property.
|
|
105
|
+
|
|
106
|
+
|msg. | type | description |
|
|
107
|
+
|:-------|:-------|:----------------------------------|
|
|
108
|
+
|topic | string | name of the input channel. |
|
|
109
|
+
|payload | boolean| input value for `topic`. |
|
|
110
|
+
|
|
111
|
+
#### Output
|
|
112
|
+
|
|
113
|
+
|msg. | type | description |
|
|
114
|
+
|:-------|:-------|:----------------------------------|
|
|
115
|
+
|payload | boolean | result of `and` of all input topics.|
|
|
116
|
+
|count | number | number of data elements.|
|
|
117
|
+
|
|
118
|
+
#### Parameters
|
|
119
|
+
|
|
120
|
+
|config| type | description |
|
|
121
|
+
|:-----|:-------|:----------------------------------|
|
|
122
|
+
|Topic | string | defines the topic for the output message.|
|
|
123
|
+
|Property| string | defines the message property to be used as payload.|
|
|
124
|
+
|min. Data|number|min. amount of topics to generate an output.|
|
|
125
|
+
|
|
126
|
+
### to number
|
|
127
|
+
|
|
128
|
+
Converts payload to a number.
|
|
81
129
|
|
|
82
130
|
#### Input
|
|
83
131
|
|
|
132
|
+
The message property to be used as payload can be defined with the `Property` property.
|
|
133
|
+
|
|
134
|
+
|msg. | type | description |
|
|
135
|
+
|:-------|:-------|:----------------------------------|
|
|
136
|
+
|payload | | input value. |
|
|
137
|
+
|
|
138
|
+
#### Output
|
|
139
|
+
|
|
140
|
+
|msg. | type | description |
|
|
141
|
+
|:-------|:-------|:----------------------------------|
|
|
142
|
+
|payload | number | number value of payload.|
|
|
143
|
+
|
|
144
|
+
#### Parameters
|
|
145
|
+
|
|
146
|
+
|config| type | description |
|
|
147
|
+
|:-----|:-------|:----------------------------------|
|
|
148
|
+
|Property| string | defines the message property to be used as payload.|
|
|
149
|
+
|
|
150
|
+
### reduce
|
|
151
|
+
|
|
152
|
+
Combines two or more streams of data (topics) into one single value.
|
|
153
|
+
|
|
154
|
+
Each stream can be debounced by arithmatic mean.
|
|
155
|
+
|
|
156
|
+
#### Input
|
|
157
|
+
|
|
158
|
+
The different inputs are differentiated by topics.
|
|
159
|
+
|
|
160
|
+
The message property to be used as payload can be defined with the `Property` property.
|
|
161
|
+
|
|
162
|
+
|msg. | type | description |
|
|
163
|
+
|:-------|:-------|:----------------------------------|
|
|
164
|
+
|topic | string | name of the input channel. |
|
|
165
|
+
|payload | number | input value for `topic`. |
|
|
166
|
+
|
|
84
167
|
#### Output
|
|
85
168
|
|
|
169
|
+
|msg. | type | description |
|
|
170
|
+
|:-------|:-------|:----------------------------------|
|
|
171
|
+
|payload | number | result of combining of all input topics.|
|
|
172
|
+
|count | number | number of data elements.|
|
|
173
|
+
|
|
86
174
|
#### Parameters
|
|
87
175
|
|
|
176
|
+
|config| type | description |
|
|
177
|
+
|:-----|:-------|:----------------------------------|
|
|
178
|
+
|Topic | string | defines the topic for the output message.|
|
|
179
|
+
|Property| string | defines the message property to be used as payload.|
|
|
180
|
+
|min. Mean|number|min. amount of values for the arithmatic mean of one topic.|
|
|
181
|
+
|max. Mean|number|max. amount of values for the arithmatic mean of one topic.|
|
|
182
|
+
|min. Data|number|min. amount of topics to generate an output.|
|
|
183
|
+
|Algorithm|string|algorithm to combine the values.|
|
|
184
|
+
|
|
185
|
+
#### Algorithms
|
|
186
|
+
|
|
88
187
|
## Example Flow
|
|
89
188
|
|
|
90
189
|
[example flow](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/logic.json)
|
package/counter.html
CHANGED
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">
|
|
@@ -45,8 +50,39 @@
|
|
|
45
50
|
|
|
46
51
|
<script type="text/html" data-help-name="and">
|
|
47
52
|
|
|
48
|
-
<p
|
|
53
|
+
<p>.Combines two or more boolean vales with the <code>and</code> operator.</p>
|
|
54
|
+
<p>The input values are converted as described in the <code>to bool</code> node.</p>
|
|
49
55
|
|
|
50
56
|
<h3>Input</h3>
|
|
57
|
+
|
|
58
|
+
<p>The different inputs are differentiated by topics.</p>
|
|
59
|
+
<p>The message property to be used as payload can be defined with the <code>Property</code> property.</p>
|
|
60
|
+
|
|
61
|
+
<dl class="message-properties">
|
|
62
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
63
|
+
<dd> name of the input channel.</dd>
|
|
64
|
+
<dt>payload <span class="property-type">boolean</span></dt>
|
|
65
|
+
<dd> input value for <code>topic</code>.</dd>
|
|
66
|
+
</dl>
|
|
67
|
+
|
|
68
|
+
<h3>Output</h3>
|
|
69
|
+
|
|
70
|
+
<dl class="message-properties">
|
|
71
|
+
<dt>payload <span class="property-type">boolean</span></dt>
|
|
72
|
+
<dd> result of <code>and</code> of all input topics.</dd>
|
|
73
|
+
<dt>count <span class="property-type">number</span></dt>
|
|
74
|
+
<dd> number of data elements.</dd>
|
|
75
|
+
</dl>
|
|
76
|
+
|
|
77
|
+
<h3>Parameter</h3>
|
|
51
78
|
|
|
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>
|
|
82
|
+
<dt>Property <span class="property-type">string</span></dt>
|
|
83
|
+
<dd> defines the message property to be used as payload.</dd>
|
|
84
|
+
<dt>min. Data <span class="property-type">number</span></dt>
|
|
85
|
+
<dd> min. amount of topics to generate an output.</dd>
|
|
86
|
+
</dl>
|
|
87
|
+
|
|
52
88
|
</script>
|
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
|
@@ -39,8 +39,43 @@
|
|
|
39
39
|
|
|
40
40
|
<script type="text/html" data-help-name="tobool">
|
|
41
41
|
|
|
42
|
-
<p
|
|
42
|
+
<p>Converts payload to a bool value:</p>
|
|
43
|
+
|
|
44
|
+
<table>
|
|
45
|
+
<tr> <th>type</th> <th>input</th> <th>output</th> </tr>
|
|
46
|
+
<tr> <td>boolean</td> <td>false</td> <td>false</td> </tr>
|
|
47
|
+
<tr> <td></td> <td>true</td> <td>true</td> </tr>
|
|
48
|
+
<tr> <td>number</td> <td>0</td> <td>false</td> </tr>
|
|
49
|
+
<tr> <td></td> <td>1</td> <td>true</td> </tr>
|
|
50
|
+
<tr> <td>string</td> <td>false</td> <td>false</td> </tr>
|
|
51
|
+
<tr> <td></td> <td>true</td> <td>true</td> </tr>
|
|
52
|
+
<tr> <td></td> <td>0</td> <td>false</td> </tr>
|
|
53
|
+
<tr> <td></td> <td>1</td> <td>true</td> </tr>
|
|
54
|
+
<tr> <td></td> <td>on</td> <td>false</td> </tr>
|
|
55
|
+
<tr> <td></td> <td>off</td> <td>true</td> </tr>
|
|
56
|
+
</table>
|
|
43
57
|
|
|
44
58
|
<h3>Input</h3>
|
|
59
|
+
|
|
60
|
+
<p>The message property to be used as payload can be defined with the <code>Property</code> property.</p>
|
|
61
|
+
|
|
62
|
+
<dl class="message-properties">
|
|
63
|
+
<dt>payload <span class="property-type"></span></dt>
|
|
64
|
+
<dd> input value.</dd>
|
|
65
|
+
</dl>
|
|
66
|
+
|
|
67
|
+
<h3>Output</h3>
|
|
68
|
+
|
|
69
|
+
<dl class="message-properties">
|
|
70
|
+
<dt>payload <span class="property-type">boolean</span></dt>
|
|
71
|
+
<dd> bool value of payload.</dd>
|
|
72
|
+
</dl>
|
|
73
|
+
|
|
74
|
+
<h3>Parameter</h3>
|
|
45
75
|
|
|
76
|
+
<dl class="message-properties">
|
|
77
|
+
<dt>Property <span class="property-type">string</span></dt>
|
|
78
|
+
<dd> defines the message property to be used as payload.</dd>
|
|
79
|
+
</dl>
|
|
80
|
+
|
|
46
81
|
</script>
|
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">
|
|
@@ -45,8 +50,39 @@
|
|
|
45
50
|
|
|
46
51
|
<script type="text/html" data-help-name="or">
|
|
47
52
|
|
|
48
|
-
<p
|
|
53
|
+
<p>Combines two or more boolean vales with the <code>or</code> operator.</p>
|
|
54
|
+
<p>The input values are converted as described in the <code>to bool</code> node.</p>
|
|
49
55
|
|
|
50
56
|
<h3>Input</h3>
|
|
57
|
+
|
|
58
|
+
<p>The different inputs are differentiated by topics.</p>
|
|
59
|
+
<p>The message property to be used as payload can be defined with the <code>Property</code> property.</p>
|
|
60
|
+
|
|
61
|
+
<dl class="message-properties">
|
|
62
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
63
|
+
<dd> name of the input channel.</dd>
|
|
64
|
+
<dt>payload <span class="property-type">boolean</span></dt>
|
|
65
|
+
<dd> input value for <code>topic</code>.</dd>
|
|
66
|
+
</dl>
|
|
67
|
+
|
|
68
|
+
<h3>Output</h3>
|
|
69
|
+
|
|
70
|
+
<dl class="message-properties">
|
|
71
|
+
<dt>payload <span class="property-type">boolean</span></dt>
|
|
72
|
+
<dd> result of <code>or</code> of all input topics.</dd>
|
|
73
|
+
<dt>count <span class="property-type">number</span></dt>
|
|
74
|
+
<dd> number of data elements.</dd>
|
|
75
|
+
</dl>
|
|
76
|
+
|
|
77
|
+
<h3>Parameter</h3>
|
|
51
78
|
|
|
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>
|
|
82
|
+
<dt>Property <span class="property-type">string</span></dt>
|
|
83
|
+
<dd> defines the message property to be used as payload.</dd>
|
|
84
|
+
<dt>min. Data <span class="property-type">number</span></dt>
|
|
85
|
+
<dd> min. amount of topics to generate an output.</dd>
|
|
86
|
+
</dl>
|
|
87
|
+
|
|
52
88
|
</script>
|
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
|
@@ -39,8 +39,29 @@
|
|
|
39
39
|
|
|
40
40
|
<script type="text/html" data-help-name="tonumber">
|
|
41
41
|
|
|
42
|
-
<p
|
|
42
|
+
<p>Converts payload to a number.</p>
|
|
43
43
|
|
|
44
44
|
<h3>Input</h3>
|
|
45
|
+
|
|
46
|
+
<p>The message property to be used as payload can be defined with the <code>Property</code> property.</p>
|
|
47
|
+
|
|
48
|
+
<dl class="message-properties">
|
|
49
|
+
<dt>payload <span class="property-type"></span></dt>
|
|
50
|
+
<dd> input value.</dd>
|
|
51
|
+
</dl>
|
|
52
|
+
|
|
53
|
+
<h3>Output</h3>
|
|
54
|
+
|
|
55
|
+
<dl class="message-properties">
|
|
56
|
+
<dt>payload <span class="property-type">number</span></dt>
|
|
57
|
+
<dd> number value of payload.</dd>
|
|
58
|
+
</dl>
|
|
59
|
+
|
|
60
|
+
<h3>Parameter</h3>
|
|
45
61
|
|
|
62
|
+
<dl class="message-properties">
|
|
63
|
+
<dt>Property <span class="property-type">string</span></dt>
|
|
64
|
+
<dd> defines the message property to be used as payload.</dd>
|
|
65
|
+
</dl>
|
|
66
|
+
|
|
46
67
|
</script>
|
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">
|
|
@@ -87,8 +92,47 @@
|
|
|
87
92
|
|
|
88
93
|
<script type="text/html" data-help-name="reduce">
|
|
89
94
|
|
|
90
|
-
<p
|
|
95
|
+
<p>Combines two or more streams of data (topics) into one single value.</p>
|
|
96
|
+
<p>Each stream can be debounced by arithmatic mean.</p>
|
|
91
97
|
|
|
92
98
|
<h3>Input</h3>
|
|
99
|
+
|
|
100
|
+
<p>The different inputs are differentiated by topics.</p>
|
|
101
|
+
<p>The message property to be used as payload can be defined with the <code>Property</code> property.</p>
|
|
102
|
+
|
|
103
|
+
<dl class="message-properties">
|
|
104
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
105
|
+
<dd> name of the input channel.</dd>
|
|
106
|
+
<dt>payload <span class="property-type">number</span></dt>
|
|
107
|
+
<dd> input value for <code>topic</code>.</dd>
|
|
108
|
+
</dl>
|
|
109
|
+
|
|
110
|
+
<h3>Output</h3>
|
|
111
|
+
|
|
112
|
+
<dl class="message-properties">
|
|
113
|
+
<dt>payload <span class="property-type">number</span></dt>
|
|
114
|
+
<dd> result of combining of all input topics.</dd>
|
|
115
|
+
<dt>count <span class="property-type">number</span></dt>
|
|
116
|
+
<dd> number of data elements.</dd>
|
|
117
|
+
</dl>
|
|
118
|
+
|
|
119
|
+
<h3>Parameter</h3>
|
|
93
120
|
|
|
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>
|
|
124
|
+
<dt>Property <span class="property-type">string</span></dt>
|
|
125
|
+
<dd> defines the message property to be used as payload.</dd>
|
|
126
|
+
<dt>min. Mean <span class="property-type">number</span></dt>
|
|
127
|
+
<dd> min. amount of values for the arithmatic mean of one topic.</dd>
|
|
128
|
+
<dt>max. Mean <span class="property-type">number</span></dt>
|
|
129
|
+
<dd> max. amount of values for the arithmatic mean of one topic.</dd>
|
|
130
|
+
<dt>min. Data <span class="property-type">number</span></dt>
|
|
131
|
+
<dd> min. amount of topics to generate an output.</dd>
|
|
132
|
+
<dt>Algorithm <span class="property-type">string</span></dt>
|
|
133
|
+
<dd> algorithm to combine the values.</dd>
|
|
134
|
+
</dl>
|
|
135
|
+
|
|
136
|
+
<h3>Algorithms</h3>
|
|
137
|
+
|
|
94
138
|
</script>
|
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mschaeffler/node-red-logic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "nodes for simple mathematical operations.",
|
|
5
5
|
"license": "LGPL-2.1",
|
|
6
6
|
"homepage": "https://github.com/m-schaeffler/node-red-my-nodes/tree/main/node-red-logic",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"node-red": {
|
|
18
18
|
"version": ">=1.3.7",
|
|
19
19
|
"nodes": {
|
|
20
|
+
"counter":"counter.js",
|
|
20
21
|
"tobool":"logic_bool.js",
|
|
21
22
|
"tonumber":"math_number.js",
|
|
22
23
|
"or":"logic_or.js",
|
|
23
24
|
"and":"logic_and.js",
|
|
24
|
-
"counter":"counter.js",
|
|
25
25
|
"reduce":"math_reduce.js"
|
|
26
26
|
}
|
|
27
27
|
},
|