smart-nodes 0.3.36 → 0.4.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/CHANGELOG.md +62 -0
- package/README.md +35 -17
- package/central/central.html +27 -24
- package/central/central.js +84 -26
- package/central/locales/de-DE/central.html +10 -0
- package/central/locales/de-DE/central.json +14 -0
- package/central/locales/en-US/central.html +10 -0
- package/central/locales/en-US/central.json +14 -0
- package/compare/compare.html +64 -87
- package/compare/compare.js +69 -29
- package/compare/locales/de-DE/compare.html +36 -0
- package/compare/locales/de-DE/compare.json +35 -0
- package/compare/locales/en-US/compare.html +36 -0
- package/compare/locales/en-US/compare.json +35 -0
- package/counter/counter.html +70 -72
- package/counter/counter.js +43 -20
- package/counter/locales/de-DE/counter.html +48 -0
- package/counter/locales/de-DE/counter.json +21 -0
- package/counter/locales/en-US/counter.html +48 -0
- package/counter/locales/en-US/counter.json +21 -0
- package/delay/delay.html +30 -102
- package/delay/delay.js +63 -20
- package/delay/locales/de-DE/delay.html +71 -0
- package/delay/locales/de-DE/delay.json +19 -0
- package/delay/locales/en-US/delay.html +76 -0
- package/delay/locales/en-US/delay.json +19 -0
- package/forwarder/forwarder.html +11 -42
- package/forwarder/forwarder.js +59 -18
- package/forwarder/locales/de-DE/forwarder.html +32 -0
- package/forwarder/locales/de-DE/forwarder.json +15 -0
- package/forwarder/locales/en-US/forwarder.html +32 -0
- package/forwarder/locales/en-US/forwarder.json +15 -0
- package/heating-curve/heating-curve.html +10 -51
- package/heating-curve/heating-curve.js +38 -13
- package/heating-curve/locales/de-DE/heating-curve.html +38 -0
- package/heating-curve/locales/de-DE/heating-curve.json +12 -0
- package/heating-curve/locales/en-US/heating-curve.html +38 -0
- package/heating-curve/locales/en-US/heating-curve.json +12 -0
- package/hysteresis/hysteresis.html +49 -69
- package/hysteresis/hysteresis.js +94 -68
- package/hysteresis/locales/de-DE/hysteresis.html +36 -0
- package/hysteresis/locales/de-DE/hysteresis.json +27 -0
- package/hysteresis/locales/en-US/hysteresis.html +36 -0
- package/hysteresis/locales/en-US/hysteresis.json +27 -0
- package/light/light.html +250 -0
- package/{light-control/light-control.js → light/light.js} +151 -32
- package/light/locales/de-DE/light.html +149 -0
- package/light/locales/de-DE/light.json +24 -0
- package/light/locales/en-US/light.html +148 -0
- package/light/locales/en-US/light.json +24 -0
- package/logic/locales/de-DE/logic.html +12 -0
- package/logic/locales/de-DE/logic.json +26 -0
- package/logic/locales/en-US/logic.html +12 -0
- package/logic/locales/en-US/logic.json +26 -0
- package/logic/logic.html +48 -64
- package/logic/logic.js +63 -29
- package/long-press/locales/de-DE/long-press.html +5 -0
- package/long-press/locales/de-DE/long-press.json +13 -0
- package/long-press/locales/en-US/long-press.html +5 -0
- package/long-press/locales/en-US/long-press.json +13 -0
- package/{long-press-control/long-press-control.html → long-press/long-press.html} +10 -14
- package/long-press/long-press.js +163 -0
- package/mixing-valve/locales/de-DE/mixing-valve.html +65 -0
- package/mixing-valve/locales/de-DE/mixing-valve.json +19 -0
- package/mixing-valve/locales/en-US/mixing-valve.html +66 -0
- package/mixing-valve/locales/en-US/mixing-valve.json +19 -0
- package/mixing-valve/mixing-valve.html +27 -93
- package/mixing-valve/mixing-valve.js +87 -61
- package/multi-press/locales/de-DE/multi-press.html +5 -0
- package/multi-press/locales/de-DE/multi-press.json +12 -0
- package/multi-press/locales/en-US/multi-press.html +5 -0
- package/multi-press/locales/en-US/multi-press.json +12 -0
- package/{multi-press-control/multi-press-control.html → multi-press/multi-press.html} +9 -13
- package/{multi-press-control/multi-press-control.js → multi-press/multi-press.js} +53 -5
- package/package.json +7 -7
- package/persistence.js +1 -0
- package/scene/locales/de-DE/scene.html +105 -0
- package/scene/locales/de-DE/scene.json +21 -0
- package/scene/locales/en-US/scene.html +107 -0
- package/scene/locales/en-US/scene.json +20 -0
- package/{scene-control/scene-control.html → scene/scene.html} +30 -132
- package/{scene-control/scene-control.js → scene/scene.js} +76 -26
- package/scheduler/locales/de-DE/scheduler.html +30 -0
- package/scheduler/locales/de-DE/scheduler.json +21 -0
- package/scheduler/locales/en-US/scheduler.html +30 -0
- package/scheduler/locales/en-US/scheduler.json +21 -0
- package/scheduler/scheduler.html +34 -64
- package/scheduler/scheduler.js +85 -53
- package/shutter/locales/de-DE/shutter.html +127 -0
- package/shutter/locales/de-DE/shutter.json +11 -0
- package/shutter/locales/en-US/shutter.html +133 -0
- package/shutter/locales/en-US/shutter.json +11 -0
- package/{shutter-control/shutter-control.html → shutter/shutter.html} +7 -133
- package/{shutter-control/shutter-control.js → shutter/shutter.js} +116 -56
- package/shutter-complex/locales/de-DE/shutter-complex.html +120 -0
- package/shutter-complex/locales/de-DE/shutter-complex.json +20 -0
- package/shutter-complex/locales/en-US/shutter-complex.html +120 -0
- package/shutter-complex/locales/en-US/shutter-complex.json +20 -0
- package/{shutter-complex-control/shutter-complex-control.html → shutter-complex/shutter-complex.html} +36 -140
- package/shutter-complex/shutter-complex.js +578 -0
- package/smart_helper.js +52 -9
- package/statistic/locales/de-DE/statistic.html +10 -0
- package/statistic/locales/de-DE/statistic.json +29 -0
- package/statistic/locales/en-US/statistic.html +10 -0
- package/statistic/locales/en-US/statistic.json +29 -0
- package/statistic/statistic.html +38 -43
- package/statistic/statistic.js +57 -28
- package/text-exec/locales/de-DE/text-exec.html +18 -0
- package/text-exec/locales/de-DE/text-exec.json +7 -0
- package/text-exec/locales/en-US/text-exec.html +18 -0
- package/text-exec/locales/en-US/text-exec.json +7 -0
- package/text-exec/text-exec.html +9 -25
- package/text-exec/text-exec.js +43 -2
- package/light-control/light-control.html +0 -363
- package/long-press-control/long-press-control.js +0 -76
- package/shutter-complex-control/shutter-complex-control.js +0 -442
package/compare/compare.html
CHANGED
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
category: "Smart Nodes",
|
|
4
4
|
paletteLabel: "Compare",
|
|
5
5
|
color: "#E2D96E",
|
|
6
|
-
color: "#E2D96E",
|
|
7
6
|
defaults: {
|
|
8
7
|
name: { value: "" },
|
|
9
8
|
comparator: { value: "EQUAL" }, // EQUAL, GREATER, GREATER_EQUAL, SMALLER, SMALLER_EQUAL, UNEQUAL
|
|
10
9
|
value1: { value: "" },
|
|
11
|
-
value1_type: { value: "
|
|
10
|
+
value1_type: { value: "NOTHING" },
|
|
12
11
|
value2: { value: "" },
|
|
13
|
-
value2_type: { value: "
|
|
12
|
+
value2_type: { value: "NOTHING" },
|
|
14
13
|
out_false: { value: '{"topic": ""}' },
|
|
15
14
|
out_false_type: { value: 'json' },
|
|
16
15
|
out_true: { value: '{"topic": ""}' },
|
|
@@ -33,27 +32,28 @@
|
|
|
33
32
|
},
|
|
34
33
|
oneditprepare: function ()
|
|
35
34
|
{
|
|
35
|
+
let node = this;
|
|
36
|
+
|
|
36
37
|
$("#node-input-comparator").typedInput({
|
|
37
|
-
types: [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
],
|
|
38
|
+
types: [{
|
|
39
|
+
default: "EQUAL",
|
|
40
|
+
value: "comperator",
|
|
41
|
+
options: [
|
|
42
|
+
{ value: "SMALLER", label: node._("compare.ui.smaller") },
|
|
43
|
+
{ value: "SMALLER_EQUAL", label: node._("compare.ui.smaller_equal") },
|
|
44
|
+
{ value: "EQUAL", label: node._("compare.ui.equal") },
|
|
45
|
+
{ value: "UNEQUAL", label: node._("compare.ui.unequal") },
|
|
46
|
+
{ value: "GREATER_EQUAL", label: node._("compare.ui.greater_equal") },
|
|
47
|
+
{ value: "GREATER", label: node._("compare.ui.greater") },
|
|
48
|
+
],
|
|
49
|
+
}],
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
$("#node-input-value1").typedInput({
|
|
53
53
|
type: "num",
|
|
54
54
|
types: ["str", "num", "bool", {
|
|
55
|
-
value: "
|
|
56
|
-
label: "
|
|
55
|
+
value: "NOTHING",
|
|
56
|
+
label: node._("compare.ui.no_value"),
|
|
57
57
|
icon: "fa fa-times",
|
|
58
58
|
hasValue: false,
|
|
59
59
|
}],
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
$("#node-input-value2").typedInput({
|
|
64
64
|
type: "num",
|
|
65
65
|
types: ["str", "num", "bool", {
|
|
66
|
-
value: "
|
|
67
|
-
label: "
|
|
66
|
+
value: "NOTHING",
|
|
67
|
+
label: node._("compare.ui.no_value"),
|
|
68
68
|
icon: "fa fa-times",
|
|
69
69
|
hasValue: false,
|
|
70
70
|
}],
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
$("#node-input-out_true").typedInput({
|
|
77
77
|
type: "json",
|
|
78
78
|
types: ["json", {
|
|
79
|
-
value: "
|
|
80
|
-
label: "
|
|
79
|
+
value: "NOTHING",
|
|
80
|
+
label: node._("compare.ui.send_nothing"),
|
|
81
81
|
icon: "fa fa-times",
|
|
82
82
|
hasValue: false,
|
|
83
83
|
}],
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
$("#node-input-out_false").typedInput({
|
|
88
88
|
type: "json",
|
|
89
89
|
types: ["json", {
|
|
90
|
-
value: "
|
|
91
|
-
label: "
|
|
90
|
+
value: "NOTHING",
|
|
91
|
+
label: node._("compare.ui.send_nothing"),
|
|
92
92
|
icon: "fa fa-times",
|
|
93
93
|
hasValue: false,
|
|
94
94
|
}],
|
|
@@ -99,9 +99,10 @@
|
|
|
99
99
|
type: "bool",
|
|
100
100
|
types: [{
|
|
101
101
|
value: "1",
|
|
102
|
+
value: "send_only_change",
|
|
102
103
|
options: [
|
|
103
|
-
{ value: "true", label: "
|
|
104
|
-
{ value: "false", label: "
|
|
104
|
+
{ value: "true", label: node._("compare.ui.send_only_change") },
|
|
105
|
+
{ value: "false", label: node._("compare.ui.always") },
|
|
105
106
|
]
|
|
106
107
|
}]
|
|
107
108
|
});
|
|
@@ -110,9 +111,10 @@
|
|
|
110
111
|
type: "num",
|
|
111
112
|
types: [{
|
|
112
113
|
value: "1",
|
|
114
|
+
value: "outputs",
|
|
113
115
|
options: [
|
|
114
|
-
{ value: "1", label: "
|
|
115
|
-
{ value: "2", label: "
|
|
116
|
+
{ value: "1", label: node._("compare.ui.common_output") },
|
|
117
|
+
{ value: "2", label: node._("compare.ui.separate_output") },
|
|
116
118
|
]
|
|
117
119
|
}]
|
|
118
120
|
});
|
|
@@ -127,105 +129,80 @@
|
|
|
127
129
|
$("#resend_on_start_row").hide();
|
|
128
130
|
});
|
|
129
131
|
$("#node-input-save_state").trigger("change");
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
// Backward compatibility
|
|
136
|
+
if (this.value1_type == "null")
|
|
137
|
+
{
|
|
138
|
+
this.value1_type = "NOTHING";
|
|
139
|
+
$("#node-input-value1_type").val("NOTHING");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (this.value2_type == "null")
|
|
143
|
+
{
|
|
144
|
+
this.value2_type = "NOTHING";
|
|
145
|
+
$("#node-input-value2_type").val("NOTHING");
|
|
146
|
+
}
|
|
147
|
+
|
|
130
148
|
},
|
|
131
149
|
});
|
|
132
150
|
</script>
|
|
133
151
|
|
|
134
152
|
<script type="text/html" data-template-name="smart_compare">
|
|
135
153
|
<div class="form-row">
|
|
136
|
-
<label for="node-input-name"><i class="fa fa-tag"></i>
|
|
137
|
-
<input type="text" id="node-input-name"
|
|
154
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="compare.ui.name"></span></label>
|
|
155
|
+
<input type="text" id="node-input-name" data-i18n="[placeholder]compare.ui.name"/>
|
|
138
156
|
</div>
|
|
139
157
|
<div class="form-row">
|
|
140
|
-
<label for="node-input-comparator"><i class="fa fa-sort"></i>
|
|
158
|
+
<label for="node-input-comparator"><i class="fa fa-sort"></i> <span data-i18n="compare.ui.compare"></span></label>
|
|
141
159
|
<input id="node-input-comparator" />
|
|
142
160
|
</div>
|
|
143
|
-
<div class="form-row">
|
|
144
|
-
<
|
|
145
|
-
<div>die einkommenden Nachrichten überschrieben werden.</div>
|
|
161
|
+
<div class="form-row" style="max-width: 28rem">
|
|
162
|
+
<span data-i18n="compare.ui.note_default_values"></span>
|
|
146
163
|
</div>
|
|
147
164
|
<div class="form-row">
|
|
148
|
-
<label for="node-input-value1"><i class="fa fa-hashtag"></i>
|
|
165
|
+
<label for="node-input-value1"><i class="fa fa-hashtag"></i> <span data-i18n="compare.ui.value_1"></span></label>
|
|
149
166
|
<input type="text" id="node-input-value1">
|
|
150
167
|
<input type="hidden" id="node-input-value1_type">
|
|
151
168
|
</div>
|
|
152
169
|
<div class="form-row">
|
|
153
|
-
<label for="node-input-value2"><i class="fa fa-hashtag"></i>
|
|
170
|
+
<label for="node-input-value2"><i class="fa fa-hashtag"></i> <span data-i18n="compare.ui.value_2"></span></label>
|
|
154
171
|
<input type="text" id="node-input-value2"/>
|
|
155
172
|
<input type="hidden" id="node-input-value2_type">
|
|
156
173
|
</div>
|
|
157
174
|
<hr/>
|
|
158
|
-
<h4 style="margin: 0.5rem 0;"
|
|
175
|
+
<h4 style="margin: 0.5rem 0;"><span data-i18n="compare.ui.output_messages"></span></h4>
|
|
159
176
|
<div class="form-row">
|
|
160
|
-
<label for="node-input-out_true"><i class="fa fa-check-circle"></i>
|
|
177
|
+
<label for="node-input-out_true"><i class="fa fa-check-circle"></i> <span data-i18n="compare.ui.true"></span></label>
|
|
161
178
|
<input type="text" id="node-input-out_true"/>
|
|
162
179
|
<input type="hidden" id="node-input-out_true_type">
|
|
163
180
|
</div>
|
|
164
181
|
<div class="form-row">
|
|
165
|
-
<label for="node-input-out_false"><i class="fa fa-times-circle"></i>
|
|
182
|
+
<label for="node-input-out_false"><i class="fa fa-times-circle"></i> <span data-i18n="compare.ui.false"></span></label>
|
|
166
183
|
<input type="text" id="node-input-out_false" />
|
|
167
184
|
<input type="hidden" id="node-input-out_false_type">
|
|
168
185
|
</div>
|
|
169
186
|
<div class="form-row">
|
|
170
|
-
<label for="node-input-send_only_change"><i class="fa fa-repeat"></i>
|
|
187
|
+
<label for="node-input-send_only_change"><i class="fa fa-repeat"></i> <span data-i18n="compare.ui.send"></span></label>
|
|
171
188
|
<input id="node-input-send_only_change" />
|
|
172
189
|
</div>
|
|
173
190
|
<div class="form-row">
|
|
174
|
-
<label for="node-input-outputs"><i class="fa fa-hashtag"></i>
|
|
191
|
+
<label for="node-input-outputs"><i class="fa fa-hashtag"></i> <span data-i18n="compare.ui.outputs"></span></label>
|
|
175
192
|
<input id="node-input-outputs" />
|
|
176
193
|
</div>
|
|
177
|
-
<div class="form-row">
|
|
178
|
-
<div><strong
|
|
179
|
-
<div
|
|
180
|
-
<div>sofern es nicht bereits hier in der Konfiguration gesetzt wurde.</div>
|
|
181
|
-
<div><code>msg.comperator</code> wird automatisch auf den Vergleichs-Operator gesetzt,</div>
|
|
182
|
-
<div>sofern es nicht bereits hier in der Konfiguration gesetzt wurde.</div>
|
|
194
|
+
<div class="form-row" style="max-width: 28rem">
|
|
195
|
+
<div><strong data-i18n="compare.ui.note"></strong></div>
|
|
196
|
+
<div data-i18n="[html]compare.ui.note_text"></div>
|
|
183
197
|
</div>
|
|
184
198
|
<hr/>
|
|
185
|
-
<h4 style="margin: 0.5rem 0;"
|
|
199
|
+
<h4 style="margin: 0.5rem 0;"><span data-i18n="compare.ui.system_start"></span></h4>
|
|
186
200
|
<div class="form-row">
|
|
187
201
|
<input type="checkbox" id="node-input-save_state" style="width: 20px;" />
|
|
188
|
-
<label for="node-input-save_state" style="width: calc(100% - 30px);"
|
|
202
|
+
<label for="node-input-save_state" style="width: calc(100% - 30px);"><span data-i18n="compare.ui.save_state"></span></label>
|
|
189
203
|
</div>
|
|
190
204
|
<div class="form-row" id="resend_on_start_row">
|
|
191
205
|
<input type="checkbox" id="node-input-resend_on_start" style="width: 20px;" />
|
|
192
|
-
<label for="node-input-resend_on_start" style="width: calc(100% - 30px);"
|
|
206
|
+
<label for="node-input-resend_on_start" style="width: calc(100% - 30px);"><span data-i18n="compare.ui.send_after_start"></span></label>
|
|
193
207
|
</div>
|
|
194
|
-
</script>
|
|
195
|
-
|
|
196
|
-
<script type="text/html" data-help-name="smart_compare">
|
|
197
|
-
<p>Diese Node führt verschiedene Vergleiche aus. Dabei können nicht nur Zahlen, sondern auch Texte verglichen werden.</p>
|
|
198
|
-
<p>
|
|
199
|
-
<b>Hinweis:</b> Smart Nodes verwenden Topics im Format <code>name#nummer</code>, damit können verschiedene Smart Nodes mit dem gleichen Topic angesteuert werden.<br/>
|
|
200
|
-
Diese Node verwendet nur den Teil <code>nummer</code>. <code>name</code> und <code>#</code> sind dabei optional.
|
|
201
|
-
</p>
|
|
202
|
-
<p>
|
|
203
|
-
Folgende topics werden akzeptiert:
|
|
204
|
-
<table>
|
|
205
|
-
<thead>
|
|
206
|
-
<tr>
|
|
207
|
-
<th>Topic</th>
|
|
208
|
-
<th>Beschreibung</th>
|
|
209
|
-
</tr>
|
|
210
|
-
</thead>
|
|
211
|
-
<tbody>
|
|
212
|
-
<tr>
|
|
213
|
-
<td><code>1</code></td>
|
|
214
|
-
<td>Setzt den linken zu vergleichenden Wert</td>
|
|
215
|
-
</tr>
|
|
216
|
-
<tr>
|
|
217
|
-
<td><code>2</code></td>
|
|
218
|
-
<td>Setzt den rechten zu vergleichenden Wert</td>
|
|
219
|
-
</tr>
|
|
220
|
-
</tbody>
|
|
221
|
-
</table>
|
|
222
|
-
</p>
|
|
223
|
-
<p>Texte werden anhand ihres Ascii-Codes verglichen.<code>"c" < "b"</code> ergibt <code>false</code><code>"C" < "b"</code> ergibt <code>true</code>.</p>
|
|
224
|
-
<p>
|
|
225
|
-
<strong>Hinweis:</strong><br/>
|
|
226
|
-
<code>msg.payload</code> wird automatisch auf das Vergleichs-Ergebnis gesetzt,
|
|
227
|
-
sofern es nicht bereits in der Konfiguration gesetzt wurde.<br/>
|
|
228
|
-
<code>msg.comperator</code> wird automatisch auf den Vergleichs-Operator gesetzt,
|
|
229
|
-
sofern es nicht bereits in der Konfiguration gesetzt wurde.
|
|
230
|
-
</p>
|
|
231
208
|
</script>
|
package/compare/compare.js
CHANGED
|
@@ -7,10 +7,21 @@ module.exports = function (RED)
|
|
|
7
7
|
const node = this;
|
|
8
8
|
RED.nodes.createNode(node, config);
|
|
9
9
|
|
|
10
|
+
// ###################
|
|
11
|
+
// # Class constants #
|
|
12
|
+
// ###################
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// #######################
|
|
16
|
+
// # Global help objects #
|
|
17
|
+
// #######################
|
|
10
18
|
const smart_context = require("../persistence.js")(RED);
|
|
11
19
|
const helper = require("../smart_helper.js");
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
|
|
22
|
+
// #####################
|
|
23
|
+
// # persistent values #
|
|
24
|
+
// #####################
|
|
14
25
|
var node_settings = {
|
|
15
26
|
values: [
|
|
16
27
|
helper.evaluateNodeProperty(RED, config.value1, config.value1_type),
|
|
@@ -20,33 +31,61 @@ module.exports = function (RED)
|
|
|
20
31
|
last_message: null,
|
|
21
32
|
};
|
|
22
33
|
|
|
34
|
+
// load or delete saved values
|
|
23
35
|
if (config.save_state)
|
|
24
|
-
{
|
|
25
|
-
// load old saved values
|
|
26
36
|
node_settings = Object.assign(node_settings, smart_context.get(node.id));
|
|
27
|
-
}
|
|
28
37
|
else
|
|
29
|
-
{
|
|
30
|
-
// delete old saved values
|
|
31
38
|
smart_context.del(node.id);
|
|
32
|
-
}
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
|
|
41
|
+
// ##################
|
|
42
|
+
// # Dynamic config #
|
|
43
|
+
// ##################
|
|
35
44
|
let comparator = config.comparator;
|
|
36
45
|
let out_true = helper.evaluateNodeProperty(RED, config.out_true, config.out_true_type);
|
|
37
46
|
let out_false = helper.evaluateNodeProperty(RED, config.out_false, config.out_false_type);
|
|
38
47
|
let send_only_change = helper.evaluateNodeProperty(RED, config.send_only_change, "bool");
|
|
39
48
|
let outputs = helper.evaluateNodeProperty(RED, config.outputs, "num");
|
|
40
49
|
|
|
41
|
-
// runtime values
|
|
42
50
|
|
|
51
|
+
// ##################
|
|
52
|
+
// # Runtime values #
|
|
53
|
+
// ##################
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// ###############
|
|
57
|
+
// # Node events #
|
|
58
|
+
// ###############
|
|
43
59
|
node.on("input", function (msg)
|
|
44
60
|
{
|
|
61
|
+
handleTopic(msg);
|
|
62
|
+
|
|
63
|
+
setStatus();
|
|
64
|
+
|
|
65
|
+
if (config.save_state)
|
|
66
|
+
smart_context.set(node.id, node_settings);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
node.on("close", function ()
|
|
70
|
+
{
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
// #####################
|
|
75
|
+
// # Private functions #
|
|
76
|
+
// #####################
|
|
77
|
+
|
|
78
|
+
// This is the main function which handles all topics that was received.
|
|
79
|
+
let handleTopic = msg =>
|
|
80
|
+
{
|
|
81
|
+
helper.log("handle topic:");
|
|
82
|
+
helper.log(msg);
|
|
83
|
+
|
|
45
84
|
// Check if topic has a valid value
|
|
46
|
-
let
|
|
47
|
-
if (
|
|
85
|
+
let real_topic_number = helper.getTopicNumber(msg.topic);
|
|
86
|
+
if (real_topic_number == null || real_topic_number < 1 || real_topic_number > 2)
|
|
48
87
|
{
|
|
49
|
-
|
|
88
|
+
console.warn("Topic has to be 1 or 2, sended: " + msg.topic);
|
|
50
89
|
return;
|
|
51
90
|
}
|
|
52
91
|
|
|
@@ -54,17 +93,20 @@ module.exports = function (RED)
|
|
|
54
93
|
let num = parseFloat(msg.payload);
|
|
55
94
|
if (Number.isNaN(num))
|
|
56
95
|
{
|
|
57
|
-
|
|
96
|
+
console.warn("Payload has to be numeric: " + msg.payload);
|
|
58
97
|
return;
|
|
59
98
|
}
|
|
60
99
|
|
|
61
100
|
// Save new value
|
|
62
|
-
node_settings.values[
|
|
101
|
+
node_settings.values[real_topic_number - 1] = num;
|
|
63
102
|
|
|
64
103
|
let result = getResult();
|
|
65
|
-
let out_msg = null;
|
|
66
104
|
|
|
67
|
-
|
|
105
|
+
helper.log("getResult:");
|
|
106
|
+
helper.log(result);
|
|
107
|
+
helper.log(node_settings);
|
|
108
|
+
|
|
109
|
+
let out_msg = null;
|
|
68
110
|
|
|
69
111
|
if (result != null)
|
|
70
112
|
{
|
|
@@ -72,12 +114,12 @@ module.exports = function (RED)
|
|
|
72
114
|
if (result)
|
|
73
115
|
{
|
|
74
116
|
if (out_true !== null)
|
|
75
|
-
out_msg =
|
|
117
|
+
out_msg = helper.cloneObject(out_true);
|
|
76
118
|
}
|
|
77
119
|
else
|
|
78
120
|
{
|
|
79
121
|
if (out_false !== null)
|
|
80
|
-
out_msg =
|
|
122
|
+
out_msg = helper.cloneObject(out_false);
|
|
81
123
|
}
|
|
82
124
|
|
|
83
125
|
if (out_msg !== null)
|
|
@@ -105,12 +147,13 @@ module.exports = function (RED)
|
|
|
105
147
|
|
|
106
148
|
node_settings.last_result = result;
|
|
107
149
|
node_settings.last_message = out_msg;
|
|
108
|
-
|
|
109
|
-
if (config.save_state)
|
|
110
|
-
smart_context.set(node.id, node_settings);
|
|
111
150
|
}
|
|
112
|
-
}
|
|
151
|
+
}
|
|
113
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Do the configured comparison and return the result
|
|
155
|
+
* @returns The comparison result
|
|
156
|
+
*/
|
|
114
157
|
let getResult = () =>
|
|
115
158
|
{
|
|
116
159
|
// Wait until both values are set
|
|
@@ -168,23 +211,20 @@ module.exports = function (RED)
|
|
|
168
211
|
}
|
|
169
212
|
|
|
170
213
|
// updates the status
|
|
171
|
-
let setStatus = (
|
|
214
|
+
let setStatus = () =>
|
|
172
215
|
{
|
|
173
|
-
if (
|
|
216
|
+
if (node_settings.last_result === null)
|
|
174
217
|
node.status({});
|
|
175
218
|
else
|
|
176
|
-
node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": " + node_settings.values.join(" " + getComparatorSign() + " ") + " => " +
|
|
219
|
+
node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": " + node_settings.values.join(" " + getComparatorSign() + " ") + " => " + node_settings.last_result });
|
|
177
220
|
}
|
|
178
221
|
|
|
179
|
-
node.on("close", function ()
|
|
180
|
-
{
|
|
181
|
-
});
|
|
182
222
|
|
|
183
223
|
if (config.save_state && config.resend_on_start && node_settings.last_message != null)
|
|
184
224
|
{
|
|
185
225
|
setTimeout(() =>
|
|
186
226
|
{
|
|
187
|
-
node.send(node_settings.last_message);
|
|
227
|
+
node.send(helper.cloneObject(node_settings.last_message));
|
|
188
228
|
}, 10000);
|
|
189
229
|
}
|
|
190
230
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script type="text/html" data-help-name="smart_compare">
|
|
2
|
+
<p>Diese Node führt verschiedene Vergleiche aus. Dabei können nicht nur Zahlen, sondern auch Texte verglichen werden.</p>
|
|
3
|
+
<p>
|
|
4
|
+
<b>Hinweis:</b> Smart Nodes verwenden Topics im Format <code>name#nummer</code>, damit können verschiedene Smart Nodes mit dem gleichen Topic angesteuert werden.<br/>
|
|
5
|
+
Diese Node verwendet nur den Teil <code>nummer</code>. <code>name</code> und <code>#</code> sind dabei optional.
|
|
6
|
+
</p>
|
|
7
|
+
<p>
|
|
8
|
+
Folgende topics werden akzeptiert:
|
|
9
|
+
<table>
|
|
10
|
+
<thead>
|
|
11
|
+
<tr>
|
|
12
|
+
<th>Topic</th>
|
|
13
|
+
<th>Beschreibung</th>
|
|
14
|
+
</tr>
|
|
15
|
+
</thead>
|
|
16
|
+
<tbody>
|
|
17
|
+
<tr>
|
|
18
|
+
<td><code>1</code></td>
|
|
19
|
+
<td>Setzt den linken zu vergleichenden Wert</td>
|
|
20
|
+
</tr>
|
|
21
|
+
<tr>
|
|
22
|
+
<td><code>2</code></td>
|
|
23
|
+
<td>Setzt den rechten zu vergleichenden Wert</td>
|
|
24
|
+
</tr>
|
|
25
|
+
</tbody>
|
|
26
|
+
</table>
|
|
27
|
+
</p>
|
|
28
|
+
<p>Texte werden anhand ihres Ascii-Codes verglichen.<code>"c" < "b"</code> ergibt <code>false</code><code>"C" < "b"</code> ergibt <code>true</code>.</p>
|
|
29
|
+
<p>
|
|
30
|
+
<strong>Hinweis:</strong><br/>
|
|
31
|
+
<code>msg.payload</code> wird automatisch auf das Vergleichs-Ergebnis gesetzt,
|
|
32
|
+
sofern es nicht bereits in der Konfiguration gesetzt wurde.<br/>
|
|
33
|
+
<code>msg.comperator</code> wird automatisch auf den Vergleichs-Operator gesetzt,
|
|
34
|
+
sofern es nicht bereits in der Konfiguration gesetzt wurde.
|
|
35
|
+
</p>
|
|
36
|
+
</script>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compare": {
|
|
3
|
+
"ui": {
|
|
4
|
+
"name": "Name",
|
|
5
|
+
"compare": "Vergleich",
|
|
6
|
+
"note_default_values": "Defaultwerte werden hier gesetzt und können durch die einkommenden Nachrichten überschrieben werden.",
|
|
7
|
+
"value_1": "Wert 1",
|
|
8
|
+
"value_2": "Wert 2",
|
|
9
|
+
"output_messages": "Ausgangsnachrichten",
|
|
10
|
+
"true": "Wahr",
|
|
11
|
+
"false": "Falsch",
|
|
12
|
+
"send": "Senden",
|
|
13
|
+
"outputs": "Ausgänge",
|
|
14
|
+
"note": "Hinweis:",
|
|
15
|
+
"note_text": "<code>msg.payload</code> wird automatisch auf das Vergleichs-Ergebnis gesetzt,<br/>sofern es nicht bereits hier in der Konfiguration gesetzt wurde.<br/><code>msg.comperator</code> wird automatisch auf den Vergleichs-Operator gesetzt,<br/>sofern es nicht bereits hier in der Konfiguration gesetzt wurde.",
|
|
16
|
+
|
|
17
|
+
"system_start": "Systemstart",
|
|
18
|
+
"save_state": "Zustand speichern",
|
|
19
|
+
"send_after_start": "Letze Nachricht 10 Sekunden nach dem Start senden",
|
|
20
|
+
|
|
21
|
+
"smaller": "< Kleiner",
|
|
22
|
+
"smaller_equal": "<= Kleiner oder gleich",
|
|
23
|
+
"equal": "== Gleich",
|
|
24
|
+
"unequal": "!= Ungleich",
|
|
25
|
+
"greater_equal": ">= Größer oder gleich",
|
|
26
|
+
"greater": "> Größer",
|
|
27
|
+
"no_value": "Kein Wert",
|
|
28
|
+
"send_nothing": "Nichts senden",
|
|
29
|
+
"send_only_change": "Nur bei Änderung",
|
|
30
|
+
"always": "Immer",
|
|
31
|
+
"common_output": "Gemeinsamer Ausgang",
|
|
32
|
+
"separate_output": "Separate Ausgänge"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script type="text/html" data-help-name="smart_compare">
|
|
2
|
+
<p>This node performs various comparisons. Not only numbers, but also texts can be compared.</p>
|
|
3
|
+
<p>
|
|
4
|
+
<b>Note:</b> Smart nodes use topics in the format <code>name#number</code>, so that different smart nodes can be controlled with the same topic.<br/>
|
|
5
|
+
This node only uses the <code>number</code> part. <code>name</code> and <code>#</code> are optional.
|
|
6
|
+
</p>
|
|
7
|
+
<p>
|
|
8
|
+
The following topics are accepted:
|
|
9
|
+
<table>
|
|
10
|
+
<thead>
|
|
11
|
+
<tr>
|
|
12
|
+
<th>Topic</th>
|
|
13
|
+
<th>Description</th>
|
|
14
|
+
</tr>
|
|
15
|
+
</thead>
|
|
16
|
+
<tbody>
|
|
17
|
+
<tr>
|
|
18
|
+
<td><code>1</code></td>
|
|
19
|
+
<td>Sets the left value to compare</td>
|
|
20
|
+
</tr>
|
|
21
|
+
<tr>
|
|
22
|
+
<td><code>2</code></td>
|
|
23
|
+
<td>Sets the right value to compare</td>
|
|
24
|
+
</tr>
|
|
25
|
+
</tbody>
|
|
26
|
+
</table>
|
|
27
|
+
</p>
|
|
28
|
+
<p>Texts are compared based on their ASCII code.<code>"c" < "b"</code> returns <code>false</code><code>"C" < "b"</code> results in <code>true</code>.</p>
|
|
29
|
+
<p>
|
|
30
|
+
<strong>Note:</strong><br/>
|
|
31
|
+
<code>msg.payload</code> is automatically set to the comparison result,
|
|
32
|
+
if it has not already been set in the configuration.<br/>
|
|
33
|
+
<code>msg.comperator</code> is automatically set to the comparison operator,
|
|
34
|
+
if it has not already been set in the configuration.
|
|
35
|
+
</p>
|
|
36
|
+
</script>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compare": {
|
|
3
|
+
"ui": {
|
|
4
|
+
"name": "Name",
|
|
5
|
+
"compare": "Compare",
|
|
6
|
+
"note_default_values": "Default values are set here and can be overwritten by incoming messages.",
|
|
7
|
+
"value_1": "Value 1",
|
|
8
|
+
"value_2": "Value 2",
|
|
9
|
+
"output_messages": "Output message",
|
|
10
|
+
"true": "True",
|
|
11
|
+
"false": "False",
|
|
12
|
+
"send": "Send",
|
|
13
|
+
"outputs": "Outputs",
|
|
14
|
+
"note": "Note:",
|
|
15
|
+
"note_text": "<code>msg.payload</code> is automatically set to the comparison result,<br/>if it has not already been set here in the configuration.<br/><code>msg.comperator</code> is automatically set to the comparison operator,<br/>if it has not already been set here in the configuration.",
|
|
16
|
+
|
|
17
|
+
"system_start": "System start",
|
|
18
|
+
"save_state": "Save state",
|
|
19
|
+
"send_after_start": "Send last message 10 seconds after the start",
|
|
20
|
+
|
|
21
|
+
"smaller": "< Smaller",
|
|
22
|
+
"smaller_equal": "<= Smaller or equal",
|
|
23
|
+
"equal": "== Equal",
|
|
24
|
+
"unequal": "!= Not equal",
|
|
25
|
+
"greater_equal": ">= Greater or equal",
|
|
26
|
+
"greater": "> Greater",
|
|
27
|
+
"no_value": "No value",
|
|
28
|
+
"send_nothing": "Send nothing",
|
|
29
|
+
"send_only_change": "Only on change",
|
|
30
|
+
"always": "Always",
|
|
31
|
+
"common_output": "Common output",
|
|
32
|
+
"separate_output": "Separate outputs"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|