@mschaeffler/node-red-logic 1.4.4 → 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.
package/counter.js CHANGED
@@ -16,6 +16,7 @@ module.exports = function(RED) {
16
16
  if( msg.reset || msg.topic==="init" )
17
17
  {
18
18
  msg.count = 0;
19
+ delete msg.reset;
19
20
  }
20
21
  else if( msg.query || msg.topic==="query" )
21
22
  {
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
@@ -6,7 +6,7 @@ module.exports = function(RED) {
6
6
  //this.config = config;
7
7
  var node = this;
8
8
  this.property = config.property || "payload";
9
- this.showState = config.showState;
9
+ this.showState = Boolean( config.showState );
10
10
  this.filter = Boolean( config.filter );
11
11
  this.last = null;
12
12
 
package/logic_not.js CHANGED
@@ -6,7 +6,7 @@ module.exports = function(RED) {
6
6
  //this.config = config;
7
7
  var node = this;
8
8
  this.property = config.property || "payload";
9
- this.showState = config.showState;
9
+ this.showState = Boolean( config.showState );
10
10
  this.filter = Boolean( config.filter );
11
11
  this.last = null;
12
12
 
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
@@ -8,7 +8,7 @@ module.exports = function(RED) {
8
8
  this.property = config.property ?? "payload";
9
9
  this.propertyType = config.propertyType ?? "msg";
10
10
  this.threshold = config.threshold;
11
- this.showState = config.showState;
11
+ this.showState = Boolean( config.showState );
12
12
  if( this.propertyType === "jsonata" )
13
13
  {
14
14
  try {
@@ -71,7 +71,7 @@
71
71
 
72
72
  <script type="text/html" data-help-name="hysteresisEdge">
73
73
 
74
- <p>Message is only forwarded, if the payload raises above an upper limit or falls below a lower limit.</p>
74
+ <p>Message is only forwarded, if the payload rises above an upper limit or falls below a lower limit.</p>
75
75
  <p>Each <code>topic</code> is treated seperatly.</p>
76
76
  <p>If the msg property <code>invalid</code> is present in the message, all nodes ignore the message.</p>
77
77
 
@@ -96,7 +96,7 @@
96
96
  <dt>Property <span class="property-type">string</span></dt>
97
97
  <dd> defines the message property to be used as payload.</dd>
98
98
  <dt>up Threshold <span class="property-type">number</span></dt>
99
- <dd> threshold value for the raising edge detection.</dd>
99
+ <dd> threshold value for the rising edge detection.</dd>
100
100
  <dt>d(ow)n Threshold <span class="property-type">number</span></dt>
101
101
  <dd> threshold value for the falling edge detection.</dd>
102
102
  <dt>1st message <span class="property-type">string</span></dt>
@@ -5,12 +5,12 @@ module.exports = function(RED) {
5
5
  //this.config = config;
6
6
  var node = this;
7
7
  var context = this.context();
8
- this.property = config.property ?? "payload";
9
- this.propertyType = config.propertyType ?? "msg";
10
- this.threshold_raise = config.threshold_raise;
11
- this.threshold_fall = config.threshold_fall;
12
- this.initial = config.initial;
13
- this.showState = config.showState;
8
+ this.property = config.property ?? "payload";
9
+ this.propertyType = config.propertyType ?? "msg";
10
+ this.threshold_rise = config.threshold_raise;
11
+ this.threshold_fall = config.threshold_fall;
12
+ this.initial = config.initial ?? "none";
13
+ this.showState = Boolean( config.showState );
14
14
  if( this.propertyType === "jsonata" )
15
15
  {
16
16
  try {
@@ -76,7 +76,7 @@ module.exports = function(RED) {
76
76
 
77
77
  if( last )
78
78
  {
79
- if( msg.payload > node.threshold_raise && node.threshold_raise >= last.value && last.edge != 'rising')
79
+ if( msg.payload > node.threshold_rise && node.threshold_rise >= last.value && last.edge != 'rising')
80
80
  {
81
81
  sendMsg( 'rising' );
82
82
  }
@@ -88,7 +88,7 @@ module.exports = function(RED) {
88
88
  else
89
89
  {
90
90
  data[msg.topic] = {};
91
- if( ['any','rising'].includes(node.initial) && msg.payload > node.threshold_raise )
91
+ if( ['any','rising'].includes(node.initial) && msg.payload > node.threshold_rise )
92
92
  {
93
93
  sendMsg( 'rising' );
94
94
  }
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;
@@ -13,12 +13,12 @@
13
13
  outputs:1,
14
14
  icon: "raising-edge.png",
15
15
  label: function() {
16
- return this.name||"raising edge";
16
+ return this.name||"rising edge";
17
17
  },
18
18
  labelStyle: function() {
19
19
  return this.name?"node_label_italic":"";
20
20
  },
21
- paletteLabel: "raising edge",
21
+ paletteLabel: "rising edge",
22
22
  inputLabels: 'input',
23
23
  outputLabels: 'edge trigger',
24
24
  oneditprepare: function() {
@@ -53,7 +53,7 @@
53
53
 
54
54
  <script type="text/html" data-help-name="raisingEdge">
55
55
 
56
- <p>Message is only forwarded, if the payload raises above a threshold value.</p>
56
+ <p>Message is only forwarded, if the payload rises above a threshold value.</p>
57
57
  <p>Each <code>topic</code> is treated seperatly.</p>
58
58
  <p>If the msg property <code>invalid</code> is present in the message, all nodes ignore the message.</p>
59
59
 
@@ -8,7 +8,7 @@ module.exports = function(RED) {
8
8
  this.property = config.property ?? "payload";
9
9
  this.propertyType = config.propertyType ?? "msg";
10
10
  this.threshold = config.threshold;
11
- this.showState = config.showState;
11
+ this.showState = Boolean( config.showState );
12
12
  if( this.propertyType === "jsonata" )
13
13
  {
14
14
  try {
@@ -67,7 +67,7 @@ module.exports = function(RED) {
67
67
  if( msg.payload > node.threshold && node.threshold >= last )
68
68
  {
69
69
  status.fill = "green";
70
- msg.edge = "raising";
70
+ msg.edge = "rising";
71
71
  send( msg );
72
72
  }
73
73
  data[msg.topic] = msg.payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "1.4.4",
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",
@@ -26,7 +26,7 @@
26
26
  "negate": "math_minus.js",
27
27
  "reduce": "math_reduce.js",
28
28
  "fallingEdge": "math_falling.js",
29
- "raisingEdge": "math_raising.js",
29
+ "raisingEdge": "math_rising.js",
30
30
  "hysteresisEdge": "math_hysteresis.js",
31
31
  "statistics": "math_statistics.js",
32
32
  "mean": "math_mean.js"