@mschaeffler/node-red-logic 3.8.0 → 3.9.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.
@@ -24,7 +24,7 @@ module.exports = function(RED) {
24
24
 
25
25
  function setStatus(color,text)
26
26
  {
27
- console.log( text );
27
+ //console.log( text );
28
28
  if( node.showState )
29
29
  {
30
30
  node.status( { text:text, shape:"dot", fill:color } );
@@ -127,7 +127,7 @@ module.exports = function(RED) {
127
127
  }
128
128
  else
129
129
  {
130
- console.log("error")
130
+ //console.log("error")
131
131
  setStatus( "red", "error" );
132
132
  }
133
133
  done();
package/math_mean.html CHANGED
@@ -16,6 +16,7 @@
16
16
  filterVal:{value:0, validate:RED.validators.number()},
17
17
  filterMul:{value:10, validate:RED.validators.number()},
18
18
  zeroIsZero:{value:false},
19
+ decimals:{validate:RED.validators.number()},
19
20
  showState:{value:false}
20
21
  },
21
22
  inputs:1,
@@ -54,21 +55,25 @@
54
55
  <input type="text" id="node-input-deltaTime">
55
56
  </div>
56
57
  <div class="form-row">
57
- <label for="node-input-minData"><i class="fa fa-check-square-o "></i> min. Data</label>
58
+ <label for="node-input-minData"><i class="fa fa-check-square-o"></i> min. Data</label>
58
59
  <input type="text" id="node-input-minData">
59
60
  </div>
60
61
  <div class="form-row">
61
- <label for="node-input-filter"><i class="fa fa-filter "></i> Filterzeit</label>
62
+ <label for="node-input-filter"><i class="fa fa-filter"></i> Filterzeit</label>
62
63
  <input type="number" id="node-input-filter">
63
64
  </div>
64
65
  <div class="form-row">
65
- <label for="node-input-filterVal"><i class="fa fa-filter "></i> Filter Wert</label>
66
+ <label for="node-input-filterVal"><i class="fa fa-filter"></i> Filter Wert</label>
66
67
  <input type="text" id="node-input-filterVal">
67
68
  </div>
68
69
  <div class="form-row">
69
- <label for="node-input-filterMul"><i class="fa fa-filter "></i> Filter Wiederholungsfaktor</label>
70
+ <label for="node-input-filterMul"><i class="fa fa-filter"></i> Filter Wiederholungsfaktor</label>
70
71
  <input type="text" id="node-input-filterMul">
71
72
  </div>
73
+ <div class="form-row">
74
+ <label for="node-input-decimals"><i class="fa fa-sort-numeric-asc"></i> Nachkommastellen</label>
75
+ <input type="text" id="node-input-decimals">
76
+ </div>
72
77
  <div class="form-row">
73
78
  <label for="node-input-zeroIsZero"><i class="fa fa-exclamation-circle"></i> Null ist Null</label>
74
79
  <input type="checkbox" id="node-input-zeroIsZero" style="display:inline-block; width:20px; vertical-align:baseline;">
@@ -118,6 +123,8 @@
118
123
  <dd> send output only if change is bigger.</dd>
119
124
  <dt>Filter Wiederholungsfaktor <span class="property-type">number</span></dt>
120
125
  <dd> do send output if change is lower then <code>Filter Wert</code> after n times <code>Filterzeit</code>.</dd>
126
+ <dt>Nachkommastellen <span class="property-type">number</span></dt>
127
+ <dd> Anzahl an Nachkommastellen..</dd>
121
128
  <dt>Null ist NUll <span class="property-type">boolean</span></dt>
122
129
  <dd> If 0 is received, 0 is send immediately.</dd>
123
130
  <dt>Status <span class="property-type">boolean</span></dt>
package/math_mean.js CHANGED
@@ -14,6 +14,7 @@ module.exports = function(RED) {
14
14
  this.filterValue = Number( config.filterVal ?? 0 );
15
15
  this.filterLongTime = this.filterTime * Number( config.filterMul ?? 10 );
16
16
  this.zeroIsZero = Boolean( config.zeroIsZero );
17
+ this.round = config.decimals ? Math.pow( 10, Number( config.decimals ) ) : null;
17
18
  this.showState = Boolean( config.showState );
18
19
  if( this.propertyType === "jsonata" )
19
20
  {
@@ -109,11 +110,15 @@ module.exports = function(RED) {
109
110
  sum += value.value;
110
111
  }
111
112
  const help = last[msg.topic];
112
- const value = sum/item.length;
113
+ let value = sum/item.length;
113
114
  if( help === undefined ||
114
115
  ( help.time + node.filterTime < now && tools.distance( help.value, value ) >= node.filterValue ) ||
115
116
  ( node.filterLongTime > 0 && help.time + node.filterLongTime < now ) )
116
117
  {
118
+ if( node.round )
119
+ {
120
+ value = Math.round( value * node.round ) / node.round;
121
+ }
117
122
  sendValue( value, item.length );
118
123
  }
119
124
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "3.8.0",
3
+ "version": "3.9.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",