@mschaeffler/node-red-logic 0.7.1 → 0.8.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.
package/counter.js CHANGED
@@ -9,6 +9,7 @@ module.exports = function(RED) {
9
9
  node.on('input', function(msg,send,done) {
10
10
  if( msg.invalid )
11
11
  {
12
+ done();
12
13
  return null;
13
14
  }
14
15
  msg.count = context.get( "count" ) ?? 0;
package/logic_and.html CHANGED
@@ -8,7 +8,8 @@
8
8
  property:{value:"payload", required:true},
9
9
  minData:{value:"1", required:true, validate:function(v){
10
10
  return v!=='' && !isNaN(v) && Number(v)>0;
11
- }}
11
+ }},
12
+ filter:{value:false}
12
13
  },
13
14
  inputs:1,
14
15
  outputs:1,
@@ -49,6 +50,10 @@
49
50
  <label for="node-input-minData"><i class="fa fa-tag"></i> min. Data</label>
50
51
  <input type="text" id="node-input-minData">
51
52
  </div>
53
+ <div class="form-row">
54
+ <label for="node-input-filter"><i class="fa fa-filter"></i> Filter</label>
55
+ <input type="checkbox" id="node-input-filter" style="display:inline-block; width:20px; vertical-align:baseline;">
56
+ </div>
52
57
  </script>
53
58
 
54
59
  <script type="text/html" data-help-name="and">
