@mschaeffler/node-red-logic 0.3.0 → 0.4.4

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,118 @@ The message property to be used as payload can be defined with the `Property` pr
186
192
 
187
193
  #### Algorithms
188
194
 
189
- ## Example Flow
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
204
+
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
208
+
209
+ Message is only forwarded, if the payload falls below a threshold value.
210
+
211
+ Each `topic` is treated seperatly.
212
+
213
+ #### Input
214
+
215
+ The message property to be used as payload can be defined with the `Property` property.
216
+
217
+ |msg. | type | description |
218
+ |:-------|:-------|:----------------------------------|
219
+ |topic | string | name of the input channel. |
220
+ |payload | number | input value for `topic`. |
221
+
222
+ #### Output
223
+
224
+ Trigger message, in case a falling edge is detected.
225
+
226
+ #### Parameters
227
+
228
+ |config| type | description |
229
+ |:-----|:-------|:----------------------------------|
230
+ |Property| string | defines the message property to be used as payload.|
231
+ |Threshold|number|threshold value for the edge detection.|
232
+ |Status|boolean|shows the actual value as a node status.|
233
+
234
+ ### raisingEdge
235
+
236
+ Message is only forwarded, if the payload raises above a threshold value.
190
237
 
191
- [example flow](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/logic.json)
238
+ Each `topic` is treated seperatly.
239
+
240
+ #### Input
241
+
242
+ The message property to be used as payload can be defined with the `Property` property.
243
+
244
+ |msg. | type | description |
245
+ |:-------|:-------|:----------------------------------|
246
+ |topic | string | name of the input channel. |
247
+ |payload | number | input value for `topic`. |
248
+
249
+ #### Output
250
+
251
+ Trigger message, in case a raising edge is detected.
252
+
253
+ #### Parameters
254
+
255
+ |config| type | description |
256
+ |:-----|:-------|:----------------------------------|
257
+ |Property| string | defines the message property to be used as payload.|
258
+ |Threshold|number|threshold value for the edge detection.|
259
+ |Status|boolean|shows the actual value as a node status.|
260
+
261
+ ### hysteresis
262
+
263
+ Message is only forwarded, if the payload raises above an upper limit or falls below a lower limit.
264
+
265
+ Each `topic` is treated seperatly.
266
+
267
+ #### Input
268
+
269
+ The message property to be used as payload can be defined with the `Property` property.
270
+
271
+ |msg. | type | description |
272
+ |:-------|:-------|:----------------------------------|
273
+ |topic | string | name of the input channel. |
274
+ |payload | number | input value for `topic`. |
275
+
276
+ #### Output
277
+
278
+ Trigger message, in case an edge is detected.
279
+
280
+ #### Parameters
281
+
282
+ |config| type | description |
283
+ |:-----|:-------|:----------------------------------|
284
+ |Property| string | defines the message property to be used as payload.|
285
+ |up Threshold|number|threshold value for the raising edge detection.|
286
+ |d(ow)n Threshold|number|threshold value for the falling edge detection.|
287
+ |1st message|string|initial behaviour (None, Rising, Falling, Any).|
288
+ |Status|boolean|shows the actual value as a node status.|
289
+
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)
295
+
296
+ [edge nodes](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/edge.json)
192
297
 
193
298
  ## Author
194
299
 
195
300
  [Mathias Schäffler](https://github.com/m-schaeffler)
196
301
 
302
+ ## Contributors
303
+
304
+ for `falling edge`, `raising edge` and `hysteresis`:
305
+ * [Eugene Schava](https://github.com/eschava/node-red-contrib-edge-trigger)
306
+
197
307
  ## License
198
308
 
199
309
  LGPL-2.1
package/counter.js CHANGED
@@ -12,6 +12,9 @@ module.exports = function(RED) {
12
12
  {
13
13
  msg.count = 0;
14
14
  }
15
+ else if( msg.query || msg.topic==="query" )
16
+ {
17
+ }
15
18
  else
16
19
  {
17
20
  msg.count++;
@@ -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