@mschaeffler/node-red-logic 3.0.1 → 3.1.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.
@@ -12,6 +12,7 @@
12
12
  return v!=='' && !isNaN(v) && Number(v)<raise;}
13
13
  },
14
14
  consecutive:{value:"1",required:true},
15
+ consecutiveFall:{value:"1",required:true},
15
16
  outputRise:{value:true,required:true},
16
17
  outputRiseType:{value:"bool"},
17
18
  outputFall:{value:false,required:true},
@@ -69,9 +70,13 @@
69
70
  <input type="text" id="node-input-threshold_fall">
70
71
  </div>
71
72
  <div class="form-row">
72
- <label for="node-input-consecutive"><i class="fa fa-line-chart"></i> Consecutive</label>
73
+ <label for="node-input-consecutive"><i class="fa fa-line-chart"></i> rise Consecutive</label>
73
74
  <input type="text" id="node-input-consecutive">
74
75
  </div>
76
+ <div class="form-row">
77
+ <label for="node-input-consecutiveFall"><i class="fa fa-line-chart"></i> fall Consecutive</label>
78
+ <input type="text" id="node-input-consecutiveFall">
79
+ </div>
75
80
  <div class="form-row">
76
81
  <label for="node-input-outputRise"><i class="fa fa-sign-out"></i> rise Output</label>
77
82
  <input type="text" id="node-input-outputRise">
@@ -108,6 +113,19 @@
108
113
  <h3>Output</h3>
109
114
 
110
115
  <p>Trigger message, in case an edge is detected.</p>
116
+
117
+ <dl class="message-properties">
118
+ <dt>topic <span class="property-type">string</span></dt>
119
+ <dd> name of the input channel.</dd>
120
+ <dt>payload <span class="property-type"></span></dt>
121
+ <dd> output value defines in <code>rise Output</code> or <code>fall Output</code>.</dd>
122
+ <dt>value <span class="property-type">number</span></dt>
123
+ <dd> last input value for <code>topic</code>.</dd>
124
+ <dt>edge <span class="property-type">string</span></dt>
125
+ <dd> <code>"rising"</code> or <code>"falling"</code> according to detected edge.</dd>
126
+ <dt>init <span class="property-type">boolean</span></dt>
127
+ <dd> <code>true</code> in case of an initialization message without really an edge detection.</dd>
128
+ </dl>
111
129
 
112
130
  <h3>Parameter</h3>
113
131
 
@@ -118,8 +136,10 @@
118
136
  <dd> threshold value for the rising edge detection.</dd>
119
137
  <dt>d(ow)n Threshold <span class="property-type">number</span></dt>
120
138
  <dd> threshold value for the falling edge detection.</dd>
121
- <dt>Consecutive <span class="property-type">number</span></dt>
122
- <dd> number of consecutive frames to generate an output.</dd>
139
+ <dt>rise Consecutive <span class="property-type">number</span></dt>
140
+ <dd> number of consecutive frames to generate a rising output.</dd>
141
+ <dt>fall Consecutive <span class="property-type">number</span></dt>
142
+ <dd> number of consecutive frames to generate a falling output.</dd>
123
143
  <dt>rise Output <span class="property-type">multi</span></dt>
124
144
  <dd> Value to be sent in case of a rising edge.</dd>
125
145
  <dt>fall Output <span class="property-type">multi</span></dt>
@@ -10,7 +10,8 @@ module.exports = function(RED) {
10
10
  this.propertyType = config.propertyType ?? "msg";
11
11
  this.threshold_rise = Number( config.threshold_raise );
12
12
  this.threshold_fall = Number( config.threshold_fall );
13
- this.consecutive = Number( config.consecutive ?? 1 );
13
+ this.consecutiveRise= Number( config.consecutive ?? 1 );
14
+ this.consecutiveFall= Number( config.consecutiveFall ?? 1 );
14
15
  this.outputRise = tools.convertTypedInput( config.outputRise ?? "true", config.outputRiseType ?? "bool" );
15
16
  this.outputFall = tools.convertTypedInput( config.outputFall ?? "false",config.outputFallType ?? "bool" );
16
17
  this.showState = Boolean( config.showState );
@@ -79,12 +80,13 @@ module.exports = function(RED) {
79
80
  context.set( "data", data );
80
81
  msg.payload = edge ? node.outputRise : node.outputFall;
81
82
  msg.edge = edge ? "rising" : 'falling';
83
+ msg.init = last === undefined;
82
84
  send( msg );
83
85
  }
84
86
 
85
87
  if( msg.value > node.threshold_rise && last !== true )
86
88
  {
87
- if( ++node.cntRise >= node.consecutive )
89
+ if( ++node.cntRise >= node.consecutiveRise )
88
90
  {
89
91
  sendMsg( true );
90
92
  node.cntRise = 0;
@@ -97,7 +99,7 @@ module.exports = function(RED) {
97
99
  }
98
100
  else if( msg.value < node.threshold_fall && last !== false )
99
101
  {
100
- if( ++node.cntFall >= node.consecutive )
102
+ if( ++node.cntFall >= node.consecutiveFall )
101
103
  {
102
104
  sendMsg( false );
103
105
  node.cntFall = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
4
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",