@mschaeffler/node-red-logic 0.4.2 → 0.4.5

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Nodes to perform boolean and arithmetic operations on input signals.
4
4
 
5
- ![image of example flow](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/logic.png)
5
+ ![image of nodes](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/logic.png)
6
6
 
7
7
  ## Install
8
8
 
@@ -10,17 +10,9 @@ Nodes to perform boolean and arithmetic operations on input signals.
10
10
  $ npm install @mschaeffler/node-red-logic
11
11
  ```
12
12
 
13
- ## Usage
13
+ ## Boolean Nodes
14
14
 
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.|
15
+ ![image of example flow](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/bool.png)
24
16
 
25
17
  ### to bool
26
18
 
@@ -124,6 +116,20 @@ The message property to be used as payload can be defined with the `Property` pr
124
116
  |Property| string | defines the message property to be used as payload.|
125
117
  |min. Data|number|min. amount of topics to generate an output.|
126
118
 
119
+ ## Integer Nodes
120
+
121
+ ![image of example flow](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/math.png)
122
+
123
+ ### counter
124
+
125
+ A node that just count the messages.
126
+
127
+ #### Output
128
+
129
+ |msg. | type | description |
130
+ |:-------|:-------|:----------------------------------|
131
+ |count | number | number of messages.|
132
+
127
133
  ### to number
128
134
 
129
135
  Converts payload to a number.
@@ -186,14 +192,25 @@ The message property to be used as payload can be defined with the `Property` pr
186
192
 
187
193
  #### Algorithms
188
194
 
195
+ |algorithm|description|
196
+ |:--------|:----------|
197
+ |add |ads up the `topic` channels|
198
+ |mean |averages the `topic` channels|
199
+ |prod |multiplies the `topic` channels|
200
+ |min |gets the minimal value of the `topic` channels|
201
+ |max |gets the maximal value of the `topic` channels|
202
+
203
+ ## Edge Nodes
189
204
 
190
- ## fallingEdge
205
+ ![image of example flow](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/edge.png)
206
+
207
+ ### fallingEdge
191
208
 
192
209
  Message is only forwarded, if the payload falls below a threshold value.
193
210
 
194
211
  Each `topic` is treated seperatly.
195
212
 
196
- ### Input
213
+ #### Input
197
214
 
198
215
  The message property to be used as payload can be defined with the `Property` property.
199
216
 
@@ -202,11 +219,11 @@ The message property to be used as payload can be defined with the `Property` pr
202
219
  |topic | string | name of the input channel. |
203
220
  |payload | number | input value for `topic`. |
204
221
 
205
- ### Output
222
+ #### Output
206
223
 
207
224
  Trigger message, in case a falling edge is detected.
208
225
 
209
- ### Parameter
226
+ #### Parameters
210
227
 
211
228
  |config| type | description |
212
229
  |:-----|:-------|:----------------------------------|
@@ -214,13 +231,13 @@ Trigger message, in case a falling edge is detected.
214
231
  |Threshold|number|threshold value for the edge detection.|
215
232
  |Status|boolean|shows the actual value as a node status.|
216
233
 
217
- ## raisingEdge
234
+ ### raisingEdge
218
235
 
219
236
  Message is only forwarded, if the payload raises above a threshold value.
220
237
 
221
238
  Each `topic` is treated seperatly.
222
239
 
223
- ### Input
240
+ #### Input
224
241
 
225
242
  The message property to be used as payload can be defined with the `Property` property.
226
243
 
@@ -229,11 +246,11 @@ The message property to be used as payload can be defined with the `Property` pr
229
246
  |topic | string | name of the input channel. |
230
247
  |payload | number | input value for `topic`. |
231
248
 
232
- ### Output
249
+ #### Output
233
250
 
234
251
  Trigger message, in case a raising edge is detected.
235
252
 
236
- ### Parameter
253
+ #### Parameters
237
254
 
238
255
  |config| type | description |
239
256
  |:-----|:-------|:----------------------------------|
@@ -241,13 +258,13 @@ Trigger message, in case a raising edge is detected.
241
258
  |Threshold|number|threshold value for the edge detection.|
242
259
  |Status|boolean|shows the actual value as a node status.|
243
260
 
244
- ## hysteresis
261
+ ### hysteresis
245
262
 
246
263
  Message is only forwarded, if the payload raises above an upper limit or falls below a lower limit.
247
264
 
248
265
  Each `topic` is treated seperatly.
249
266
 
250
- ### Input
267
+ #### Input
251
268
 
252
269
  The message property to be used as payload can be defined with the `Property` property.
253
270
 
@@ -256,11 +273,11 @@ The message property to be used as payload can be defined with the `Property` pr
256
273
  |topic | string | name of the input channel. |
257
274
  |payload | number | input value for `topic`. |
258
275
 
259
- ### Output
276
+ #### Output
260
277
 
261
278
  Trigger message, in case an edge is detected.
262
279
 
263
- ### Parameter
280
+ #### Parameters
264
281
 
265
282
  |config| type | description |
266
283
  |:-----|:-------|:----------------------------------|
@@ -270,9 +287,13 @@ Trigger message, in case an edge is detected.
270
287
  |1st message|string|initial behaviour (None, Rising, Falling, Any).|
271
288
  |Status|boolean|shows the actual value as a node status.|
272
289
 
273
- ## Example Flow
290
+ ## Example Flows
291
+
292
+ [boolean nodes](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/bool.json)
293
+
294
+ [integer nodes](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/math.json)
274
295
 
275
- [example flow](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/logic.json)
296
+ [edge nodes](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/edge.json)
276
297
 
277
298
  ## Author
278
299
 
@@ -0,0 +1,289 @@
1
+ [
2
+ {
3
+ "id": "874e3c59e7510080",
4
+ "type": "tab",
5
+ "label": "Flow 2",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "3638e932e6cd704e",
12
+ "type": "tobool",
13
+ "z": "874e3c59e7510080",
14
+ "name": "",
15
+ "property": "payload",
16
+ "showState": false,
17
+ "x": 310,
18
+ "y": 120,
19
+ "wires": [
20
+ [
21
+ "59187eb10a59d119"
22
+ ]
23
+ ]
24
+ },
25
+ {
26
+ "id": "7d8ce3c91fad2f4c",
27
+ "type": "or",
28
+ "z": "874e3c59e7510080",
29
+ "name": "",
30
+ "topic": "",
31
+ "property": "payload",
32
+ "minData": "1",
33
+ "x": 310,
34
+ "y": 200,
35
+ "wires": [
36
+ [
37
+ "c9d4c13317184fd5"
38
+ ]
39
+ ]
40
+ },
41
+ {
42
+ "id": "59a5371d04a4ad46",
43
+ "type": "and",
44
+ "z": "874e3c59e7510080",
45
+ "name": "",
46
+ "topic": "",
47
+ "property": "payload",
48
+ "minData": "1",
49
+ "x": 310,
50
+ "y": 280,
51
+ "wires": [
52
+ [
53
+ "1b5361bc5d9fa406"
54
+ ]
55
+ ]
56
+ },
57
+ {
58
+ "id": "59187eb10a59d119",
59
+ "type": "debug",
60
+ "z": "874e3c59e7510080",
61
+ "name": "",
62
+ "active": true,
63
+ "tosidebar": true,
64
+ "console": false,
65
+ "tostatus": true,
66
+ "complete": "payload",
67
+ "targetType": "msg",
68
+ "statusVal": "payload",
69
+ "statusType": "auto",
70
+ "x": 490,
71
+ "y": 120,
72
+ "wires": []
73
+ },
74
+ {
75
+ "id": "71b5ad607d2a4667",
76
+ "type": "inject",
77
+ "z": "874e3c59e7510080",
78
+ "name": "reset",
79
+ "props": [
80
+ {
81
+ "p": "reset",
82
+ "v": "true",
83
+ "vt": "bool"
84
+ },
85
+ {
86
+ "p": "topic",
87
+ "vt": "str"
88
+ }
89
+ ],
90
+ "repeat": "",
91
+ "crontab": "",
92
+ "once": false,
93
+ "onceDelay": 0.1,
94
+ "topic": "",
95
+ "x": 150,
96
+ "y": 320,
97
+ "wires": [
98
+ [
99
+ "59a5371d04a4ad46",
100
+ "7d8ce3c91fad2f4c"
101
+ ]
102
+ ]
103
+ },
104
+ {
105
+ "id": "308f4479c5fe35b5",
106
+ "type": "inject",
107
+ "z": "874e3c59e7510080",
108
+ "name": "",
109
+ "props": [
110
+ {
111
+ "p": "topic",
112
+ "vt": "str"
113
+ },
114
+ {
115
+ "p": "payload"
116
+ }
117
+ ],
118
+ "repeat": "",
119
+ "crontab": "",
120
+ "once": false,
121
+ "onceDelay": 0.1,
122
+ "topic": "A",
123
+ "payload": "invalid",
124
+ "payloadType": "str",
125
+ "x": 140,
126
+ "y": 80,
127
+ "wires": [
128
+ [
129
+ "3638e932e6cd704e"
130
+ ]
131
+ ]
132
+ },
133
+ {
134
+ "id": "93b191eedfb167ba",
135
+ "type": "inject",
136
+ "z": "874e3c59e7510080",
137
+ "name": "",
138
+ "props": [
139
+ {
140
+ "p": "topic",
141
+ "vt": "str"
142
+ },
143
+ {
144
+ "p": "payload"
145
+ }
146
+ ],
147
+ "repeat": "",
148
+ "crontab": "",
149
+ "once": false,
150
+ "onceDelay": 0.1,
151
+ "topic": "A",
152
+ "payload": "on",
153
+ "payloadType": "str",
154
+ "x": 150,
155
+ "y": 120,
156
+ "wires": [
157
+ [
158
+ "3638e932e6cd704e",
159
+ "7d8ce3c91fad2f4c",
160
+ "59a5371d04a4ad46"
161
+ ]
162
+ ]
163
+ },
164
+ {
165
+ "id": "bc22906368cc9ebd",
166
+ "type": "inject",
167
+ "z": "874e3c59e7510080",
168
+ "name": "",
169
+ "props": [
170
+ {
171
+ "p": "topic",
172
+ "vt": "str"
173
+ },
174
+ {
175
+ "p": "payload"
176
+ }
177
+ ],
178
+ "repeat": "",
179
+ "crontab": "",
180
+ "once": false,
181
+ "onceDelay": 0.1,
182
+ "topic": "A",
183
+ "payload": "off",
184
+ "payloadType": "str",
185
+ "x": 150,
186
+ "y": 160,
187
+ "wires": [
188
+ [
189
+ "3638e932e6cd704e",
190
+ "7d8ce3c91fad2f4c",
191
+ "59a5371d04a4ad46"
192
+ ]
193
+ ]
194
+ },
195
+ {
196
+ "id": "c9d4c13317184fd5",
197
+ "type": "debug",
198
+ "z": "874e3c59e7510080",
199
+ "name": "",
200
+ "active": true,
201
+ "tosidebar": true,
202
+ "console": false,
203
+ "tostatus": true,
204
+ "complete": "payload",
205
+ "targetType": "msg",
206
+ "statusVal": "payload",
207
+ "statusType": "auto",
208
+ "x": 490,
209
+ "y": 200,
210
+ "wires": []
211
+ },
212
+ {
213
+ "id": "1b5361bc5d9fa406",
214
+ "type": "debug",
215
+ "z": "874e3c59e7510080",
216
+ "name": "",
217
+ "active": true,
218
+ "tosidebar": true,
219
+ "console": false,
220
+ "tostatus": true,
221
+ "complete": "payload",
222
+ "targetType": "msg",
223
+ "statusVal": "payload",
224
+ "statusType": "auto",
225
+ "x": 490,
226
+ "y": 280,
227
+ "wires": []
228
+ },
229
+ {
230
+ "id": "49a9351d2c03c622",
231
+ "type": "inject",
232
+ "z": "874e3c59e7510080",
233
+ "name": "",
234
+ "props": [
235
+ {
236
+ "p": "topic",
237
+ "vt": "str"
238
+ },
239
+ {
240
+ "p": "payload"
241
+ }
242
+ ],
243
+ "repeat": "",
244
+ "crontab": "",
245
+ "once": false,
246
+ "onceDelay": 0.1,
247
+ "topic": "B",
248
+ "payload": "0",
249
+ "payloadType": "num",
250
+ "x": 150,
251
+ "y": 260,
252
+ "wires": [
253
+ [
254
+ "59a5371d04a4ad46",
255
+ "7d8ce3c91fad2f4c"
256
+ ]
257
+ ]
258
+ },
259
+ {
260
+ "id": "2b32172c0bd9fa07",
261
+ "type": "inject",
262
+ "z": "874e3c59e7510080",
263
+ "name": "",
264
+ "props": [
265
+ {
266
+ "p": "topic",
267
+ "vt": "str"
268
+ },
269
+ {
270
+ "p": "payload"
271
+ }
272
+ ],
273
+ "repeat": "",
274
+ "crontab": "",
275
+ "once": false,
276
+ "onceDelay": 0.1,
277
+ "topic": "B",
278
+ "payload": "5",
279
+ "payloadType": "num",
280
+ "x": 150,
281
+ "y": 220,
282
+ "wires": [
283
+ [
284
+ "7d8ce3c91fad2f4c",
285
+ "59a5371d04a4ad46"
286
+ ]
287
+ ]
288
+ }
289
+ ]
Binary file
@@ -0,0 +1,323 @@
1
+ [
2
+ {
3
+ "id": "4970749d37068d6b",
4
+ "type": "tab",
5
+ "label": "Flow 1",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "52d9bc78e16a9148",
12
+ "type": "fallingEdge",
13
+ "z": "4970749d37068d6b",
14
+ "name": "",
15
+ "property": "payload",
16
+ "threshold": "0.5",
17
+ "showState": true,
18
+ "x": 350,
19
+ "y": 180,
20
+ "wires": [
21
+ [
22
+ "77726eaa088e280b"
23
+ ]
24
+ ]
25
+ },
26
+ {
27
+ "id": "77726eaa088e280b",
28
+ "type": "debug",
29
+ "z": "4970749d37068d6b",
30
+ "name": "",
31
+ "active": false,
32
+ "tosidebar": true,
33
+ "console": false,
34
+ "tostatus": true,
35
+ "complete": "edge",
36
+ "targetType": "msg",
37
+ "statusVal": "payload",
38
+ "statusType": "auto",
39
+ "x": 520,
40
+ "y": 180,
41
+ "wires": []
42
+ },
43
+ {
44
+ "id": "ac8e06cc38b44b25",
45
+ "type": "inject",
46
+ "z": "4970749d37068d6b",
47
+ "name": "",
48
+ "props": [
49
+ {
50
+ "p": "topic",
51
+ "vt": "str"
52
+ },
53
+ {
54
+ "p": "payload"
55
+ }
56
+ ],
57
+ "repeat": "",
58
+ "crontab": "",
59
+ "once": false,
60
+ "onceDelay": 0.1,
61
+ "topic": "A",
62
+ "payload": "invalid",
63
+ "payloadType": "str",
64
+ "x": 140,
65
+ "y": 140,
66
+ "wires": [
67
+ [
68
+ "a24056951606f51c",
69
+ "52d9bc78e16a9148"
70
+ ]
71
+ ]
72
+ },
73
+ {
74
+ "id": "c3c3954adcb27b9f",
75
+ "type": "inject",
76
+ "z": "4970749d37068d6b",
77
+ "name": "",
78
+ "props": [
79
+ {
80
+ "p": "topic",
81
+ "vt": "str"
82
+ },
83
+ {
84
+ "p": "payload"
85
+ }
86
+ ],
87
+ "repeat": "",
88
+ "crontab": "",
89
+ "once": false,
90
+ "onceDelay": 0.1,
91
+ "topic": "B",
92
+ "payload": "5",
93
+ "payloadType": "num",
94
+ "x": 150,
95
+ "y": 280,
96
+ "wires": [
97
+ [
98
+ "a24056951606f51c",
99
+ "52d9bc78e16a9148",
100
+ "6c0fc0087d21517c"
101
+ ]
102
+ ]
103
+ },
104
+ {
105
+ "id": "f968bad2f0afca41",
106
+ "type": "inject",
107
+ "z": "4970749d37068d6b",
108
+ "name": "",
109
+ "props": [
110
+ {
111
+ "p": "topic",
112
+ "vt": "str"
113
+ },
114
+ {
115
+ "p": "payload"
116
+ }
117
+ ],
118
+ "repeat": "",
119
+ "crontab": "",
120
+ "once": false,
121
+ "onceDelay": 0.1,
122
+ "topic": "A",
123
+ "payload": "true",
124
+ "payloadType": "bool",
125
+ "x": 150,
126
+ "y": 180,
127
+ "wires": [
128
+ [
129
+ "a24056951606f51c",
130
+ "52d9bc78e16a9148"
131
+ ]
132
+ ]
133
+ },
134
+ {
135
+ "id": "ad9fbb99931a81c4",
136
+ "type": "inject",
137
+ "z": "4970749d37068d6b",
138
+ "name": "",
139
+ "props": [
140
+ {
141
+ "p": "topic",
142
+ "vt": "str"
143
+ },
144
+ {
145
+ "p": "payload"
146
+ }
147
+ ],
148
+ "repeat": "",
149
+ "crontab": "",
150
+ "once": false,
151
+ "onceDelay": 0.1,
152
+ "topic": "A",
153
+ "payload": "false",
154
+ "payloadType": "bool",
155
+ "x": 150,
156
+ "y": 220,
157
+ "wires": [
158
+ [
159
+ "a24056951606f51c",
160
+ "52d9bc78e16a9148"
161
+ ]
162
+ ]
163
+ },
164
+ {
165
+ "id": "f1ab2e7739f49adf",
166
+ "type": "inject",
167
+ "z": "4970749d37068d6b",
168
+ "name": "",
169
+ "props": [
170
+ {
171
+ "p": "topic",
172
+ "vt": "str"
173
+ },
174
+ {
175
+ "p": "payload"
176
+ }
177
+ ],
178
+ "repeat": "",
179
+ "crontab": "",
180
+ "once": false,
181
+ "onceDelay": 0.1,
182
+ "topic": "B",
183
+ "payload": "-5",
184
+ "payloadType": "num",
185
+ "x": 150,
186
+ "y": 320,
187
+ "wires": [
188
+ [
189
+ "a24056951606f51c",
190
+ "52d9bc78e16a9148",
191
+ "6c0fc0087d21517c"
192
+ ]
193
+ ]
194
+ },
195
+ {
196
+ "id": "a24056951606f51c",
197
+ "type": "raisingEdge",
198
+ "z": "4970749d37068d6b",
199
+ "name": "",
200
+ "property": "payload",
201
+ "threshold": "0.5",
202
+ "showState": true,
203
+ "x": 350,
204
+ "y": 240,
205
+ "wires": [
206
+ [
207
+ "fe404d9f9c32f265"
208
+ ]
209
+ ]
210
+ },
211
+ {
212
+ "id": "fe655bd06e553598",
213
+ "type": "inject",
214
+ "z": "4970749d37068d6b",
215
+ "name": "reset",
216
+ "props": [
217
+ {
218
+ "p": "reset",
219
+ "v": "true",
220
+ "vt": "bool"
221
+ },
222
+ {
223
+ "p": "topic",
224
+ "vt": "str"
225
+ }
226
+ ],
227
+ "repeat": "",
228
+ "crontab": "",
229
+ "once": false,
230
+ "onceDelay": 0.1,
231
+ "topic": "",
232
+ "x": 150,
233
+ "y": 80,
234
+ "wires": [
235
+ [
236
+ "a24056951606f51c",
237
+ "52d9bc78e16a9148",
238
+ "6c0fc0087d21517c"
239
+ ]
240
+ ]
241
+ },
242
+ {
243
+ "id": "fe404d9f9c32f265",
244
+ "type": "debug",
245
+ "z": "4970749d37068d6b",
246
+ "name": "",
247
+ "active": false,
248
+ "tosidebar": true,
249
+ "console": false,
250
+ "tostatus": true,
251
+ "complete": "edge",
252
+ "targetType": "msg",
253
+ "statusVal": "",
254
+ "statusType": "auto",
255
+ "x": 520,
256
+ "y": 240,
257
+ "wires": []
258
+ },
259
+ {
260
+ "id": "50bd9f615e8929df",
261
+ "type": "debug",
262
+ "z": "4970749d37068d6b",
263
+ "name": "",
264
+ "active": true,
265
+ "tosidebar": true,
266
+ "console": false,
267
+ "tostatus": true,
268
+ "complete": "edge",
269
+ "targetType": "msg",
270
+ "statusVal": "payload",
271
+ "statusType": "auto",
272
+ "x": 520,
273
+ "y": 320,
274
+ "wires": []
275
+ },
276
+ {
277
+ "id": "6c0fc0087d21517c",
278
+ "type": "hysteresisEdge",
279
+ "z": "4970749d37068d6b",
280
+ "name": "",
281
+ "property": "payload",
282
+ "threshold_raise": "1",
283
+ "threshold_fall": "-1",
284
+ "initial": "falling",
285
+ "showState": true,
286
+ "x": 360,
287
+ "y": 320,
288
+ "wires": [
289
+ [
290
+ "50bd9f615e8929df"
291
+ ]
292
+ ]
293
+ },
294
+ {
295
+ "id": "23a7bae9cad0dd16",
296
+ "type": "inject",
297
+ "z": "4970749d37068d6b",
298
+ "name": "",
299
+ "props": [
300
+ {
301
+ "p": "topic",
302
+ "vt": "str"
303
+ },
304
+ {
305
+ "p": "payload"
306
+ }
307
+ ],
308
+ "repeat": "",
309
+ "crontab": "",
310
+ "once": false,
311
+ "onceDelay": 0.1,
312
+ "topic": "B",
313
+ "payload": "0",
314
+ "payloadType": "num",
315
+ "x": 150,
316
+ "y": 360,
317
+ "wires": [
318
+ [
319
+ "6c0fc0087d21517c"
320
+ ]
321
+ ]
322
+ }
323
+ ]
Binary file
Binary file
@@ -0,0 +1,328 @@
1
+ [
2
+ {
3
+ "id": "e7a1598e6f6358b9",
4
+ "type": "tab",
5
+ "label": "Flow 3",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "b387e894bd2d43ef",
12
+ "type": "reduce",
13
+ "z": "e7a1598e6f6358b9",
14
+ "name": "",
15
+ "topic": "",
16
+ "property": "payload",
17
+ "minMean": "1",
18
+ "maxMean": "1",
19
+ "minData": "2",
20
+ "algo": "add",
21
+ "x": 350,
22
+ "y": 260,
23
+ "wires": [
24
+ [
25
+ "ae068d25a90dae25"
26
+ ]
27
+ ]
28
+ },
29
+ {
30
+ "id": "b3daecdca91d5857",
31
+ "type": "counter",
32
+ "z": "e7a1598e6f6358b9",
33
+ "name": "",
34
+ "x": 360,
35
+ "y": 120,
36
+ "wires": [
37
+ [
38
+ "8d3bba1d6e5cb22f"
39
+ ]
40
+ ]
41
+ },
42
+ {
43
+ "id": "244e769e05d8b030",
44
+ "type": "tonumber",
45
+ "z": "e7a1598e6f6358b9",
46
+ "name": "",
47
+ "property": "payload",
48
+ "showState": true,
49
+ "x": 360,
50
+ "y": 200,
51
+ "wires": [
52
+ [
53
+ "5a783605c2561d00"
54
+ ]
55
+ ]
56
+ },
57
+ {
58
+ "id": "8d3bba1d6e5cb22f",
59
+ "type": "debug",
60
+ "z": "e7a1598e6f6358b9",
61
+ "name": "",
62
+ "active": true,
63
+ "tosidebar": true,
64
+ "console": false,
65
+ "tostatus": true,
66
+ "complete": "payload",
67
+ "targetType": "msg",
68
+ "statusVal": "payload",
69
+ "statusType": "auto",
70
+ "x": 550,
71
+ "y": 120,
72
+ "wires": []
73
+ },
74
+ {
75
+ "id": "5a783605c2561d00",
76
+ "type": "debug",
77
+ "z": "e7a1598e6f6358b9",
78
+ "name": "",
79
+ "active": true,
80
+ "tosidebar": true,
81
+ "console": false,
82
+ "tostatus": true,
83
+ "complete": "payload",
84
+ "targetType": "msg",
85
+ "statusVal": "payload",
86
+ "statusType": "auto",
87
+ "x": 550,
88
+ "y": 200,
89
+ "wires": []
90
+ },
91
+ {
92
+ "id": "ae068d25a90dae25",
93
+ "type": "debug",
94
+ "z": "e7a1598e6f6358b9",
95
+ "name": "",
96
+ "active": true,
97
+ "tosidebar": true,
98
+ "console": false,
99
+ "tostatus": true,
100
+ "complete": "payload",
101
+ "targetType": "msg",
102
+ "statusVal": "payload",
103
+ "statusType": "auto",
104
+ "x": 550,
105
+ "y": 260,
106
+ "wires": []
107
+ },
108
+ {
109
+ "id": "b7f75f4a22ecd0ee",
110
+ "type": "inject",
111
+ "z": "e7a1598e6f6358b9",
112
+ "name": "",
113
+ "props": [
114
+ {
115
+ "p": "topic",
116
+ "vt": "str"
117
+ },
118
+ {
119
+ "p": "payload"
120
+ }
121
+ ],
122
+ "repeat": "",
123
+ "crontab": "",
124
+ "once": false,
125
+ "onceDelay": 0.1,
126
+ "topic": "A",
127
+ "payload": "5",
128
+ "payloadType": "str",
129
+ "x": 190,
130
+ "y": 120,
131
+ "wires": [
132
+ [
133
+ "b3daecdca91d5857",
134
+ "244e769e05d8b030",
135
+ "b387e894bd2d43ef",
136
+ "3c37bb4e8785f015"
137
+ ]
138
+ ]
139
+ },
140
+ {
141
+ "id": "19ad2b1afbfee8cf",
142
+ "type": "inject",
143
+ "z": "e7a1598e6f6358b9",
144
+ "name": "",
145
+ "props": [
146
+ {
147
+ "p": "topic",
148
+ "vt": "str"
149
+ },
150
+ {
151
+ "p": "payload"
152
+ }
153
+ ],
154
+ "repeat": "",
155
+ "crontab": "",
156
+ "once": false,
157
+ "onceDelay": 0.1,
158
+ "topic": "A",
159
+ "payload": "-5",
160
+ "payloadType": "num",
161
+ "x": 190,
162
+ "y": 200,
163
+ "wires": [
164
+ [
165
+ "244e769e05d8b030",
166
+ "b387e894bd2d43ef",
167
+ "3c37bb4e8785f015"
168
+ ]
169
+ ]
170
+ },
171
+ {
172
+ "id": "ac9dd1323d3d60ae",
173
+ "type": "inject",
174
+ "z": "e7a1598e6f6358b9",
175
+ "name": "",
176
+ "props": [
177
+ {
178
+ "p": "topic",
179
+ "vt": "str"
180
+ },
181
+ {
182
+ "p": "payload"
183
+ }
184
+ ],
185
+ "repeat": "",
186
+ "crontab": "",
187
+ "once": false,
188
+ "onceDelay": 0.1,
189
+ "topic": "A",
190
+ "payload": "0",
191
+ "payloadType": "str",
192
+ "x": 190,
193
+ "y": 160,
194
+ "wires": [
195
+ [
196
+ "244e769e05d8b030",
197
+ "b387e894bd2d43ef",
198
+ "3c37bb4e8785f015"
199
+ ]
200
+ ]
201
+ },
202
+ {
203
+ "id": "144150b47c7b7f5e",
204
+ "type": "inject",
205
+ "z": "e7a1598e6f6358b9",
206
+ "name": "",
207
+ "props": [
208
+ {
209
+ "p": "topic",
210
+ "vt": "str"
211
+ },
212
+ {
213
+ "p": "payload"
214
+ }
215
+ ],
216
+ "repeat": "",
217
+ "crontab": "",
218
+ "once": false,
219
+ "onceDelay": 0.1,
220
+ "topic": "B",
221
+ "payload": "2",
222
+ "payloadType": "num",
223
+ "x": 190,
224
+ "y": 260,
225
+ "wires": [
226
+ [
227
+ "b387e894bd2d43ef",
228
+ "3c37bb4e8785f015"
229
+ ]
230
+ ]
231
+ },
232
+ {
233
+ "id": "424f044c65f13d95",
234
+ "type": "inject",
235
+ "z": "e7a1598e6f6358b9",
236
+ "name": "",
237
+ "props": [
238
+ {
239
+ "p": "topic",
240
+ "vt": "str"
241
+ },
242
+ {
243
+ "p": "payload"
244
+ }
245
+ ],
246
+ "repeat": "",
247
+ "crontab": "",
248
+ "once": false,
249
+ "onceDelay": 0.1,
250
+ "topic": "B",
251
+ "payload": "-2",
252
+ "payloadType": "num",
253
+ "x": 190,
254
+ "y": 340,
255
+ "wires": [
256
+ [
257
+ "b387e894bd2d43ef",
258
+ "3c37bb4e8785f015"
259
+ ]
260
+ ]
261
+ },
262
+ {
263
+ "id": "5fa26abfa096ab15",
264
+ "type": "inject",
265
+ "z": "e7a1598e6f6358b9",
266
+ "name": "",
267
+ "props": [
268
+ {
269
+ "p": "topic",
270
+ "vt": "str"
271
+ },
272
+ {
273
+ "p": "payload"
274
+ }
275
+ ],
276
+ "repeat": "",
277
+ "crontab": "",
278
+ "once": false,
279
+ "onceDelay": 0.1,
280
+ "topic": "B",
281
+ "payload": "0",
282
+ "payloadType": "num",
283
+ "x": 190,
284
+ "y": 300,
285
+ "wires": [
286
+ [
287
+ "b387e894bd2d43ef",
288
+ "3c37bb4e8785f015"
289
+ ]
290
+ ]
291
+ },
292
+ {
293
+ "id": "3c37bb4e8785f015",
294
+ "type": "reduce",
295
+ "z": "e7a1598e6f6358b9",
296
+ "name": "",
297
+ "topic": "",
298
+ "property": "payload",
299
+ "minMean": "1",
300
+ "maxMean": "3",
301
+ "minData": "2",
302
+ "algo": "mean",
303
+ "x": 350,
304
+ "y": 340,
305
+ "wires": [
306
+ [
307
+ "e48c5acab52f93e3"
308
+ ]
309
+ ]
310
+ },
311
+ {
312
+ "id": "e48c5acab52f93e3",
313
+ "type": "debug",
314
+ "z": "e7a1598e6f6358b9",
315
+ "name": "",
316
+ "active": true,
317
+ "tosidebar": true,
318
+ "console": false,
319
+ "tostatus": true,
320
+ "complete": "payload",
321
+ "targetType": "msg",
322
+ "statusVal": "payload",
323
+ "statusType": "auto",
324
+ "x": 550,
325
+ "y": 340,
326
+ "wires": []
327
+ }
328
+ ]
Binary file
package/math_falling.html CHANGED
@@ -12,7 +12,7 @@
12
12
  outputs:1,
13
13
  icon: "falling-edge.png",
14
14
  label: function() {
15
- return this.name||"falling";
15
+ return this.name||"falling edge";
16
16
  },
17
17
  paletteLabel: "falling edge",
18
18
  inputLabels: 'input',
package/math_falling.js CHANGED
@@ -27,6 +27,7 @@ module.exports = function(RED) {
27
27
  if( msg.payload < this.threshold && this.threshold <= last )
28
28
  {
29
29
  status.fill = "green";
30
+ msg.edge = "falling";
30
31
  send( msg );
31
32
  }
32
33
  data[msg.topic] = msg.payload;
@@ -12,7 +12,6 @@ module.exports = function(RED) {
12
12
  this.showState = config.showState;
13
13
 
14
14
  node.on('input', function(msg,send,done) {
15
-
16
15
  if( msg.reset || msg.topic==="init" )
17
16
  {
18
17
  context.set( "data", {} );
@@ -50,11 +49,11 @@ module.exports = function(RED) {
50
49
  else
51
50
  {
52
51
  data[msg.topic] = {};
53
- if( ( this.initial == 'any' || this.initial == 'rising' ) && msg.payload > this.threshold_raise )
52
+ if( ['any','rising'].includes(this.initial) && msg.payload > this.threshold_raise )
54
53
  {
55
54
  sendMsg( 'rising' );
56
55
  }
57
- else if( ( this.initial == 'any' || this.initial == 'falling' ) && msg.payload < this.threshold_fall )
56
+ else if( ['any','falling'].includes(this.initial) && msg.payload < this.threshold_fall )
58
57
  {
59
58
  sendMsg( 'falling' );
60
59
  }
package/math_raising.html CHANGED
@@ -12,7 +12,7 @@
12
12
  outputs:1,
13
13
  icon: "raising-edge.png",
14
14
  label: function() {
15
- return this.name||"raising";
15
+ return this.name||"raising edge";
16
16
  },
17
17
  paletteLabel: "raising edge",
18
18
  inputLabels: 'input',
package/math_raising.js CHANGED
@@ -27,6 +27,7 @@ module.exports = function(RED) {
27
27
  if( msg.payload > this.threshold && this.threshold >= last )
28
28
  {
29
29
  status.fill = "green";
30
+ msg.edge = "raising";
30
31
  send( msg );
31
32
  }
32
33
  data[msg.topic] = msg.payload;
package/math_reduce.html CHANGED
@@ -142,4 +142,14 @@
142
142
 
143
143
  <h3>Algorithms</h3>
144
144
 
145
+ <dl class="message-properties">
146
+ <table>
147
+ <tr><th>algorithm</th><th>description</th></tr>
148
+ <tr><td>add</td><td>ads up the <code>topic</code> channels</td></tr>
149
+ <tr><td>mean</td><td>averages the <code>topic</code> channels</td></tr>
150
+ <tr><td>prod</td><td>multiplies the <code>topic</code> channels</td></tr>
151
+ <tr><td>min</td><td>gets the minimal value of the <code>topic</code> channels</td></tr>
152
+ <tr><td>max</td><td>gets the maximal value of the <code>topic</code> channels</td></tr>
153
+ </table>
154
+
145
155
  </script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "0.4.2",
4
- "description": "nodes for simple mathematical operations.",
3
+ "version": "0.4.5",
4
+ "description": "nodes for simple operations.",
5
5
  "license": "LGPL-2.1",
6
6
  "homepage": "https://github.com/m-schaeffler/node-red-my-nodes/tree/main/node-red-logic",
7
7
  "repository": {
@@ -19,13 +19,13 @@
19
19
  "nodes": {
20
20
  "counter":"counter.js",
21
21
  "tobool":"logic_bool.js",
22
- "tonumber":"math_number.js",
23
22
  "or":"logic_or.js",
24
23
  "and":"logic_and.js",
24
+ "tonumber":"math_number.js",
25
+ "reduce":"math_reduce.js",
25
26
  "fallingEdge":"math_falling.js",
26
27
  "raisingEdge":"math_raising.js",
27
- "hysteresisEdge":"math_hysteresis.js",
28
- "reduce":"math_reduce.js"
28
+ "hysteresisEdge":"math_hysteresis.js"
29
29
  }
30
30
  },
31
31
  "author": {
@@ -1 +0,0 @@
1
- []