@mschaeffler/node-red-logic 1.4.5 → 1.4.6

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_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_mean.html CHANGED
@@ -17,7 +17,7 @@
17
17
  },
18
18
  inputs:1,
19
19
  outputs:1,
20
- icon:"font-awesome/fa-arrows-v",
20
+ icon:"smooth.png",
21
21
  label: function() {
22
22
  return this.name||"mean";
23
23
  },
package/math_mean.js CHANGED
@@ -7,10 +7,10 @@ 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
14
  if( this.propertyType === "jsonata" )
15
15
  {
16
16
  try {
@@ -67,16 +67,17 @@ module.exports = function(RED) {
67
67
  let data = context.get( "data" ) ?? {};
68
68
  let item = data[msg.topic] ?? [];
69
69
  item.push( { time:now, value:payload } );
70
- while( item[0].time < now - this.deltaTime )
70
+ while( item[0].time < now - node.deltaTime )
71
71
  {
72
72
  item.shift();
73
73
  }
74
74
  data[msg.topic] = item;
75
75
  context.set( "data", data );
76
76
 
77
- function sendValue(value)
77
+ function sendValue(value,count)
78
78
  {
79
79
  msg.payload = value;
80
+ msg.count = count;
80
81
  last[msg.topic] = now;
81
82
  context.set( "last", last );
82
83
  node.status({fill:"green",shape:"dot",text:`${item.length} / ${msg.payload.toPrecision(4)}`});
@@ -85,7 +86,7 @@ module.exports = function(RED) {
85
86
 
86
87
  if( node.zeroIsZero && payload === 0 )
87
88
  {
88
- sendValue( 0 );
89
+ sendValue( 0, 1 );
89
90
  }
90
91
  else if( item.length >= node.minData )
91
92
  {
@@ -96,7 +97,7 @@ module.exports = function(RED) {
96
97
  }
97
98
  if( (last[msg.topic]??0)+node.filter < now )
98
99
  {
99
- sendValue( sum/item.length );
100
+ sendValue( sum/item.length, item.length );
100
101
  }
101
102
  else
102
103
  {
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/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.6",
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",