@mschaeffler/node-red-logic 1.4.5 → 1.4.7

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.
Binary file
package/logic_and.js CHANGED
@@ -6,9 +6,9 @@ module.exports = function(RED) {
6
6
  //this.config = config;
7
7
  var node = this;
8
8
  var context = this.context();
9
- this.topic = config.topic;
9
+ this.topic = config.topic ?? "";
10
10
  this.property = config.property || "payload";
11
- this.minData = Number( config.minData );
11
+ this.minData = Number( config.minData ?? 1 );
12
12
  this.filter = Boolean( config.filter );
13
13
  this.last = null;
14
14
 
package/logic_bool.js CHANGED
@@ -9,6 +9,7 @@ module.exports = function(RED) {
9
9
  this.showState = Boolean( config.showState );
10
10
  this.filter = Boolean( config.filter );
11
11
  this.last = null;
12
+ node.status( "" );
12
13
 
13
14
  node.on('input', function(msg,send,done) {
14
15
  if( msg.invalid )
package/logic_not.js CHANGED
@@ -9,6 +9,7 @@ module.exports = function(RED) {
9
9
  this.showState = Boolean( config.showState );
10
10
  this.filter = Boolean( config.filter );
11
11
  this.last = null;
12
+ node.status( "" );
12
13
 
13
14
  node.on('input', function(msg,send,done) {
14
15
  if( msg.invalid )
package/logic_or.js CHANGED
@@ -6,9 +6,9 @@ module.exports = function(RED) {
6
6
  //this.config = config;
7
7
  var node = this;
8
8
  var context = this.context();
9
- this.topic = config.topic;
9
+ this.topic = config.topic ?? "";
10
10
  this.property = config.property || "payload";
11
- this.minData = Number( config.minData );
11
+ this.minData = Number( config.minData ?? 1 );
12
12
  this.filter = Boolean( config.filter );
13
13
  this.last = null;
14
14
 
package/math_falling.js CHANGED
@@ -19,6 +19,7 @@ module.exports = function(RED) {
19
19
  return;
20
20
  }
21
21
  }
22
+ node.status( "" );
22
23
 
23
24
  node.on('input', function(msg,send,done) {
24
25
  if( msg.invalid )
@@ -21,6 +21,7 @@ module.exports = function(RED) {
21
21
  return;
22
22
  }
23
23
  }
24
+ node.status( "" );
24
25
 
25
26
  node.on('input', function(msg,send,done) {
26
27
  if( msg.invalid )
package/math_mean.html CHANGED
@@ -13,11 +13,12 @@
13
13
  return v!=='' && !isNaN(v) && Number(v)>0;}
14
14
  },
15
15
  filter:{value:"0", validate:RED.validators.number()},
16
- zeroIsZero:{value:false}
16
+ zeroIsZero:{value:false},
17
+ showState:{value:false}
17
18
  },
18
19
  inputs:1,
19
20
  outputs:1,
20
- icon:"font-awesome/fa-arrows-v",
21
+ icon:"smooth.png",
21
22
  label: function() {
22
23
  return this.name||"mean";
23
24
  },
@@ -62,6 +63,10 @@
62
63
  <label for="node-input-zeroIsZero"><i class="fa fa-exclamation-circle"></i> Null ist Null</label>
63
64
  <input type="checkbox" id="node-input-zeroIsZero" style="display:inline-block; width:20px; vertical-align:baseline;">
64
65
  </div>
66
+ <div class="form-row">
67
+ <label for="node-input-showStatus"><i class="fa fa-star-o"></i> Status</label>
68
+ <input type="checkbox" id="node-input-showState" style="display:inline-block; width:20px; vertical-align:baseline;">
69
+ </div>
65
70
  </script>
66
71
 
67
72
  <script type="text/html" data-help-name="mean">
@@ -101,5 +106,7 @@
101
106
  <dd> send output only after this time.</dd>
102
107
  <dt>Null ist NUll <span class="property-type">boolean</span></dt>
103
108
  <dd> If 0 is received, 0 is send immediately.</dd>
109
+ <dt>Status <span class="property-type">boolean</span></dt>
110
+ <dd> shows the actual value as a node status.</dd>
104
111
  </dl>
105
112
  </script>
package/math_mean.js CHANGED
@@ -7,10 +7,11 @@ module.exports = function(RED) {
7
7
  var context = this.context();
8
8
  this.property = config.property || "payload";
9
9
  this.propertyType = config.propertyType ?? "msg";
10
- this.deltaTime = Number( config.deltaTime )*1000;
11
- this.minData = Number( config.minData );
10
+ this.deltaTime = Number( config.deltaTime ?? 60 )*1000;
11
+ this.minData = Number( config.minData ?? 1 );
12
12
  this.filter = Number( config.filter ?? 0 )*1000;
13
- this.zeroIsZero = config.zeroIsZero ?? false;
13
+ this.zeroIsZero = Boolean( config.zeroIsZero );
14
+ this.showState = Boolean( config.showState );
14
15
  if( this.propertyType === "jsonata" )
15
16
  {
16
17
  try {
@@ -21,6 +22,15 @@ module.exports = function(RED) {
21
22
  return;
22
23
  }
23
24
  }
25
+ this.oldStatus = this.status;
26
+ this.status = function(state)
27
+ {
28
+ if( node.showState )
29
+ {
30
+ node.oldStatus( state );
31
+ }
32
+ }
33
+ node.oldStatus( "" );
24
34
 
25
35
  node.on('input', function(msg,send,done) {
26
36
  if( msg.invalid )
@@ -67,16 +77,17 @@ module.exports = function(RED) {
67
77
  let data = context.get( "data" ) ?? {};
68
78
  let item = data[msg.topic] ?? [];
69
79
  item.push( { time:now, value:payload } );
70
- while( item[0].time < now - this.deltaTime )
80
+ while( item[0].time < now - node.deltaTime )
71
81
  {
72
82
  item.shift();
73
83
  }
74
84
  data[msg.topic] = item;
75
85
  context.set( "data", data );
76
86
 
77
- function sendValue(value)
87
+ function sendValue(value,count)
78
88
  {
79
89
  msg.payload = value;
90
+ msg.count = count;
80
91
  last[msg.topic] = now;
81
92
  context.set( "last", last );
82
93
  node.status({fill:"green",shape:"dot",text:`${item.length} / ${msg.payload.toPrecision(4)}`});
@@ -85,7 +96,7 @@ module.exports = function(RED) {
85
96
 
86
97
  if( node.zeroIsZero && payload === 0 )
87
98
  {
88
- sendValue( 0 );
99
+ sendValue( 0, 1 );
89
100
  }
90
101
  else if( item.length >= node.minData )
91
102
  {
@@ -96,7 +107,7 @@ module.exports = function(RED) {
96
107
  }
97
108
  if( (last[msg.topic]??0)+node.filter < now )
98
109
  {
99
- sendValue( sum/item.length );
110
+ sendValue( sum/item.length, item.length );
100
111
  }
101
112
  else
102
113
  {
package/math_minus.js CHANGED
@@ -19,6 +19,7 @@ module.exports = function(RED) {
19
19
  return;
20
20
  }
21
21
  }
22
+ node.status( "" );
22
23
 
23
24
  node.on('input', function(msg,send,done) {
24
25
  if( msg.invalid )
package/math_number.js CHANGED
@@ -19,6 +19,7 @@ module.exports = function(RED) {
19
19
  return;
20
20
  }
21
21
  }
22
+ node.status( "" );
22
23
 
23
24
  node.on('input', function(msg,send,done) {
24
25
  if( msg.invalid )
package/math_reduce.js CHANGED
@@ -5,11 +5,11 @@ module.exports = function(RED) {
5
5
  //this.config = config;
6
6
  var node = this;
7
7
  var context = this.context();
8
- this.topic = config.topic;
8
+ this.topic = config.topic ?? "";
9
9
  this.property = config.property || "payload";
10
- this.minMean = Number( config.minMean );
11
- this.maxMean = Number( config.maxMean );
12
- this.minData = Number( config.minData );
10
+ this.minMean = Number( config.minMean ?? 1 );
11
+ this.maxMean = Number( config.maxMean ?? 1 );
12
+ this.minData = Number( config.minData ?? 1 );
13
13
  this.algo = config.algo;
14
14
  this.filter = Boolean( config.filter );
15
15
  this.last = null;
package/math_rising.js CHANGED
@@ -19,6 +19,7 @@ module.exports = function(RED) {
19
19
  return;
20
20
  }
21
21
  }
22
+ node.status( "" );
22
23
 
23
24
  node.on('input', function(msg,send,done) {
24
25
  if( msg.invalid )
@@ -7,8 +7,8 @@ module.exports = function(RED) {
7
7
  var context = this.context();
8
8
  this.property = config.property || "payload";
9
9
  this.propertyType = config.propertyType ?? "msg";
10
- this.deltaTime = Number( config.deltaTime )*1000;
11
- this.minData = Number( config.minData );
10
+ this.deltaTime = Number( config.deltaTime ?? 60 )*1000;
11
+ this.minData = Number( config.minData ?? 1 );
12
12
  if( this.propertyType === "jsonata" )
13
13
  {
14
14
  try {
@@ -33,7 +33,6 @@ module.exports = function(RED) {
33
33
  }
34
34
  else
35
35
  {
36
- const now = Date.now();
37
36
  function getPayload(callback)
38
37
  {
39
38
  if( node.propertyPrepared )
@@ -57,6 +56,7 @@ module.exports = function(RED) {
57
56
  }
58
57
  getPayload( function(value)
59
58
  {
59
+ const now = Date.now();
60
60
  const payload = Number( value );
61
61
  if( ! isNaN( payload ) )
62
62
  {
@@ -73,6 +73,7 @@ module.exports = function(RED) {
73
73
  if( item.length >= node.minData )
74
74
  {
75
75
  msg.stat = {
76
+ value: payload,
76
77
  count: item.length,
77
78
  min: Number.MAX_SAFE_INTEGER,
78
79
  max: Number.MIN_SAFE_INTEGER };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "1.4.5",
3
+ "version": "1.4.7",
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",
@@ -35,5 +35,8 @@
35
35
  "author": {
36
36
  "name": "Mathias Schäffler",
37
37
  "url": "https://github.com/m-schaeffler"
38
+ },
39
+ "scripts": {
40
+ "test": "mocha \"test/*_spec.js\""
38
41
  }
39
42
  }