@mschaeffler/node-red-logic 3.10.1 → 3.11.2

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
@@ -48,7 +48,7 @@
48
48
  </div>
49
49
  <div class="form-row">
50
50
  <label for="node-input-minData"><i class="fa fa-tag"></i> min. Data</label>
51
- <input type="text" id="node-input-minData">
51
+ <input type="number" id="node-input-minData">
52
52
  </div>
53
53
  <div class="form-row">
54
54
  <label for="node-input-filter"><i class="fa fa-filter"></i> Filter</label>
package/logic_or.html CHANGED
@@ -48,7 +48,7 @@
48
48
  </div>
49
49
  <div class="form-row">
50
50
  <label for="node-input-minData"><i class="fa fa-tag"></i> min. Data</label>
51
- <input type="text" id="node-input-minData">
51
+ <input type="number" id="node-input-minData">
52
52
  </div>
53
53
  <div class="form-row">
54
54
  <label for="node-input-filter"><i class="fa fa-filter"></i> Filter</label>
@@ -6,9 +6,13 @@
6
6
  name:{value:""},
7
7
  property:{value:"payload",required:true},
8
8
  delay:{value:"0",required:true},
9
+ delayUnit:{value:"secs"},
9
10
  minOn:{value:"0",required:true},
11
+ minOnUnit:{value:"secs"},
10
12
  maxOn:{value:"0",required:true},
13
+ maxOnUnit:{value:"secs"},
11
14
  postrun:{value:"0",required:true},
15
+ postrunUnit:{value:"secs"},
12
16
  outputOn:{value:true,required:true},
13
17
  outputOnType:{value:"bool"},
14
18
  outputOff:{value:false,required:true},
@@ -28,6 +32,22 @@
28
32
  inputLabels: 'input',
29
33
  outputLabels: 'boolean',
30
34
  oneditprepare: function() {
35
+ if( this.delayUnit === undefined )
36
+ {
37
+ $("#node-input-delayUnit").val( "msecs" );
38
+ }
39
+ if( this.minOnUnit === undefined )
40
+ {
41
+ $("#node-input-minOnUnit").val( "msecs" );
42
+ }
43
+ if( this.maxOnUnit === undefined )
44
+ {
45
+ $("#node-input-maxOnUnit").val( "msecs" );
46
+ }
47
+ if( this.postrunUnit === undefined )
48
+ {
49
+ $("#node-input-postrunUnit").val( "msecs" );
50
+ }
31
51
  $("#node-input-property").typedInput({
32
52
  type:"msg",
33
53
  types:["msg"],
@@ -45,7 +65,7 @@
45
65
  })
46
66
  }
47
67
  });
48
- </script>
68
+ </script>7
49
69
 
50
70
  <script type="text/html" data-template-name="timerelay">
51
71
  <div class="form-row">
@@ -59,19 +79,43 @@
59
79
  </div>
60
80
  <div class="form-row">
61
81
  <label for="node-input-delay"><i class="fa fa-play"></i> Delay</label>
62
- <input type="text" id="node-input-delay">
82
+ <input type="text" id="node-input-delay" style="width:70px;" placeholder="Time">
83
+ <select id="node-input-delayUnit" style="width:140px;">
84
+ <option value="msecs">MilliSeconds</option>
85
+ <option value="secs">Seconds</option>
86
+ <option value="mins">Minutes</option>
87
+ <option value="hours">Hours</option>
88
+ </select>
63
89
  </div>
64
90
  <div class="form-row">
65
91
  <label for="node-input-postrun"><i class="fa fa-stop"></i> Postrun</label>
66
- <input type="text" id="node-input-postrun">
92
+ <input type="text" id="node-input-postrun" style="width:70px;" placeholder="Time">
93
+ <select id="node-input-postrunUnit" style="width:140px;">
94
+ <option value="msecs">MilliSeconds</option>
95
+ <option value="secs">Seconds</option>
96
+ <option value="mins">Minutes</option>
97
+ <option value="hours">Hours</option>
98
+ </select>
67
99
  </div>
68
100
  <div class="form-row">
69
101
  <label for="node-input-minOn"><i class="fa fa-hourglass-start"></i> min on time</label>
