@mschaeffler/node-red-logic 3.13.0 → 4.0.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_bool.html +8 -1
- package/logic_bool.js +5 -0
- package/math_hysteresis.html +0 -14
- package/math_hysteresis.js +2 -29
- package/package.json +1 -1
package/logic_bool.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
|
showState:{value:false},
|
|
9
10
|
filter:{value:false}
|
|
@@ -12,7 +13,7 @@
|
|
|
12
13
|
outputs:1,
|
|
13
14
|
icon: "font-awesome/fa-check-square-o",
|
|
14
15
|
label: function() {
|
|
15
|
-
return this.name||"to bool";
|
|
16
|
+
return this.name||this.topic||"to bool";
|
|
16
17
|
},
|
|
17
18
|
labelStyle: function() {
|
|
18
19
|
return this.name?"node_label_italic":"";
|
|
@@ -35,6 +36,10 @@
|
|
|
35
36
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
36
37
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
37
38
|
</div>
|
|
39
|
+
<div class="form-row">
|
|
40
|
+
<label for="node-input-topic"><i class="fa fa-envelope-o"></i> Topic</label>
|
|
41
|
+
<input type="text" id="node-input-topic" placeholder="Topic">
|
|
42
|
+
</div>
|
|
38
43
|
<div class="form-row">
|
|
39
44
|
<label for="node-input-input"><i class="fa fa-ellipsis-h"></i> Eigenschaft</label>
|
|
40
45
|
<input type="text" id="node-input-property">
|
|
@@ -88,6 +93,8 @@
|
|
|
88
93
|
<h3>Parameter</h3>
|
|
89
94
|
|
|
90
95
|
<dl class="message-properties">
|
|
96
|
+
<dt>Topic <span class="property-type">string</span></dt>
|
|
97
|
+
<dd> defines the topic for the output message.</dd>
|
|
91
98
|
<dt>Property <span class="property-type">string</span></dt>
|
|
92
99
|
<dd> defines the message property to be used as payload.</dd>
|
|
93
100
|
<dt>Status <span class="property-type">boolean</span></dt>
|
package/logic_bool.js
CHANGED
|
@@ -5,6 +5,7 @@ module.exports = function(RED) {
|
|
|
5
5
|
RED.nodes.createNode(this,config);
|
|
6
6
|
//this.config = config;
|
|
7
7
|
var node = this;
|
|
8
|
+
this.topic = config.topic ?? "";
|
|
8
9
|
this.property = config.property || "payload";
|
|
9
10
|
this.showState = Boolean( config.showState );
|
|
10
11
|
this.filter = Boolean( config.filter );
|
|
@@ -21,6 +22,10 @@ module.exports = function(RED) {
|
|
|
21
22
|
let status = { text:msg.payload ?? "error" };
|
|
22
23
|
if( msg.payload !== null )
|
|
23
24
|
{
|
|
25
|
+
if( node.topic )
|
|
26
|
+
{
|
|
27
|
+
msg.topic = node.topic;
|
|
28
|
+
}
|
|
24
29
|
if( node.filter )
|
|
25
30
|
{
|
|
26
31
|
status.shape = "dot";
|
package/math_hysteresis.html
CHANGED
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
const raise = $("#node-input-threshold_raise").length ? $("#node-input-threshold_raise").val() : this.threshold_raise;
|
|
13
13
|
return v!=='' && !isNaN(v) && Number(v)<raise;}
|
|
14
14
|
},
|
|
15
|
-
consecutive:{value:1,required:true,validate:RED.validators.number()},
|
|
16
|
-
consecutiveFall:{value:1,required:true,validate:RED.validators.number()},
|
|
17
15
|
outputRise:{value:true,required:true},
|
|
18
16
|
outputRiseType:{value:"bool"},
|
|
19
17
|
outputFall:{value:false,required:true},
|
|
@@ -75,14 +73,6 @@
|
|
|
75
73
|
<label for="node-input-threshold_fall"><i class="fa fa-chevron-down"></i> dn threshold</label>
|
|
76
74
|
<input type="text" id="node-input-threshold_fall">
|
|
77
75
|
</div>
|
|
78
|
-
<div class="form-row">
|
|
79
|
-
<label for="node-input-consecutive"><i class="fa fa-line-chart"></i> rise Consecutive</label>
|
|
80
|
-
<input type="number" id="node-input-consecutive">
|
|
81
|
-
</div>
|
|
82
|
-
<div class="form-row">
|
|
83
|
-
<label for="node-input-consecutiveFall"><i class="fa fa-line-chart"></i> fall Consecutive</label>
|
|
84
|
-
<input type="number" id="node-input-consecutiveFall">
|
|
85
|
-
</div>
|
|
86
76
|
<div class="form-row">
|
|
87
77
|
<label for="node-input-outputRise"><i class="fa fa-sign-out"></i> rise Output</label>
|
|
88
78
|
<input type="text" id="node-input-outputRise">
|
|
@@ -150,10 +140,6 @@
|
|
|
150
140
|
<dd> threshold value for the rising edge detection.</dd>
|
|
151
141
|
<dt>d(ow)n Threshold <span class="property-type">number</span></dt>
|
|
152
142
|
<dd> threshold value for the falling edge detection.</dd>
|
|
153
|
-
<dt>rise Consecutive <span class="property-type">number</span></dt>
|
|
154
|
-
<dd> number of consecutive frames to generate a rising output.</dd>
|
|
155
|
-
<dt>fall Consecutive <span class="property-type">number</span></dt>
|
|
156
|
-
<dd> number of consecutive frames to generate a falling output.</dd>
|
|
157
143
|
<dt>rise Output <span class="property-type">multi</span></dt>
|
|
158
144
|
<dd> Value to be sent in case of a rising edge.</dd>
|
|
159
145
|
<dt>fall Output <span class="property-type">multi</span></dt>
|
package/math_hysteresis.js
CHANGED
|
@@ -11,8 +11,6 @@ module.exports = function(RED) {
|
|
|
11
11
|
this.propertyType = config.propertyType ?? "msg";
|
|
12
12
|
this.threshold_rise = Number( config.threshold_raise );
|
|
13
13
|
this.threshold_fall = Number( config.threshold_fall );
|
|
14
|
-
this.consecutiveRise= Number( config.consecutive ?? 1 );
|
|
15
|
-
this.consecutiveFall= Number( config.consecutiveFall ?? 1 );
|
|
16
14
|
this.outputRise = RED.util.evaluateNodeProperty( config.outputRise ?? "true", config.outputRiseType ?? "bool" );
|
|
17
15
|
this.outputFall = RED.util.evaluateNodeProperty( config.outputFall ?? "false",config.outputFallType ?? "bool" );
|
|
18
16
|
this.noInit = Boolean( config.noInit );
|
|
@@ -27,8 +25,6 @@ module.exports = function(RED) {
|
|
|
27
25
|
return;
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
|
-
node.cntRise = 0;
|
|
31
|
-
node.cntFall = 0;
|
|
32
28
|
node.status( "" );
|
|
33
29
|
|
|
34
30
|
function msgSetEdge(msg,edge)
|
|
@@ -110,34 +106,11 @@ module.exports = function(RED) {
|
|
|
110
106
|
|
|
111
107
|
if( msg.value > node.threshold_rise && last !== true )
|
|
112
108
|
{
|
|
113
|
-
|
|
114
|
-
{
|
|
115
|
-
sendMsg( true );
|
|
116
|
-
node.cntRise = 0;
|
|
117
|
-
}
|
|
118
|
-
else
|
|
119
|
-
{
|
|
120
|
-
status.fill = "gray";
|
|
121
|
-
}
|
|
122
|
-
node.cntFall = 0;
|
|
109
|
+
sendMsg( true );
|
|
123
110
|
}
|
|
124
111
|
else if( msg.value < node.threshold_fall && last !== false )
|
|
125
112
|
{
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
sendMsg( false );
|
|
129
|
-
node.cntFall = 0;
|
|
130
|
-
}
|
|
131
|
-
else
|
|
132
|
-
{
|
|
133
|
-
status.fill = "gray";
|
|
134
|
-
}
|
|
135
|
-
node.cntRise = 0;
|
|
136
|
-
}
|
|
137
|
-
else
|
|
138
|
-
{
|
|
139
|
-
node.cntRise = 0;
|
|
140
|
-
node.cntFall = 0;
|
|
113
|
+
sendMsg( false );
|
|
141
114
|
}
|
|
142
115
|
}
|
|
143
116
|
else
|
package/package.json
CHANGED