package/logic_and.js CHANGED
@@ -9,10 +9,13 @@ module.exports = function(RED) {
9
9
  this.topic = config.topic;
10
10
  this.property = config.property || "payload";
11
11
  this.minData = Number( config.minData );
12
+ this.filter = Boolean( config.filter );
13
+ this.last = null;
12
14
 
13
15
  node.on('input', function(msg,send,done) {
14
16
  if( msg.invalid )
15
17
  {
18
+ done();
16
19
  return null;
17
20
  }
18
21
  if( msg.reset || msg.topic==="init" )
@@ -44,8 +47,26 @@ module.exports = function(RED) {
44
47
 
45
48
  if( msg.count >= node.minData )
46
49
  {
47
- node.status( msg.payload );
48
- send( msg );
50
+ let status = { text:msg.payload };
51
+ if( node.filter )
52
+ {
53
+ status.shape = "dot";
54
+ if( msg.payload !== node.last )
55
+ {
56
+ node.last = msg.payload;
57
+ status.fill = "green";
58
+ send( msg );
59
+ }
60
+ else
61
+ {
62
+ status.fill = "gray";
63
+ }
64
+ }
65
+ else
66
+ {
67
+ send( msg );
68
+ }
69
+ node.status( status );
49
70
  }
50
71
  else
51
72
  {
package/logic_bool.html CHANGED
@@ -5,7 +5,8 @@
5
5
  defaults: {
6
6
  name:{value:""},
7
7
  property:{value:"payload",required:true},
8
- showState:{value:false}
8
+ showState:{value:false},
9
+ filter:{value:false}
9
10
  },
10
11
  inputs:1,
11
12
  outputs:1,
@@ -43,6 +44,10 @@
43
44
  <label for="node-input-showStatus"><i class="fa fa-star-o"></i> Status</label>
44
45
  <input type="checkbox" id="node-input-showState" style="display:inline-block; width:20px; vertical-align:baseline;">
45
46
  </div>
47
+ <div class="form-row">
48
+ <label for="node-input-filter"><i class="fa fa-filter"></i> Filter</label>
49
+ <input type="checkbox" id="node-input-filter" style="display:inline-block; width:20px; vertical-align:baseline;">
50
+ </div>
46
51
  </script>
47
52
 
48
53
  <script type="text/html" data-help-name="tobool">
package/logic_bool.js CHANGED
@@ -5,30 +5,44 @@ module.exports = function(RED) {
5
5
  RED.nodes.createNode(this,config);
6
6
  //this.config = config;
7
7
  var node = this;
8
- this.property = config.property || "payload";
8
+ this.property = config.property || "payload";
9
9
  this.showState = config.showState;
10
+ this.filter = Boolean( config.filter );
11
+ this.last = null;
10
12
 
11
13
  node.on('input', function(msg,send,done) {
12
14
  if( msg.invalid )
13
15
  {
16
+ done();
14
17
  return null;
15
18
  }
16
19
  msg.payload = tools.property2boolean( RED.util.getMessageProperty( msg, node.property ) );
20
+ let status = { text:msg.payload ?? "error" };
17
21
  if( msg.payload !== null )
18
22
  {
19
- if( node.showState )
23
+ if( node.filter )
20
24
  {
21
- node.status( msg.payload );
25
+ status.shape = "dot";
26
+ if( msg.payload !== node.last )
27
+ {
28
+ node.last = msg.payload;
29
+ status.fill = "green";
30
+ send( msg );
31
+ }
32
+ else
33
+ {
34
+ status.fill = "gray";
35
+ }
22
36
  }
23
- send( msg );
24
- }
25
- else
26
- {
27
- if( node.showState )
37
+ else
28
38
  {
29
- node.status( "error" );
39
+ send( msg );
30
40
  }
31
41
  }
42
+ if( node.showState )
43
+ {
44
+ node.status( status );
45
+ }
32
46
  done();
33
47
  });
34
48
  }
package/logic_or.html CHANGED
@@ -8,7 +8,8 @@
8
8
  property:{value:"payload", required:true},
9
9
  minData:{value:"1", required:true, validate:function(v){
10
10
  return v!=='' && !isNaN(v) && Number(v)>0;
11
- }}
11
+ }},
12
+ filter:{value:false}
12
13
  },
13
14
  inputs:1,
14
15
  outputs:1,
@@ -49,6 +50,10 @@
49
50
  <label for="node-input-minData"><i class="fa fa-tag"></i> min. Data</label>
50
51
  <input type="text" id="node-input-minData">
51
52
  </div>
53
+ <div class="form-row">
54
+ <label for="node-input-filter"><i class="fa fa-filter"></i> Filter</label>
55
+ <input type="checkbox" id="node-input-filter" style="display:inline-block; width:20px; vertical-align:baseline;">
56
+ </div>
52
57
  </script>
53
58
 
54
59
  <script type="text/html" data-help-name="or">
package/logic_or.js CHANGED
@@ -9,10 +9,13 @@ module.exports = function(RED) {
9
9
  this.topic = config.topic;
10
10
  this.property = config.property || "payload";
11
11
  this.minData = Number( config.minData );
12
+ this.filter = Boolean( config.filter );
13
+ this.last = null;
12
14
 
13
15
  node.on('input', function(msg,send,done) {
14
16
  if( msg.invalid )
15
17
  {
18
+ done();
16
19
  return null;
17
20
  }
18
21
  if( msg.reset || msg.topic==="init" )
@@ -44,8 +47,26 @@ module.exports = function(RED) {
44
47
 
45
48
  if( msg.count >= node.minData )
46
49
  {
47
- node.status( msg.payload );
48
- send( msg );
50
+ let status = { text:msg.payload };
51
+ if( node.filter )
52
+ {
53
+ status.shape = "dot";
54
+ if( msg.payload !== node.last )
55
+ {
56
+ node.last = msg.payload;
57
+ status.fill = "green";
58
+ send( msg );
59
+ }
60
+ else
61
+ {
62
+ status.fill = "gray";
63
+ }
64
+ }
65
+ else
66
+ {
67
+ send( msg );
68
+ }
69
+ node.status( status );
49
70
  }
50
71
  else
51
72
  {
package/math_falling.js CHANGED
@@ -12,6 +12,7 @@ module.exports = function(RED) {
12
12
  node.on('input', function(msg,send,done) {
13
13
  if( msg.invalid )
14
14
  {
15
+ done();
15
16
  return null;
16
17
  }
17
18
  if( msg.reset || msg.topic==="init" )
@@ -14,6 +14,7 @@ module.exports = function(RED) {
14
14
  node.on('input', function(msg,send,done) {
15
15
  if( msg.invalid )
16
16
  {
17
+ done();
17
18
  return null;
18
19
  }
19
20
  if( msg.reset || msg.topic==="init" )
package/math_number.html CHANGED
@@ -5,7 +5,8 @@
5
5
  defaults: {
6
6
  name:{value:""},
7
7
  property:{value:"payload",required:true},
8
- showState:{value:false}
8
+ showState:{value:false},
9
+ filter:{value:false}
9
10
  },
10
11
  inputs:1,
11
12
  outputs:1,
@@ -43,6 +44,10 @@
43
44
  <label for="node-input-showStatus"><i class="fa fa-star-o"></i> Status</label>
44
45
  <input type="checkbox" id="node-input-showState" style="display:inline-block; width:20px; vertical-align:baseline;">
45
46
  </div>
47
+ <div class="form-row">
48
+ <label for="node-input-filter"><i class="fa fa-filter"></i> Filter</label>
49
+ <input type="checkbox" id="node-input-filter" style="display:inline-block; width:20px; vertical-align:baseline;">
50
+ </div>
46
51
  </script>
47
52
 
48
53
  <script type="text/html" data-help-name="tonumber">
package/math_number.js CHANGED
@@ -4,29 +4,47 @@ module.exports = function(RED) {
4
4
  RED.nodes.createNode(this,config);
5
5
  //this.config = config;
6
6
  var node = this;
7
- this.property = config.property ?? "payload";
7
+ this.property = config.property ?? "payload";
8
8
  this.showState = config.showState;
9
+ this.filter = Boolean( config.filter );
10
+ this.last = null;
9
11
 
10
12
  node.on('input', function(msg,send,done) {
11
13
  if( msg.invalid )
12
14
  {
15
+ done();
13
16
  return null;
14
17
  }
15
18
  msg.payload = Number( RED.util.getMessageProperty( msg, node.property ) );
19
+ let status = { text:msg.payload };
16
20
  if( ! isNaN( msg.payload ) )
17
21
  {
18
- if( node.showState )
22
+ if( node.filter )
19
23
  {
20
- node.status( msg.payload );
24
+ status.shape = "dot";
25
+ if( msg.payload !== node.last )
26
+ {
27
+ node.last = msg.payload;
28
+ status.fill = "green";
29
+ send( msg );
30
+ }
31
+ else
32
+ {
33
+ status.fill = "gray";
34
+ }
35
+ }
36
+ else
37
+ {
38
+ send( msg );
21
39
  }
22
- send( msg );
23
40
  }
24
41
  else
25
42
  {
26
- if( node.showState )
27
- {
28
- node.status( "not a Number" );
29
- }
43
+ status.text = "not a Number";
44
+ }
45
+ if( node.showState )
46
+ {
47
+ node.status( status );
30
48
  }
31
49
  done();
32
50
  });
package/math_raising.js CHANGED
@@ -12,6 +12,7 @@ module.exports = function(RED) {
12
12
  node.on('input', function(msg,send,done) {
13
13
  if( msg.invalid )
14
14
  {
15
+ done();
15
16
  return null;
16
17
  }
17
18
  if( msg.reset || msg.topic==="init" )
package/math_reduce.html CHANGED
@@ -16,7 +16,8 @@
16
16
  minData:{value:"1", required:true, validate:function(v){
17
17
  return v!=='' && !isNaN(v) && Number(v)>0;}
18
18
  },
19
- algo:{value:"", required:true}
19
+ algo:{value:"", required:true},
20
+ filter:{value:false}
20
21
  },
21
22
  inputs:1,
22
23
  outputs:1,
@@ -85,6 +86,10 @@
85
86
  <option value="max">Maximum</option>
86
87
  </select>
87
88
  </div>
89
+ <div class="form-row">
90
+ <label for="node-input-filter"><i class="fa fa-filter"></i> Filter</label>
91
+ <input type="checkbox" id="node-input-filter" style="display:inline-block; width:20px; vertical-align:baseline;">
92
+ </div>
88
93
  </script>
89
94
 
90
95
  <script type="text/html" data-help-name="reduce">
package/math_reduce.js CHANGED
@@ -11,10 +11,13 @@ module.exports = function(RED) {
11
11
  this.maxMean = Number( config.maxMean );
12
12
  this.minData = Number( config.minData );
13
13
  this.algo = config.algo;
14
+ this.filter = Boolean( config.filter );
15
+ this.last = null;
14
16
 
15
17
  node.on('input', function(msg,send,done) {
16
18
  if( msg.invalid )
17
19
  {
20
+ done();
18
21
  return null;
19
22
  }
20
23
  if( msg.reset || msg.topic==="init" )
@@ -25,6 +28,7 @@ module.exports = function(RED) {
25
28
  else
26
29
  {
27
30
  const payload = Number( RED.util.getMessageProperty( msg, node.property ) );
31
+ let status = { shape:"dot" };
28
32
  if( ! isNaN( payload ) )
29
33
  {
30
34
  let data = context.get( "data" ) ?? {};
@@ -72,18 +76,38 @@ module.exports = function(RED) {
72
76
  {
73
77
  case "mean": msg.payload /= msg.count; break;
74
78
  }
75
- node.status({fill:"green",shape:"dot",text:msg.payload});
76
- send( msg );
79
+ status.text = msg.payload;
80
+ if( node.filter )
81
+ {
82
+ if( msg.payload !== node.last )
83
+ {
84
+ node.last = msg.payload;
85
+ status.fill = "green";
86
+ send( msg );
87
+ }
88
+ else
89
+ {
90
+ status.fill = "gray";
91
+ }
92
+ }
93
+ else
94
+ {
95
+ status.fill = "green";
96
+ send( msg );
97
+ }
77
98
  }
78
99
  else
79
100
  {
80
- node.status({fill:"gray",shape:"dot",text:"to less data"});
101
+ status.fill = "gray";
102
+ status.text = "to less data";
81
103
  }
82
104
  }
83
105
  else
84
106
  {
85
- node.status({fill:"red",shape:"dot",text:"payload is NaN"});
107
+ status.fill = "red";
108
+ status.text = "payload is NaN";
86
109
  }
110
+ node.status( status );
87
111
  }
88
112
  done();
89
113
  });
@@ -12,6 +12,7 @@ module.exports = function(RED) {
12
12
  node.on('input', function(msg,send,done) {
13
13
  if( msg.invalid )
14
14
  {
15
+ done();
15
16
  return null;
16
17
  }
17
18
  if( msg.reset || msg.topic==="init" )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "0.7.1",
3
+ "version": "0.8.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",