70
- <input type="text" id="node-input-minOn">
102
+ <input type="text" id="node-input-minOn" style="width:70px;" placeholder="Time">
103
+ <select id="node-input-minOnUnit" style="width:140px;">
104
+ <option value="msecs">MilliSeconds</option>
105
+ <option value="secs">Seconds</option>
106
+ <option value="mins">Minutes</option>
107
+ <option value="hours">Hours</option>
108
+ </select>
71
109
  </div>
72
110
  <div class="form-row">
73
111
  <label for="node-input-maxOn"><i class="fa fa-hourglass-end"></i> max on time</label>
74
- <input type="text" id="node-input-maxOn">
112
+ <input type="text" id="node-input-maxOn" style="width:70px;" placeholder="Time">
113
+ <select id="node-input-maxOnUnit" style="width:140px;">
114
+ <option value="msecs">MilliSeconds</option>
115
+ <option value="secs">Seconds</option>
116
+ <option value="mins">Minutes</option>
117
+ <option value="hours">Hours</option>
118
+ </select>
75
119
  </div>
76
120
  <div class="form-row">
77
121
  <label for="node-input-outputOn"><i class="fa fa-sign-out"></i> on Output</label>
@@ -6,12 +6,12 @@ module.exports = function(RED) {
6
6
  //this.config = config;
7
7
  var node = this;
8
8
  this.property = config.property || "payload";
9
- this.delay = Number( config.delay ?? 0 );
10
- this.postrun = Number( config.postrun ?? 0 );
11
- this.minOn = Number( config.minOn ?? 0 );
12
- this.maxOn = Number( config.maxOn ?? 0 );
13
- this.outputOn = tools.convertTypedInput( config.outputOn ?? "true", config.outputOnType ?? "bool" );
14
- this.outputOff = tools.convertTypedInput( config.outputOff ?? "false",config.outputOffType ?? "bool" );
9
+ this.delay = Number( config.delay ?? 0 ) * tools.timeUnits( config.delayUnit );
10
+ this.postrun = Number( config.postrun ?? 0 ) * tools.timeUnits( config.postrunUnit );
11
+ this.minOn = Number( config.minOn ?? 0 ) * tools.timeUnits( config.minOnUnit );
12
+ this.maxOn = Number( config.maxOn ?? 0 ) * tools.timeUnits( config.maxOnUnit );
13
+ this.outputOn = RED.util.evaluateNodeProperty( config.outputOn ?? "true", config.outputOnType ?? "bool" );
14
+ this.outputOff = RED.util.evaluateNodeProperty( config.outputOff ?? "false",config.outputOffType ?? "bool" );
15
15
  this.showState = Boolean( config.showState );
16
16
  this.state = null;
17
17
  this.last = null;
package/math_falling.html CHANGED
@@ -4,6 +4,7 @@
4
4
  color: "#C0DEED",
5
5
  defaults: {
6
6
  name:{value:""},
7
+ topic:{value:""},
7
8
  property:{value:"payload",required:true},
8
9
  propertyType:{value:"msg"},
9
10
  threshold:{value:"",required:true,validate:RED.validators.number()},
@@ -44,6 +45,10 @@
44
45
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
45
46
  <input type="text" id="node-input-name" placeholder="Name">
46
47
  </div>
48
+ <div class="form-row">
49
+ <label for="node-input-topic"><i class="fa fa-envelope-o"></i> Topic</label>
50
+ <input type="text" id="node-input-topic" placeholder="Topic">
51
+ </div>
47
52
  <div class="form-row">
48
53
  <label for="node-input-property"><i class="fa fa-ellipsis-h"></i> Eigenschaft</label>
49
54
  <input type="text" id="node-input-property">
@@ -92,6 +97,8 @@
92
97
  <h3>Parameter</h3>
93
98
 
94
99
  <dl class="message-properties">
100
+ <dt>Topic <span class="property-type">string</span></dt>
101
+ <dd> defines the topic for the output message, "" is <code>msg.topic</code>.</dd>
95
102
  <dt>Property <span class="property-type">string</span></dt>
96
103
  <dd> defines the message property to be used as payload.</dd>
97
104
  <dt>Threshold <span class="property-type">number</span></dt>
package/math_falling.js CHANGED
@@ -6,11 +6,12 @@ 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
10
  this.property = config.property ?? "payload";
10
11
  this.propertyType = config.propertyType ?? "msg";
11
12
  this.threshold = Number( config.threshold );
12
13
  this.consecutive = Number( config.consecutive ?? 1 );
13
- this.output = tools.convertTypedInput( config.output ?? "true", config.outputType ?? "bool" );
14
+ this.output = RED.util.evaluateNodeProperty( config.output ?? "true", config.outputType ?? "bool" );
14
15
  this.showState = Boolean( config.showState );
15
16
  if( this.propertyType === "jsonata" )
16
17
  {
@@ -66,6 +67,10 @@ module.exports = function(RED) {
66
67
 
67
68
  if( ! isNaN( msg.value ) )
68
69
  {
70
+ if( node.topic )
71
+ {
72
+ msg.topic = node.topic;
73
+ }
69
74
  let data = context.get( "data" ) ?? {};
70
75
  const last = data[msg.topic] ?? Number.MIN_SAFE_INTEGER;
71
76
  if( msg.value < node.threshold && node.threshold <= last )
@@ -73,10 +78,10 @@ module.exports = function(RED) {
73
78
  if( ++node.cntFall >= node.consecutive )
74
79
  {
75
80
  status.fill = "green";
81
+ data[msg.topic] = msg.value;
76
82
  msg.payload = node.output;
77
83
  msg.edge = "falling";
78
84
  send( msg );
79
- data[msg.topic] = msg.value;
80
85
  node.cntFall = 0;
81
86
  }
82
87
  else
@@ -4,6 +4,7 @@
4
4
  color: "#C0DEED",
5
5
  defaults: {
6
6
  name:{value:""},
7
+ topic:{value:""},
7
8
  property:{value:"payload",required:true},
8
9
  propertyType:{value:"msg"},
9
10
  threshold_raise:{value:"",required:true,validate:RED.validators.number()},
@@ -57,6 +58,10 @@
57
58
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
58
59
  <input type="text" id="node-input-name" placeholder="Name">
59
60
  </div>
61
+ <div class="form-row">
62
+ <label for="node-input-topic"><i class="fa fa-envelope-o"></i> Topic</label>
63
+ <input type="text" id="node-input-topic" placeholder="Topic">
64
+ </div>
60
65
  <div class="form-row">
61
66
  <label for="node-input-input"><i class="fa fa-ellipsis-h"></i> Eigenschaft</label>
62
67
  <input type="text" id="node-input-property">
@@ -137,6 +142,8 @@
137
142
  <h3>Parameter</h3>
138
143
 
139
144
  <dl class="message-properties">
145
+ <dt>Topic <span class="property-type">string</span></dt>
146
+ <dd> defines the topic for the output message, "" is <code>msg.topic</code>.</dd>
140
147
  <dt>Property <span class="property-type">string</span></dt>
141
148
  <dd> defines the message property to be used as payload.</dd>
142
149
  <dt>up Threshold <span class="property-type">number</span></dt>
@@ -6,14 +6,15 @@ 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
10
  this.property = config.property ?? "payload";
10
11
  this.propertyType = config.propertyType ?? "msg";
11
12
  this.threshold_rise = Number( config.threshold_raise );
12
13
  this.threshold_fall = Number( config.threshold_fall );
13
14
  this.consecutiveRise= Number( config.consecutive ?? 1 );
14
15
  this.consecutiveFall= Number( config.consecutiveFall ?? 1 );
15
- this.outputRise = tools.convertTypedInput( config.outputRise ?? "true", config.outputRiseType ?? "bool" );
16
- this.outputFall = tools.convertTypedInput( config.outputFall ?? "false",config.outputFallType ?? "bool" );
16
+ this.outputRise = RED.util.evaluateNodeProperty( config.outputRise ?? "true", config.outputRiseType ?? "bool" );
17
+ this.outputFall = RED.util.evaluateNodeProperty( config.outputFall ?? "false",config.outputFallType ?? "bool" );
17
18
  this.noInit = Boolean( config.noInit );
18
19
  this.showState = Boolean( config.showState );
19
20
  if( this.propertyType === "jsonata" )
@@ -52,7 +53,7 @@ module.exports = function(RED) {
52
53
  {
53
54
  for( const i in data )
54
55
  {
55
- let help ={ topic: i, query: true };
56
+ let help = { topic: i, query: true };
56
57
  msgSetEdge( help, data[i].edge );
57
58
  send( help );
58
59
  }
@@ -84,6 +85,10 @@ module.exports = function(RED) {
84
85
  getPayload( function(value)
85
86
  {
86
87
  msg.value = Number( value );
88
+ if( node.topic )
89
+ {
90
+ msg.topic = node.topic;
91
+ }
87
92
  let status = { fill:data[msg.topic]?.status??"gray", shape:"dot", text:tools.formatNumber( msg.value ) };
88
93
 
89
94
  if( ! isNaN( msg.value ) )
package/math_mean.html CHANGED
@@ -10,10 +10,12 @@
10
10
  deltaTime:{value:"60", required:true, validate:function(v){
11
11
  return v!=='' && !isNaN(v) && Number(v)>0;}
12
12
  },
13
+ deltaUnit:{value:"secs"},
13
14
  minData:{value:"1", required:true, validate:function(v){
14
15
  return v!=='' && !isNaN(v) && Number(v)>0;}
15
16
  },
16
17
  filter:{value:0, validate:RED.validators.number()},
18
+ filterUnit:{value:"secs"},
17
19
  filterVal:{value:0, validate:RED.validators.number()},
18
20
  filterMul:{value:10, validate:RED.validators.number()},
19
21
  zeroIsZero:{value:false},
@@ -24,7 +26,7 @@
24
26
  outputs:1,
25
27
  icon:"smooth.png",
26
28
  label: function() {
27
- return this.name||"mean";
29
+ return this.name||this.topic||"mean";
28
30
  },
29
31
  labelStyle: function() {
30
32
  return this.name?"node_label_italic":"";
@@ -32,6 +34,14 @@
32
34
  inputLabels: 'input',
33
35
  outputLabels: 'output',
34
36
  oneditprepare: function() {
37
+ if( this.deltaUnit === undefined )
38
+ {
39
+ $("#node-input-deltaUnit").val( "secs" );
40
+ }
41
+ if( this.filterUnit === undefined )
42
+ {
43
+ $("#node-input-filterUnit").val( "secs" );
44
+ }
35
45
  $("#node-input-property").typedInput({
36
46
  type:"msg",
37
47
  types:["msg","jsonata"],
@@ -57,15 +67,27 @@
57
67
  </div>
58
68
  <div class="form-row">
59
69
  <label for="node-input-minMean"><i class="fa fa-hourglass-o"></i> Zeitspanne</label>
60
- <input type="text" id="node-input-deltaTime">
70
+ <input type="text" id="node-input-deltaTime" style="width:70px;" placeholder="Time">
71
+ <select id="node-input-deltaUnit" style="width:140px;">
72
+ <option value="msecs">MilliSeconds</option>
73
+ <option value="secs">Seconds</option>
74
+ <option value="mins">Minutes</option>
75
+ <option value="hours">Hours</option>
76
+ </select>
61
77
  </div>
62
78
  <div class="form-row">
63
79
  <label for="node-input-minData"><i class="fa fa-check-square-o"></i> min. Data</label>
64
- <input type="text" id="node-input-minData">
80
+ <input type="number" id="node-input-minData">
65
81
  </div>
66
82
  <div class="form-row">
67
83
  <label for="node-input-filter"><i class="fa fa-filter"></i> Filterzeit</label>
68
- <input type="number" id="node-input-filter">
84
+ <input type="number" id="node-input-filter" style="width:70px;" placeholder="Time">
85
+ <select id="node-input-filterUnit" style="width:140px;">
86
+ <option value="msecs">MilliSeconds</option>
87
+ <option value="secs">Seconds</option>
88
+ <option value="mins">Minutes</option>
89
+ <option value="hours">Hours</option>
90
+ </select>
69
91
  </div>
70
92
  <div class="form-row">
71
93
  <label for="node-input-filterVal"><i class="fa fa-filter"></i> Filter Wert</label>
package/math_mean.js CHANGED
@@ -9,9 +9,9 @@ module.exports = function(RED) {
9
9
  this.topic = config.topic || "";
10
10
  this.property = config.property || "payload";
11
11
  this.propertyType = config.propertyType ?? "msg";
12
- this.deltaTime = Number( config.deltaTime ?? 60 )*1000;
12
+ this.deltaTime = Number( config.deltaTime ?? 60 ) * tools.timeUnits( config.deltaUnit );
13
13
  this.minData = Number( config.minData ?? 1 );
14
- this.filterTime = Number( config.filter ?? 0 )*1000;
14
+ this.filterTime = Number( config.filter ?? 0 ) * tools.timeUnits( config.filterUnit );
15
15
  this.filterValue = Number( config.filterVal ?? 0 );
16
16
  this.filterLongTime = this.filterTime * Number( config.filterMul ?? 10 );
17
17
  this.zeroIsZero = Boolean( config.zeroIsZero );
@@ -138,7 +138,11 @@ module.exports = function(RED) {
138
138
  }
139
139
  else
140
140
  {
141
- node.status({fill:"red",shape:"dot",text:"payload is NaN"});
141
+ if( value !== undefined )
142
+ {
143
+ node.status({fill:"red",shape:"dot",text:"payload is NaN"});
144
+ node.warn( `payload is NaN (${msg.topic}=${value})` );
145
+ }
142
146
  }
143
147
  done();
144
148
  } );
package/math_reduce.html CHANGED
@@ -68,15 +68,15 @@
68
68
  </div>
69
69
  <div class="form-row">
70
70
  <label for="node-input-minMean"><i class="fa fa-hourglass-o"></i> min. Mean</label>
71
- <input type="text" id="node-input-minMean">
71
+ <input type="number" id="node-input-minMean">
72
72
  </div>
73
73
  <div class="form-row">
74
74
  <label for="node-input-maxMean"><i class="fa fa-hourglass"></i> max. Mean</label>
75
- <input type="text" id="node-input-maxMean">
75
+ <input type="number" id="node-input-maxMean">
76
76
  </div>
77
77
  <div class="form-row">
78
78
  <label for="node-input-minData"><i class="fa fa-check-square-o "></i> min. Data</label>
79
- <input type="text" id="node-input-minData">
79
+ <input type="number" id="node-input-minData">
80
80
  </div>
81
81
  <div class="form-row">
82
82
  <label for="node-input-algo"><i class="fa fa-flask"></i> Algorithm</label>
package/math_rising.html CHANGED
@@ -4,9 +4,10 @@
4
4
  color: "#C0DEED",
5
5
  defaults: {
6
6
  name:{value:""},
7
+ topic:{value:""},
7
8
  property:{value:"payload",required:true},
8
9
  propertyType:{value:"msg"},
9
- threshold:{value:1,required:true,validate:RED.validators.number()},
10
+ threshold:{value:"",required:true,validate:RED.validators.number()},
10
11
  consecutive:{value:1,required:true,validate:RED.validators.number()},
11
12
  output:{value:true,required:true},
12
13
  outputType:{value:"bool"},
@@ -44,6 +45,10 @@
44
45
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
45
46
  <input type="text" id="node-input-name" placeholder="Name">
46
47
  </div>
48
+ <div class="form-row">
49
+ <label for="node-input-topic"><i class="fa fa-envelope-o"></i> Topic</label>
50
+ <input type="text" id="node-input-topic" placeholder="Topic">
51
+ </div>
47
52
  <div class="form-row">
48
53
  <label for="node-input-property"><i class="fa fa-ellipsis-h"></i> Eigenschaft</label>
49
54
  <input type="text" id="node-input-property">
@@ -92,6 +97,8 @@
92
97
  <h3>Parameter</h3>
93
98
 
94
99
  <dl class="message-properties">
100
+ <dt>Topic <span class="property-type">string</span></dt>
101
+ <dd> defines the topic for the output message, "" is <code>msg.topic</code>.</dd>
95
102
  <dt>Property <span class="property-type">string</span></dt>
96
103
  <dd> defines the message property to be used as payload.</dd>
97
104
  <dt>Threshold <span class="property-type">number</span></dt>
package/math_rising.js CHANGED
@@ -6,11 +6,12 @@ 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
10
  this.property = config.property ?? "payload";
10
11
  this.propertyType = config.propertyType ?? "msg";
11
12
  this.threshold = Number( config.threshold );
12
13
  this.consecutive = Number( config.consecutive ?? 1 );
13
- this.output = tools.convertTypedInput( config.output ?? "true", config.outputType ?? "bool" );
14
+ this.output = RED.util.evaluateNodeProperty( config.output ?? "true", config.outputType ?? "bool" );
14
15
  this.showState = Boolean( config.showState );
15
16
  if( this.propertyType === "jsonata" )
16
17
  {
@@ -67,6 +68,10 @@ module.exports = function(RED) {
67
68
 
68
69
  if( ! isNaN( msg.value ) )
69
70
  {
71
+ if( node.topic )
72
+ {
73
+ msg.topic = node.topic;
74
+ }
70
75
  let data = context.get( "data" ) ?? {};
71
76
  const last = data[msg.topic] ?? Number.MAX_SAFE_INTEGER;
72
77
  if( msg.value > node.threshold && node.threshold >= last )
@@ -74,10 +79,10 @@ module.exports = function(RED) {
74
79
  if( ++node.cntRise >= node.consecutive )
75
80
  {
76
81
  status.fill = "green";
82
+ data[msg.topic] = msg.value;
77
83
  msg.payload = node.output;
78
84
  msg.edge = "rising";
79
85
  send( msg );
80
- data[msg.topic] = msg.value;
81
86
  node.cntRise = 0;
82
87
  }
83
88
  else
@@ -9,6 +9,7 @@
9
9
  deltaTime:{value:"60", required:true, validate:function(v){
10
10
  return v!=='' && !isNaN(v) && Number(v)>0;}
11
11
  },
12
+ deltaUnit:{value:"secs"},
12
13
  minData:{value:"1", required:true, validate:function(v){
13
14
  return v!=='' && !isNaN(v) && Number(v)>0;}
14
15
  },
@@ -28,6 +29,10 @@
28
29
  outputLabels: 'output',
29
30
  oneditprepare: function() {
30
31
  const node = this;
32
+ if( this.deltaUnit === undefined )
33
+ {
34
+ $("#node-input-deltaUnit").val( "secs" );
35
+ }
31
36
  $("#node-input-property").typedInput({
32
37
  type:"msg",
33
38
  types:["msg","jsonata"],
@@ -62,11 +67,17 @@
62
67
  </div>
63
68
  <div class="form-row">
64
69
  <label for="node-input-minMean"><i class="fa fa-hourglass-o"></i> Zeitspanne</label>
65
- <input type="text" id="node-input-deltaTime">
70
+ <input type="text" id="node-input-deltaTime" style="width:70px;" placeholder="Time">
71
+ <select id="node-input-deltaUnit" style="width:140px;">
72
+ <option value="msecs">MilliSeconds</option>
73
+ <option value="secs">Seconds</option>
74
+ <option value="mins">Minutes</option>
75
+ <option value="hours">Hours</option>
76
+ </select>
66
77
  </div>
67
78
  <div class="form-row">
68
79
  <label for="node-input-minData"><i class="fa fa-check-square-o "></i> min. Data</label>
69
- <input type="text" id="node-input-minData">
80
+ <input type="number" id="node-input-minData">
70
81
  </div>
71
82
  <div class="form-row">
72
83
  <label for="node-input-contextStore"><i class="fa fa-database"></i> Contextstore</label>
@@ -8,7 +8,7 @@ module.exports = function(RED) {
8
8
  var context = this.context();
9
9
  this.property = config.property || "payload";
10
10
  this.propertyType = config.propertyType ?? "msg";
11
- this.deltaTime = Number( config.deltaTime ?? 60 )*1000;
11
+ this.deltaTime = Number( config.deltaTime ?? 60 ) * tools.timeUnits( config.deltaUnit );
12
12
  this.minData = Number( config.minData ?? 1 );
13
13
  this.contextStore = config.contextStore ?? "none";
14
14
  this.showState = Boolean( config.showState );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "3.10.1",
3
+ "version": "3.11.2",
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",
package/tools.js CHANGED
@@ -58,21 +58,6 @@ exports.getPayload = function(node,msg,callback)
58
58
  }
59
59
  }
60
60
 
61
- exports.convertTypedInput = function(value,type)
62
- {
63
- switch( type )
64
- {
65
- case "num":
66
- return Number( value );
67
- case "bool":
68
- return exports.property2boolean( value );
69
- case "json":
70
- return JSON.parse( value );
71
- default:
72
- return value;
73
- }
74
- }
75
-
76
61
  exports.distance = function(a,b)
77
62
  {
78
63
  return a>b ? a-b : b-a;
@@ -82,3 +67,18 @@ exports.formatNumber = function(value)
82
67
  {
83
68
  return value > 5000 ? value.toFixed( 0 ) : value.toPrecision( 4 );
84
69
  }
70
+
71
+ exports.timeUnits = function(unit)
72
+ {
73
+ switch( unit ?? "secs" )
74
+ {
75
+ case "secs":
76
+ return 1000;
77
+ case "mins":
78
+ return 1000 * 60;
79
+ case "hours":
80
+ return 1000 * 60 * 60;
81
+ default:
82
+ return 1;
83
+ }
84
+ }