@mschaeffler/node-red-logic 0.4.2 → 0.4.3

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
@@ -10,7 +10,7 @@ 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
+ ## Nodes
14
14
 
15
15
  ### counter
16
16
 
@@ -187,13 +187,17 @@ The message property to be used as payload can be defined with the `Property` pr
187
187
  #### Algorithms
188
188
 
189
189
 
190
- ## fallingEdge
190
+ ## Edge Nodes
191
+
192
+ ![image of example flow](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/edge.png)
193
+
194
+ ### fallingEdge
191
195
 
192
196
  Message is only forwarded, if the payload falls below a threshold value.
193
197
 
194
198
  Each `topic` is treated seperatly.
195
199
 
196
- ### Input
200
+ #### Input
197
201
 
198
202
  The message property to be used as payload can be defined with the `Property` property.
199
203
 
@@ -202,11 +206,11 @@ The message property to be used as payload can be defined with the `Property` pr
202
206
  |topic | string | name of the input channel. |
203
207
  |payload | number | input value for `topic`. |
204
208
 
205
- ### Output
209
+ #### Output
206
210
 
207
211
  Trigger message, in case a falling edge is detected.
208
212
 
209
- ### Parameter
213
+ #### Parameters
210
214
 
211
215
  |config| type | description |
212
216
  |:-----|:-------|:----------------------------------|
@@ -214,13 +218,13 @@ Trigger message, in case a falling edge is detected.
214
218
  |Threshold|number|threshold value for the edge detection.|
215
219
  |Status|boolean|shows the actual value as a node status.|
216
220
 
217
- ## raisingEdge
221
+ ### raisingEdge
218
222
 
219
223
  Message is only forwarded, if the payload raises above a threshold value.
220
224
 
221
225
  Each `topic` is treated seperatly.
222
226
 
223
- ### Input
227
+ #### Input
224
228
 
225
229
  The message property to be used as payload can be defined with the `Property` property.
226
230
 
@@ -229,11 +233,11 @@ The message property to be used as payload can be defined with the `Property` pr
229
233
  |topic | string | name of the input channel. |
230
234
  |payload | number | input value for `topic`. |
231
235
 
232
- ### Output
236
+ #### Output
233
237
 
234
238
  Trigger message, in case a raising edge is detected.
235
239
 
236
- ### Parameter
240
+ #### Parameters
237
241
 
238
242
  |config| type | description |
239
243
  |:-----|:-------|:----------------------------------|
@@ -241,13 +245,13 @@ Trigger message, in case a raising edge is detected.
241
245
  |Threshold|number|threshold value for the edge detection.|
242
246
  |Status|boolean|shows the actual value as a node status.|
243
247
 
244
- ## hysteresis
248
+ ### hysteresis
245
249
 
246
250
  Message is only forwarded, if the payload raises above an upper limit or falls below a lower limit.
247
251
 
248
252
  Each `topic` is treated seperatly.
249
253
 
250
- ### Input
254
+ #### Input
251
255
 
252
256
  The message property to be used as payload can be defined with the `Property` property.
253
257
 
@@ -256,11 +260,11 @@ The message property to be used as payload can be defined with the `Property` pr
256
260
  |topic | string | name of the input channel. |
257
261
  |payload | number | input value for `topic`. |
258
262
 
259
- ### Output
263
+ #### Output
260
264
 
261
265
  Trigger message, in case an edge is detected.
262
266
 
263
- ### Parameter
267
+ #### Parameters
264
268
 
265
269
  |config| type | description |
266
270
  |:-----|:-------|:----------------------------------|
@@ -270,9 +274,9 @@ Trigger message, in case an edge is detected.
270
274
  |1st message|string|initial behaviour (None, Rising, Falling, Any).|
271
275
  |Status|boolean|shows the actual value as a node status.|
272
276
 
273
- ## Example Flow
277
+ ## Example Flows
274
278
 
275
- [example flow](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/logic.json)
279
+ [edge nodes](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-logic/examples/edge.json)
276
280
 
277
281
  ## Author
278
282
 
@@ -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
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;
@@ -50,11 +50,11 @@ module.exports = function(RED) {
50
50
  else
51
51
  {
52
52
  data[msg.topic] = {};
53
- if( ( this.initial == 'any' || this.initial == 'rising' ) && msg.payload > this.threshold_raise )
53
+ if( this.initial in ['any','rising'] && msg.payload > this.threshold_raise )
54
54
  {
55
55
  sendMsg( 'rising' );
56
56
  }
57
- else if( ( this.initial == 'any' || this.initial == 'falling' ) && msg.payload < this.threshold_fall )
57
+ else if( this.initial in ['any','falling'] && msg.payload < this.threshold_fall )
58
58
  {
59
59
  sendMsg( 'falling' );
60
60
  }
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
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",