@mschaeffler/node-red-logic 3.8.0 → 3.10.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.
- package/logic_timerelay.js +2 -2
- package/math_mean.html +18 -4
- package/math_mean.js +11 -1
- package/package.json +1 -1
package/logic_timerelay.js
CHANGED
|
@@ -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
|
@@ -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
|
deltaTime:{value:"60", required:true, validate:function(v){
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
filterVal:{value:0, validate:RED.validators.number()},
|
|
17
18
|
filterMul:{value:10, validate:RED.validators.number()},
|
|
18
19
|
zeroIsZero:{value:false},
|
|
20
|
+
decimals:{validate:RED.validators.number()},
|
|
19
21
|
showState:{value:false}
|
|
20
22
|
},
|
|
21
23
|
inputs:1,
|
|
@@ -44,6 +46,10 @@
|
|
|
44
46
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
45
47
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
46
48
|
</div>
|
|
49
|
+
<div class="form-row">
|
|
50
|
+
<label for="node-input-topic"><i class="fa fa-envelope-o"></i> Topic</label>
|
|
51
|
+
<input type="text" id="node-input-topic" placeholder="Topic">
|
|
52
|
+
</div>
|
|
47
53
|
<div class="form-row">
|
|
48
54
|
<label for="node-input-input"><i class="fa fa-ellipsis-h"></i> Eigenschaft</label>
|
|
49
55
|
<input type="text" id="node-input-property">
|
|
@@ -54,21 +60,25 @@
|
|
|
54
60
|
<input type="text" id="node-input-deltaTime">
|
|
55
61
|
</div>
|
|
56
62
|
<div class="form-row">
|
|
57
|
-
<label for="node-input-minData"><i class="fa fa-check-square-o
|
|
63
|
+
<label for="node-input-minData"><i class="fa fa-check-square-o"></i> min. Data</label>
|
|
58
64
|
<input type="text" id="node-input-minData">
|
|
59
65
|
</div>
|
|
60
66
|
<div class="form-row">
|
|
61
|
-
<label for="node-input-filter"><i class="fa fa-filter
|
|
67
|
+
<label for="node-input-filter"><i class="fa fa-filter"></i> Filterzeit</label>
|
|
62
68
|
<input type="number" id="node-input-filter">
|
|
63
69
|
</div>
|
|
64
70
|
<div class="form-row">
|
|
65
|
-
<label for="node-input-filterVal"><i class="fa fa-filter
|
|
71
|
+
<label for="node-input-filterVal"><i class="fa fa-filter"></i> Filter Wert</label>
|
|
66
72
|
<input type="text" id="node-input-filterVal">
|
|
67
73
|
</div>
|
|
68
74
|
<div class="form-row">
|
|
69
|
-
<label for="node-input-filterMul"><i class="fa fa-filter
|
|
75
|
+
<label for="node-input-filterMul"><i class="fa fa-filter"></i> Filter Wiederholungsfaktor</label>
|
|
70
76
|
<input type="text" id="node-input-filterMul">
|
|
71
77
|
</div>
|
|
78
|
+
<div class="form-row">
|
|
79
|
+
<label for="node-input-decimals"><i class="fa fa-sort-numeric-asc"></i> Nachkommastellen</label>
|
|
80
|
+
<input type="text" id="node-input-decimals">
|
|
81
|
+
</div>
|
|
72
82
|
<div class="form-row">
|
|
73
83
|
<label for="node-input-zeroIsZero"><i class="fa fa-exclamation-circle"></i> Null ist Null</label>
|
|
74
84
|
<input type="checkbox" id="node-input-zeroIsZero" style="display:inline-block; width:20px; vertical-align:baseline;">
|
|
@@ -106,6 +116,8 @@
|
|
|
106
116
|
<h3>Parameter</h3>
|
|
107
117
|
|
|
108
118
|
<dl class="message-properties">
|
|
119
|
+
<dt>Topic <span class="property-type">string</span></dt>
|
|
120
|
+
<dd> defines the topic for the output message, "" is <code>msg.topic</code>.</dd>
|
|
109
121
|
<dt>Property <span class="property-type">string</span></dt>
|
|
110
122
|
<dd> defines the message property to be used as payload.</dd>
|
|
111
123
|
<dt>Delta time <span class="property-type">number</span></dt>
|
|
@@ -118,6 +130,8 @@
|
|
|
118
130
|
<dd> send output only if change is bigger.</dd>
|
|
119
131
|
<dt>Filter Wiederholungsfaktor <span class="property-type">number</span></dt>
|
|
120
132
|
<dd> do send output if change is lower then <code>Filter Wert</code> after n times <code>Filterzeit</code>.</dd>
|
|
133
|
+
<dt>Nachkommastellen <span class="property-type">number</span></dt>
|
|
134
|
+
<dd> Anzahl an Nachkommastellen..</dd>
|
|
121
135
|
<dt>Null ist NUll <span class="property-type">boolean</span></dt>
|
|
122
136
|
<dd> If 0 is received, 0 is send immediately.</dd>
|
|
123
137
|
<dt>Status <span class="property-type">boolean</span></dt>
|
package/math_mean.js
CHANGED
|
@@ -6,6 +6,7 @@ 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.deltaTime = Number( config.deltaTime ?? 60 )*1000;
|
|
@@ -14,6 +15,7 @@ module.exports = function(RED) {
|
|
|
14
15
|
this.filterValue = Number( config.filterVal ?? 0 );
|
|
15
16
|
this.filterLongTime = this.filterTime * Number( config.filterMul ?? 10 );
|
|
16
17
|
this.zeroIsZero = Boolean( config.zeroIsZero );
|
|
18
|
+
this.round = config.decimals ? Math.pow( 10, Number( config.decimals ) ) : null;
|
|
17
19
|
this.showState = Boolean( config.showState );
|
|
18
20
|
if( this.propertyType === "jsonata" )
|
|
19
21
|
{
|
|
@@ -89,6 +91,10 @@ module.exports = function(RED) {
|
|
|
89
91
|
|
|
90
92
|
function sendValue(value,count)
|
|
91
93
|
{
|
|
94
|
+
if( node.topic )
|
|
95
|
+
{
|
|
96
|
+
msg.topic = node.topic;
|
|
97
|
+
}
|
|
92
98
|
msg.payload = value;
|
|
93
99
|
msg.count = count;
|
|
94
100
|
last[msg.topic] = {value:value,time:now};
|
|
@@ -109,11 +115,15 @@ module.exports = function(RED) {
|
|
|
109
115
|
sum += value.value;
|
|
110
116
|
}
|
|
111
117
|
const help = last[msg.topic];
|
|
112
|
-
|
|
118
|
+
let value = sum/item.length;
|
|
113
119
|
if( help === undefined ||
|
|
114
120
|
( help.time + node.filterTime < now && tools.distance( help.value, value ) >= node.filterValue ) ||
|
|
115
121
|
( node.filterLongTime > 0 && help.time + node.filterLongTime < now ) )
|
|
116
122
|
{
|
|
123
|
+
if( node.round )
|
|
124
|
+
{
|
|
125
|
+
value = Math.round( value * node.round ) / node.round;
|
|
126
|
+
}
|
|
117
127
|
sendValue( value, item.length );
|
|
118
128
|
}
|
|
119
129
|
else
|
package/package.json
CHANGED