smart-nodes 0.3.37 → 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 +26 -12
- package/central/central.js +84 -26
- package/central/locales/de-DE/central.json +1 -4
- package/central/locales/en-US/central.json +0 -3
- package/compare/compare.html +40 -24
- package/compare/compare.js +69 -29
- package/compare/locales/de-DE/compare.json +5 -7
- package/compare/locales/en-US/compare.json +18 -8
- package/counter/counter.html +64 -17
- package/counter/counter.js +43 -20
- package/counter/locales/de-DE/counter.json +6 -9
- package/counter/locales/en-US/counter.json +12 -16
- package/delay/delay.html +18 -88
- 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 +43 -65
- 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-control/light-control.html → light/light.html} +34 -144
- 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 +27 -40
- 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 +15 -79
- 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} +18 -121
- 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} +30 -133
- 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 +32 -36
- 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/long-press-control/long-press-control.js +0 -76
- package/shutter-complex-control/shutter-complex-control.js +0 -442
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
|
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compare": {
|
|
3
|
-
"errors": {
|
|
4
|
-
"wrong_topic": "Topic muss 1 oder 2 sein, gesendet: "
|
|
5
|
-
},
|
|
6
3
|
"ui": {
|
|
7
4
|
"name": "Name",
|
|
8
5
|
"compare": "Vergleich",
|
|
@@ -14,12 +11,13 @@
|
|
|
14
11
|
"false": "Falsch",
|
|
15
12
|
"send": "Senden",
|
|
16
13
|
"outputs": "Ausgänge",
|
|
17
|
-
"note": "Hinweis",
|
|
18
|
-
"
|
|
19
|
-
|
|
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
|
+
|
|
20
17
|
"system_start": "Systemstart",
|
|
21
18
|
"save_state": "Zustand speichern",
|
|
22
19
|
"send_after_start": "Letze Nachricht 10 Sekunden nach dem Start senden",
|
|
20
|
+
|
|
23
21
|
"smaller": "< Kleiner",
|
|
24
22
|
"smaller_equal": "<= Kleiner oder gleich",
|
|
25
23
|
"equal": "== Gleich",
|
|
@@ -28,7 +26,7 @@
|
|
|
28
26
|
"greater": "> Größer",
|
|
29
27
|
"no_value": "Kein Wert",
|
|
30
28
|
"send_nothing": "Nichts senden",
|
|
31
|
-
"
|
|
29
|
+
"send_only_change": "Nur bei Änderung",
|
|
32
30
|
"always": "Immer",
|
|
33
31
|
"common_output": "Gemeinsamer Ausgang",
|
|
34
32
|
"separate_output": "Separate Ausgänge"
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compare": {
|
|
3
|
-
"errors": {
|
|
4
|
-
"wrong_topic": "Topic has to be 1 or 2, sended: "
|
|
5
|
-
},
|
|
6
3
|
"ui": {
|
|
7
4
|
"name": "Name",
|
|
8
5
|
"compare": "Compare",
|
|
9
|
-
"note_default_values": "Default values
|
|
6
|
+
"note_default_values": "Default values are set here and can be overwritten by incoming messages.",
|
|
10
7
|
"value_1": "Value 1",
|
|
11
8
|
"value_2": "Value 2",
|
|
12
9
|
"output_messages": "Output message",
|
|
@@ -14,12 +11,25 @@
|
|
|
14
11
|
"false": "False",
|
|
15
12
|
"send": "Send",
|
|
16
13
|
"outputs": "Outputs",
|
|
17
|
-
"note": "Note",
|
|
18
|
-
"
|
|
19
|
-
|
|
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
|
+
|
|
20
17
|
"system_start": "System start",
|
|
21
18
|
"save_state": "Save state",
|
|
22
|
-
"send_after_start": "Send last message 10 seconds after the start"
|
|
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"
|
|
23
33
|
}
|
|
24
34
|
}
|
|
25
35
|
}
|
package/counter/counter.html
CHANGED
|
@@ -23,11 +23,54 @@
|
|
|
23
23
|
},
|
|
24
24
|
oneditprepare: function ()
|
|
25
25
|
{
|
|
26
|
+
let node = this;
|
|
27
|
+
|
|
28
|
+
$("#node-input-start")
|
|
29
|
+
.spinner({
|
|
30
|
+
change: function (event, ui)
|
|
31
|
+
{
|
|
32
|
+
var value = parseFloat(this.value);
|
|
33
|
+
value = isNaN(value) ? 0 : value;
|
|
34
|
+
if (value !== this.value) $(this).spinner("value", value);
|
|
35
|
+
},
|
|
36
|
+
}).css("max-width", "4rem");
|
|
37
|
+
|
|
38
|
+
$("#node-input-step")
|
|
39
|
+
.spinner({
|
|
40
|
+
change: function (event, ui)
|
|
41
|
+
{
|
|
42
|
+
var value = parseFloat(this.value);
|
|
43
|
+
value = isNaN(value) ? 0 : value;
|
|
44
|
+
if (value !== this.value) $(this).spinner("value", value);
|
|
45
|
+
},
|
|
46
|
+
}).css("max-width", "4rem");
|
|
47
|
+
|
|
48
|
+
$("#node-input-min")
|
|
49
|
+
.spinner({
|
|
50
|
+
change: function (event, ui)
|
|
51
|
+
{
|
|
52
|
+
var value = parseFloat(this.value);
|
|
53
|
+
value = isNaN(value) ? 0 : value;
|
|
54
|
+
if (value !== this.value) $(this).spinner("value", value);
|
|
55
|
+
},
|
|
56
|
+
}).css("max-width", "4rem");
|
|
57
|
+
|
|
58
|
+
$("#node-input-max")
|
|
59
|
+
.spinner({
|
|
60
|
+
change: function (event, ui)
|
|
61
|
+
{
|
|
62
|
+
var value = parseFloat(this.value);
|
|
63
|
+
value = isNaN(value) ? 0 : value;
|
|
64
|
+
if (value !== this.value) $(this).spinner("value", value);
|
|
65
|
+
},
|
|
66
|
+
}).css("max-width", "4rem");
|
|
67
|
+
|
|
68
|
+
|
|
26
69
|
$("#node-input-out_message").typedInput({
|
|
27
70
|
type: "json",
|
|
28
71
|
types: ["json", {
|
|
29
|
-
value: "
|
|
30
|
-
label:
|
|
72
|
+
value: "NOTHING",
|
|
73
|
+
label: node._("default"),
|
|
31
74
|
icon: "fa fa-times",
|
|
32
75
|
hasValue: false,
|
|
33
76
|
}],
|
|
@@ -42,6 +85,14 @@
|
|
|
42
85
|
$("#resend_on_start_row").hide();
|
|
43
86
|
});
|
|
44
87
|
$("#node-input-save_state").trigger("change");
|
|
88
|
+
|
|
89
|
+
// Backward compatibility
|
|
90
|
+
if (this.out_message_type == "null")
|
|
91
|
+
{
|
|
92
|
+
this.out_message_type = "NOTHING";
|
|
93
|
+
$("#node-input-out_message_type").val("NOTHING");
|
|
94
|
+
}
|
|
95
|
+
|
|
45
96
|
}
|
|
46
97
|
});
|
|
47
98
|
</script>
|
|
@@ -53,43 +104,39 @@
|
|
|
53
104
|
</div>
|
|
54
105
|
<div class="form-row">
|
|
55
106
|
<label for="node-input-start"><i class="fa fa-cog"></i> <span data-i18n="counter.ui.start"></label>
|
|
56
|
-
<input
|
|
107
|
+
<input id="node-input-start" data-i18n="[placeholder]counter.ui.start">
|
|
57
108
|
</div>
|
|
58
109
|
<div class="form-row">
|
|
59
110
|
<label for="node-input-step"><i class="fa fa-forward"></i> <span data-i18n="counter.ui.step"></label>
|
|
60
|
-
<input
|
|
111
|
+
<input id="node-input-step" data-i18n="[placeholder]counter.ui.step">
|
|
61
112
|
</div>
|
|
62
113
|
<div class="form-row">
|
|
63
114
|
<label for="node-input-min"><i class="fa fa-arrow-down"></i> <span data-i18n="counter.ui.min"></label>
|
|
64
|
-
<input
|
|
115
|
+
<input id="node-input-min" data-i18n="[placeholder]counter.ui.min">
|
|
65
116
|
</div>
|
|
66
117
|
<div class="form-row">
|
|
67
118
|
<label for="node-input-max"><i class="fa fa-arrow-up"></i> <span data-i18n="counter.ui.max"></label>
|
|
68
|
-
<input
|
|
119
|
+
<input id="node-input-max" data-i18n="[placeholder]counter.ui.max">
|
|
69
120
|
</div>
|
|
70
121
|
<hr/>
|
|
71
|
-
<h4 style="margin: 0.5rem 0;"
|
|
122
|
+
<h4 style="margin: 0.5rem 0;"><span data-i18n="compare.ui.output_messages"></span></h4>
|
|
72
123
|
<div class="form-row">
|
|
73
|
-
<label for="node-input-out_message"><i class="fa fa-check-circle"></i>
|
|
124
|
+
<label for="node-input-out_message"><i class="fa fa-check-circle"></i> <span data-i18n="counter.ui.message"></span></label>
|
|
74
125
|
<input type="text" id="node-input-out_message"/>
|
|
75
126
|
<input type="hidden" id="node-input-out_message_type">
|
|
76
127
|
</div>
|
|
77
128
|
<div class="form-row">
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
<div class="form-row">
|
|
81
|
-
<span>
|
|
82
|
-
<code>msg.payload</code> wird immer automatisch auf den Ergebnis-Wert gesetzt.
|
|
83
|
-
</span>
|
|
129
|
+
<div><strong data-i18n="counter.ui.note"></strong></div>
|
|
130
|
+
<div data-i18n="[html]counter.ui.note_text"></div>
|
|
84
131
|
</div>
|
|
85
132
|
<hr/>
|
|
86
|
-
<h4 style="margin: 0.5rem 0;"
|
|
133
|
+
<h4 style="margin: 0.5rem 0;"><span data-i18n="compare.ui.system_start"></span></h4>
|
|
87
134
|
<div class="form-row">
|
|
88
135
|
<input type="checkbox" id="node-input-save_state" style="width: 20px;" />
|
|
89
|
-
<label for="node-input-save_state" style="width: calc(100% - 30px);"
|
|
136
|
+
<label for="node-input-save_state" style="width: calc(100% - 30px);"><span data-i18n="compare.ui.save_state"></span></label>
|
|
90
137
|
</div>
|
|
91
138
|
<div class="form-row" id="resend_on_start_row">
|
|
92
139
|
<input type="checkbox" id="node-input-resend_on_start" style="width: 20px;" />
|
|
93
|
-
<label for="node-input-resend_on_start" style="width: calc(100% - 30px);"
|
|
140
|
+
<label for="node-input-resend_on_start" style="width: calc(100% - 30px);"><span data-i18n="compare.ui.send_after_start"></span></label>
|
|
94
141
|
</div>
|
|
95
142
|
</script>
|
package/counter/counter.js
CHANGED
|
@@ -7,41 +7,67 @@ 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
|
|
|
21
|
+
// #####################
|
|
22
|
+
// # persistent values #
|
|
23
|
+
// #####################
|
|
13
24
|
var node_settings = {
|
|
14
25
|
value: null,
|
|
15
26
|
last_message: null,
|
|
16
27
|
};
|
|
17
28
|
|
|
29
|
+
// load or delete saved values
|
|
18
30
|
if (config.save_state)
|
|
19
|
-
{
|
|
20
|
-
// load old saved values
|
|
21
31
|
node_settings = Object.assign(node_settings, smart_context.get(node.id));
|
|
22
|
-
}
|
|
23
32
|
else
|
|
24
|
-
{
|
|
25
|
-
// delete old saved values
|
|
26
33
|
smart_context.del(node.id);
|
|
27
|
-
}
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let
|
|
35
|
+
|
|
36
|
+
// ##################
|
|
37
|
+
// # Dynamic config #
|
|
38
|
+
// ##################
|
|
39
|
+
let start = parseInt(config.start, 10);
|
|
40
|
+
let step = parseInt(config.step, 10);
|
|
41
|
+
let min = parseInt(config.min, 10);
|
|
42
|
+
let max = parseInt(config.max, 10);
|
|
34
43
|
let out_message = helper.evaluateNodeProperty(RED, config.out_message, config.out_message_type);
|
|
35
44
|
|
|
36
|
-
|
|
45
|
+
|
|
46
|
+
// ##################
|
|
47
|
+
// # Runtime values #
|
|
48
|
+
// ##################
|
|
49
|
+
// Not used by this node
|
|
37
50
|
|
|
38
51
|
node.on("input", function (msg)
|
|
39
52
|
{
|
|
40
53
|
handleTopic(msg);
|
|
54
|
+
|
|
41
55
|
sendResult();
|
|
56
|
+
|
|
42
57
|
setStatus();
|
|
58
|
+
smart_context.set(node.id, node_settings);
|
|
43
59
|
});
|
|
44
60
|
|
|
61
|
+
node.on("close", function ()
|
|
62
|
+
{
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// #####################
|
|
67
|
+
// # Private functions #
|
|
68
|
+
// #####################
|
|
69
|
+
|
|
70
|
+
// This is the main function which handles all topics that was received.
|
|
45
71
|
let handleTopic = msg =>
|
|
46
72
|
{
|
|
47
73
|
let real_topic = helper.getTopicName(msg.topic);
|
|
@@ -93,6 +119,9 @@ module.exports = function (RED)
|
|
|
93
119
|
node_settings.value = Math.min(max, Math.max(min, node_settings.value));
|
|
94
120
|
}
|
|
95
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Send the result to the output
|
|
124
|
+
*/
|
|
96
125
|
let sendResult = () =>
|
|
97
126
|
{
|
|
98
127
|
// Nothing changed, nothing to do
|
|
@@ -101,19 +130,13 @@ module.exports = function (RED)
|
|
|
101
130
|
|
|
102
131
|
// if out_message is set, use this instead of the default message
|
|
103
132
|
if (out_message)
|
|
104
|
-
node_settings.last_message =
|
|
133
|
+
node_settings.last_message = helper.cloneObject(out_message, { payload: node_settings.value });
|
|
105
134
|
else
|
|
106
135
|
node_settings.last_message = { payload: node_settings.value };
|
|
107
136
|
|
|
108
|
-
smart_context.set(node.id, node_settings);
|
|
109
|
-
|
|
110
137
|
node.send(node_settings.last_message);
|
|
111
138
|
}
|
|
112
139
|
|
|
113
|
-
node.on("close", function ()
|
|
114
|
-
{
|
|
115
|
-
});
|
|
116
|
-
|
|
117
140
|
// updates the status
|
|
118
141
|
let setStatus = () =>
|
|
119
142
|
{
|
|
@@ -127,7 +150,7 @@ module.exports = function (RED)
|
|
|
127
150
|
{
|
|
128
151
|
setTimeout(() =>
|
|
129
152
|
{
|
|
130
|
-
node.send(node_settings.last_message);
|
|
153
|
+
node.send(helper.cloneObject(node_settings.last_message));
|
|
131
154
|
}, 10000);
|
|
132
155
|
}
|
|
133
156
|
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"counter": {
|
|
3
|
-
"errors": {
|
|
4
|
-
"wrong_topic": "Topic muss 1 oder 2 sein, gesendet: "
|
|
5
|
-
},
|
|
6
3
|
"ui": {
|
|
7
4
|
"name": "Name",
|
|
8
5
|
"start": "Start",
|
|
9
6
|
"step": "Schritt",
|
|
10
7
|
"min": "Min",
|
|
11
8
|
"max": "Max",
|
|
9
|
+
"output_messages": "Ausgangsnachrichten",
|
|
10
|
+
"message": "Nachricht",
|
|
11
|
+
"note": "Hinweis:",
|
|
12
|
+
"note_text": "<code>msg.payload</code> wird immer automatisch auf den Ergebnis-Wert gesetzt.",
|
|
12
13
|
|
|
13
14
|
"system_start": "Systemstart",
|
|
14
15
|
"save_state": "Zustand speichern",
|
|
15
16
|
"send_after_start": "Letze Nachricht 10 Sekunden nach dem Start senden",
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"only_on_change": "Nur bei Änderung",
|
|
19
|
-
"always": "Immer",
|
|
20
|
-
"common_output": "Gemeinsamer Ausgang",
|
|
21
|
-
"separate_output": "Separate Ausgänge"
|
|
17
|
+
|
|
18
|
+
"default": "Standard"
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"counter": {
|
|
3
|
-
"errors": {
|
|
4
|
-
"wrong_topic": "Topic has to be 1 or 2, sended: "
|
|
5
|
-
},
|
|
6
3
|
"ui": {
|
|
7
4
|
"name": "Name",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"output_messages": "Output
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
"note": "Note",
|
|
18
|
-
"note_payload": "is automatically set to the comparison result, unless it has already been set here in the configuration.",
|
|
19
|
-
"note_comperator": "is automatically set to the comparison operator if it has not already been set here in the configuration.",
|
|
5
|
+
"start": "Start",
|
|
6
|
+
"step": "Step",
|
|
7
|
+
"min": "Min",
|
|
8
|
+
"max": "Max",
|
|
9
|
+
"output_messages": "Output messages",
|
|
10
|
+
"message": "Message",
|
|
11
|
+
"note": "Note:",
|
|
12
|
+
"note_text": "<code>msg.payload</code> is always automatically set to the result value.",
|
|
13
|
+
|
|
20
14
|
"system_start": "System start",
|
|
21
15
|
"save_state": "Save state",
|
|
22
|
-
"send_after_start": "Send last message 10 seconds after
|
|
16
|
+
"send_after_start": "Send last message 10 seconds after start",
|
|
17
|
+
|
|
18
|
+
"default": "Default"
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
21
|
}
|