@mschaeffler/node-red-logic 3.5.0 → 3.6.1
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/math_hysteresis.html +7 -0
- package/math_hysteresis.js +8 -4
- package/math_mean.js +2 -2
- package/math_reduce.js +2 -1
- package/math_statistics.js +2 -1
- package/package.json +1 -1
- package/tools.js +5 -0
package/math_hysteresis.html
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
outputRiseType:{value:"bool"},
|
|
18
18
|
outputFall:{value:false,required:true},
|
|
19
19
|
outputFallType:{value:"bool"},
|
|
20
|
+
noInit:{value:false},
|
|
20
21
|
showState:{value:false}
|
|
21
22
|
},
|
|
22
23
|
inputs:1,
|
|
@@ -87,6 +88,10 @@
|
|
|
87
88
|
<input type="text" id="node-input-outputFall">
|
|
88
89
|
<input type="hidden" id="node-input-outputFallType">
|
|
89
90
|
</div>
|
|
91
|
+
<div class="form-row">
|
|
92
|
+
<label for="node-input-noInit"><i class="fa fa-play"></i> no inits</label>
|
|
93
|
+
<input type="checkbox" id="node-input-noInit" style="display:inline-block; width:20px; vertical-align:baseline;">
|
|
94
|
+
</div>
|
|
90
95
|
<div class="form-row">
|
|
91
96
|
<label for="node-input-showStatus"><i class="fa fa-star-o"></i> Status</label>
|
|
92
97
|
<input type="checkbox" id="node-input-showState" style="display:inline-block; width:20px; vertical-align:baseline;">
|
|
@@ -146,6 +151,8 @@
|
|
|
146
151
|
<dd> Value to be sent in case of a rising edge.</dd>
|
|
147
152
|
<dt>fall Output <span class="property-type">multi</span></dt>
|
|
148
153
|
<dd> Value to be sent in case of a falling edge.</dd>
|
|
154
|
+
<dt>no init <span class="property-type">boolean</span></dt>
|
|
155
|
+
<dd> does not send init messages.</dd>
|
|
149
156
|
<dt>Status <span class="property-type">boolean</span></dt>
|
|
150
157
|
<dd> shows the actual value as a node status.</dd>
|
|
151
158
|
</dl>
|
package/math_hysteresis.js
CHANGED
|
@@ -14,6 +14,7 @@ module.exports = function(RED) {
|
|
|
14
14
|
this.consecutiveFall= Number( config.consecutiveFall ?? 1 );
|
|
15
15
|
this.outputRise = tools.convertTypedInput( config.outputRise ?? "true", config.outputRiseType ?? "bool" );
|
|
16
16
|
this.outputFall = tools.convertTypedInput( config.outputFall ?? "false",config.outputFallType ?? "bool" );
|
|
17
|
+
this.noInit = Boolean( config.noInit );
|
|
17
18
|
this.showState = Boolean( config.showState );
|
|
18
19
|
if( this.propertyType === "jsonata" )
|
|
19
20
|
{
|
|
@@ -83,7 +84,7 @@ module.exports = function(RED) {
|
|
|
83
84
|
getPayload( function(value)
|
|
84
85
|
{
|
|
85
86
|
msg.value = Number( value );
|
|
86
|
-
let status = { fill:data[msg.topic]?.status??"gray", shape:"dot", text:msg.value
|
|
87
|
+
let status = { fill:data[msg.topic]?.status??"gray", shape:"dot", text:tools.formatNumber( msg.value ) };
|
|
87
88
|
|
|
88
89
|
if( ! isNaN( msg.value ) )
|
|
89
90
|
{
|
|
@@ -94,9 +95,12 @@ module.exports = function(RED) {
|
|
|
94
95
|
status.fill = edge ? "red" : "blue";
|
|
95
96
|
data[msg.topic] = { edge:edge, status:status.fill };
|
|
96
97
|
context.set( "data", data );
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
if( last !== undefined || ! node.noInit )
|
|
99
|
+
{
|
|
100
|
+
msgSetEdge( msg, edge );
|
|
101
|
+
msg.init = last === undefined;
|
|
102
|
+
send( msg );
|
|
103
|
+
}
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
if( msg.value > node.threshold_rise && last !== true )
|
package/math_mean.js
CHANGED
|
@@ -93,7 +93,7 @@ module.exports = function(RED) {
|
|
|
93
93
|
msg.count = count;
|
|
94
94
|
last[msg.topic] = {value:value,time:now};
|
|
95
95
|
context.set( "last", last );
|
|
96
|
-
node.status({fill:"green",shape:"dot",text:`${item.length} / ${
|
|
96
|
+
node.status({fill:"green",shape:"dot",text:`${item.length} / ${tools.formatNumber(value)}`});
|
|
97
97
|
send( msg );
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -118,7 +118,7 @@ module.exports = function(RED) {
|
|
|
118
118
|
}
|
|
119
119
|
else
|
|
120
120
|
{
|
|
121
|
-
node.status({fill:"gray",shape:"dot",text:`${item.length} / ${
|
|
121
|
+
node.status({fill:"gray",shape:"dot",text:`${item.length} / ${tools.formatNumber(value)}`});
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
else
|
package/math_reduce.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
module.exports = function(RED) {
|
|
2
|
+
var tools = require('./tools.js');
|
|
2
3
|
|
|
3
4
|
function ReduceNode(config) {
|
|
4
5
|
RED.nodes.createNode(this,config);
|
|
@@ -112,7 +113,7 @@ module.exports = function(RED) {
|
|
|
112
113
|
{
|
|
113
114
|
case "mean": msg.payload /= msg.count; break;
|
|
114
115
|
}
|
|
115
|
-
status.text = msg.payload
|
|
116
|
+
status.text = tools.formatNumber( msg.payload );
|
|
116
117
|
if( node.filter )
|
|
117
118
|
{
|
|
118
119
|
if( msg.payload !== node.last )
|
package/math_statistics.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
module.exports = function(RED) {
|
|
2
|
+
var tools = require('./tools.js');
|
|
2
3
|
|
|
3
4
|
function StatsNode(config) {
|
|
4
5
|
RED.nodes.createNode(this,config);
|
|
@@ -103,7 +104,7 @@ module.exports = function(RED) {
|
|
|
103
104
|
msg.stat.variation = msg.stat.deviation / msg.stat.average;
|
|
104
105
|
if( node.showState )
|
|
105
106
|
{
|
|
106
|
-
node.status({fill:"green",shape:"dot",text:`${msg.stat.count} / ${msg.stat.deviation
|
|
107
|
+
node.status({fill:"green",shape:"dot",text:`${msg.stat.count} / ${tools.formatNumber(msg.stat.deviation)}`});
|
|
107
108
|
}
|
|
108
109
|
send( msg );
|
|
109
110
|
}
|
package/package.json
CHANGED