@mschaeffler/node-red-logic 0.7.2 → 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/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,6 +9,8 @@ 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 )
@@ -45,8 +47,26 @@ module.exports = function(RED) {
45
47
 
46
48
  if( msg.count >= node.minData )
47
49
  {
48
- node.status( msg.payload );
49
- 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 );
50
70
  }
51
71
  else
52
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,8 +5,10 @@ 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 )
@@ -15,21 +17,32 @@ module.exports = function(RED) {
15
17
  return null;
16
18
  }
17
19
  msg.payload = tools.property2boolean( RED.util.getMessageProperty( msg, node.property ) );
20
+ let status = { text:msg.payload ?? "error" };
18
21
  if( msg.payload !== null )
19
22
  {
20
- if( node.showState )
23
+ if( node.filter )
21
24
  {
22
- 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
+ }
23
36
  }
24
- send( msg );
25
- }
26
- else
27
- {
28
- if( node.showState )
37
+ else
29
38
  {
30
- node.status( "error" );
39
+ send( msg );
31
40
  }
32
41
  }
42
+ if( node.showState )
43
+ {
44
+ node.status( status );
45
+ }
33
46
  done();
34
47
  });
35
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,6 +9,8 @@ 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 )
@@ -45,8 +47,26 @@ module.exports = function(RED) {
45
47
 
46
48
  if( msg.count >= node.minData )
47
49
  {
48
- node.status( msg.payload );
49
- 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 );
50
70
  }
51
71
  else
52
72
  {
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,8 +4,10 @@ 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 )
@@ -14,20 +16,35 @@ module.exports = function(RED) {
14
16
  return null;
15
17
  }
16
18
  msg.payload = Number( RED.util.getMessageProperty( msg, node.property ) );
19
+ let status = { text:msg.payload };
17
20
  if( ! isNaN( msg.payload ) )
18
21
  {
19
- if( node.showState )
22
+ if( node.filter )
20
23
  {
21
- 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 );
22
39
  }
23
- send( msg );
24
40
  }
25
41
  else
26
42
  {
27
- if( node.showState )
28
- {
29
- node.status( "not a Number" );
30
- }
43
+ status.text = "not a Number";
44
+ }
45
+ if( node.showState )
46
+ {
47
+ node.status( status );
31
48
  }
32
49
  done();
33
50
  });
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,6 +11,8 @@ 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 )
@@ -26,6 +28,7 @@ module.exports = function(RED) {
26
28
  else
27
29
  {
28
30
  const payload = Number( RED.util.getMessageProperty( msg, node.property ) );
31
+ let status = { shape:"dot" };
29
32
  if( ! isNaN( payload ) )
30
33
  {
31
34
  let data = context.get( "data" ) ?? {};
@@ -73,18 +76,38 @@ module.exports = function(RED) {
73
76
  {
74
77
  case "mean": msg.payload /= msg.count; break;
75
78
  }
76
- node.status({fill:"green",shape:"dot",text:msg.payload});
77
- 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
+ }
78
98
  }
79
99
  else
80
100
  {
81
- node.status({fill:"gray",shape:"dot",text:"to less data"});
101
+ status.fill = "gray";
102
+ status.text = "to less data";
82
103
  }
83
104
  }
84
105
  else
85
106
  {
86
- node.status({fill:"red",shape:"dot",text:"payload is NaN"});
107
+ status.fill = "red";
108
+ status.text = "payload is NaN";
87
109
  }
110
+ node.status( status );
88
111
  }
89
112
  done();
90
113
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "0.7.2",
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",