smart-nodes 0.3.22 → 0.3.26
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/LICENSE.md +1 -1
- package/README.md +51 -21
- package/central/central.js +10 -8
- package/compare/compare.html +48 -0
- package/compare/compare.js +36 -20
- package/counter/counter.html +104 -0
- package/counter/counter.js +120 -0
- package/delay/delay.js +39 -37
- package/examples/heating-curve.json +480 -0
- package/examples/heating-curve.png +0 -0
- package/examples/mixing-valve.json +622 -0
- package/examples/mixing-valve.png +0 -0
- package/forwarder/forwarder.js +28 -26
- package/heating-curve/heating-curve.html +348 -0
- package/heating-curve/heating-curve.js +134 -0
- package/hysteresis/hysteresis.js +47 -46
- package/icons/smart_counter.png +0 -0
- package/light-control/light-control.js +30 -28
- package/logic/logic.html +18 -2
- package/logic/logic.js +25 -23
- package/long-press-control/long-press-control.js +6 -4
- package/mixing-valve/mixing-valve.html +188 -0
- package/mixing-valve/mixing-valve.js +357 -0
- package/multi-press-control/multi-press-control.js +3 -1
- package/package.json +8 -1
- package/scene-control/scene-control.js +29 -27
- package/scheduler/scheduler.js +27 -25
- package/shutter-complex-control/shutter-complex-control.js +62 -62
- package/shutter-control/shutter-control.js +39 -37
- package/smart_helper.js +135 -20
- package/statistic/statistic.js +30 -28
- package/text-exec/text-exec.js +3 -1
- package/LICENSE +0 -21
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
module.exports = function (RED)
|
|
2
2
|
{
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
3
5
|
function ShutterComplexControlNode(config)
|
|
4
6
|
{
|
|
5
7
|
const node = this;
|
|
6
8
|
RED.nodes.createNode(node, config);
|
|
7
9
|
|
|
8
|
-
const
|
|
10
|
+
const smart_context = require("../persistence.js")(RED);
|
|
9
11
|
const helper = require("../smart_helper.js");
|
|
10
12
|
|
|
11
13
|
// used from text-exec node
|
|
@@ -15,10 +17,10 @@ module.exports = function (RED)
|
|
|
15
17
|
node.exec_text_names = [];
|
|
16
18
|
|
|
17
19
|
// persistent values
|
|
18
|
-
var
|
|
20
|
+
var node_settings = Object.assign({}, {
|
|
19
21
|
last_position: 0, // 0 = opened, 100 = closed
|
|
20
22
|
last_direction_up: true, // remember last direction for toggle action
|
|
21
|
-
},
|
|
23
|
+
}, smart_context.get(node.id));
|
|
22
24
|
|
|
23
25
|
// dynamic config
|
|
24
26
|
let max_time = parseInt(config.max_time || 60);
|
|
@@ -47,7 +49,7 @@ module.exports = function (RED)
|
|
|
47
49
|
{
|
|
48
50
|
handleTopic(msg);
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
smart_context.set(node.id, node_settings);
|
|
51
53
|
});
|
|
52
54
|
|
|
53
55
|
node.on("close", function ()
|
|
@@ -62,56 +64,56 @@ module.exports = function (RED)
|
|
|
62
64
|
var resultDown = false;
|
|
63
65
|
var resultStop = false;
|
|
64
66
|
|
|
65
|
-
let
|
|
67
|
+
let real_topic = helper.getTopicName(msg.topic);
|
|
66
68
|
|
|
67
69
|
// set default topic if invalid value is send
|
|
68
|
-
if (!["up", "up_stop", "down", "down_stop", "stop", "toggle", "up_down", "position", "alarm"].includes(
|
|
69
|
-
|
|
70
|
+
if (!["up", "up_stop", "down", "down_stop", "stop", "toggle", "up_down", "position", "alarm"].includes(real_topic))
|
|
71
|
+
real_topic = "toggle";
|
|
70
72
|
|
|
71
73
|
// skip if button is released
|
|
72
|
-
if (msg.payload === false && ["up", "up_stop", "down", "down_stop", "stop", "toggle"].includes(
|
|
74
|
+
if (msg.payload === false && ["up", "up_stop", "down", "down_stop", "stop", "toggle"].includes(real_topic))
|
|
73
75
|
return;
|
|
74
76
|
|
|
75
77
|
// Convert up_down from HA UI to next command
|
|
76
|
-
if (
|
|
78
|
+
if (real_topic == "up_down")
|
|
77
79
|
{
|
|
78
80
|
if (msg.payload)
|
|
79
|
-
|
|
81
|
+
real_topic = "down";
|
|
80
82
|
else
|
|
81
|
-
|
|
83
|
+
real_topic = "up";
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
// Correct next topic to avoid handling up_stop, down_stop or toggle separately.
|
|
85
|
-
if (max_time_timeout != null && (
|
|
87
|
+
if (max_time_timeout != null && (real_topic == "up_stop" || real_topic == "down_stop" || real_topic == "toggle"))
|
|
86
88
|
{
|
|
87
|
-
|
|
89
|
+
real_topic = "stop";
|
|
88
90
|
}
|
|
89
91
|
else if (max_time_timeout == null)
|
|
90
92
|
{
|
|
91
93
|
// shutter is not running, set next command depending on topic
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
else if (
|
|
95
|
-
|
|
96
|
-
else if (
|
|
97
|
-
|
|
98
|
-
else if (!
|
|
99
|
-
|
|
94
|
+
if (real_topic == "up_stop")
|
|
95
|
+
real_topic = "up";
|
|
96
|
+
else if (real_topic == "down_stop")
|
|
97
|
+
real_topic = "down";
|
|
98
|
+
else if (node_settings.last_direction_up && real_topic == "toggle")
|
|
99
|
+
real_topic = "down";
|
|
100
|
+
else if (!node_settings.last_direction_up && real_topic == "toggle")
|
|
101
|
+
real_topic = "up";
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
// console.log("Convert topic to: " +
|
|
104
|
+
// console.log("Convert topic to: " + real_topic);
|
|
103
105
|
|
|
104
|
-
switch (
|
|
106
|
+
switch (real_topic)
|
|
105
107
|
{
|
|
106
108
|
case "up":
|
|
107
109
|
if (max_time_timeout != null)
|
|
108
110
|
{
|
|
109
111
|
// Nothing todo
|
|
110
|
-
if (
|
|
112
|
+
if (node_settings.last_direction_up)
|
|
111
113
|
return;
|
|
112
114
|
|
|
113
115
|
// Runs down at the moment, so stop first
|
|
114
|
-
if (
|
|
116
|
+
if (node_settings.last_direction_up == false)
|
|
115
117
|
{
|
|
116
118
|
// console.log("--- Sub topic ---");
|
|
117
119
|
handleTopic({ topic: "stop" });
|
|
@@ -123,7 +125,7 @@ module.exports = function (RED)
|
|
|
123
125
|
resultUp = true;
|
|
124
126
|
startAutoOff(false, helper.getTimeInMsFromString(msg.time_on) || null);
|
|
125
127
|
if (!alarm_active)
|
|
126
|
-
node.status({ fill: "green", shape: "dot", text:
|
|
128
|
+
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Up" });
|
|
127
129
|
break;
|
|
128
130
|
|
|
129
131
|
case "stop":
|
|
@@ -134,25 +136,25 @@ module.exports = function (RED)
|
|
|
134
136
|
if (max_time_timeout != null)
|
|
135
137
|
{
|
|
136
138
|
const change_percentage = (Date.now() - on_time) / 1000 / max_time * 100;
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
+
if (node_settings.last_direction_up)
|
|
140
|
+
node_settings.last_position = Math.max(0, node_settings.last_position - change_percentage);
|
|
139
141
|
else
|
|
140
|
-
|
|
142
|
+
node_settings.last_position = Math.min(100, node_settings.last_position + change_percentage);
|
|
141
143
|
}
|
|
142
144
|
off_time = Date.now();
|
|
143
145
|
stopAutoOff();
|
|
144
|
-
node.status({ fill: "red", shape: "dot", text:
|
|
146
|
+
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Stopped at " + Math.round(node_settings.last_position) + "%" });
|
|
145
147
|
break;
|
|
146
148
|
|
|
147
149
|
case "down":
|
|
148
150
|
if (max_time_timeout != null)
|
|
149
151
|
{
|
|
150
152
|
// Nothing todo
|
|
151
|
-
if (
|
|
153
|
+
if (node_settings.last_direction_up == false)
|
|
152
154
|
return;
|
|
153
155
|
|
|
154
156
|
// Runs up at the moment, so stop first
|
|
155
|
-
if (
|
|
157
|
+
if (node_settings.last_direction_up)
|
|
156
158
|
{
|
|
157
159
|
// console.log("--- Sub topic ---");
|
|
158
160
|
handleTopic({ topic: "stop" });
|
|
@@ -164,7 +166,7 @@ module.exports = function (RED)
|
|
|
164
166
|
resultDown = true;
|
|
165
167
|
startAutoOff(true, helper.getTimeInMsFromString(msg.time_on) || null);
|
|
166
168
|
if (!alarm_active)
|
|
167
|
-
node.status({ fill: "green", shape: "dot", text:
|
|
169
|
+
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Down" });
|
|
168
170
|
break;
|
|
169
171
|
|
|
170
172
|
case "position":
|
|
@@ -183,21 +185,21 @@ module.exports = function (RED)
|
|
|
183
185
|
// Change position while running,
|
|
184
186
|
// Calculate current position first
|
|
185
187
|
const change_percentage = (now - on_time) / 1000 / max_time * 100;
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
+
if (node_settings.last_direction_up)
|
|
189
|
+
node_settings.last_position = Math.max(0, node_settings.last_position - change_percentage);
|
|
188
190
|
else
|
|
189
|
-
|
|
191
|
+
node_settings.last_position = Math.min(100, node_settings.last_position + change_percentage);
|
|
190
192
|
|
|
191
|
-
node.status({ fill: "gray", shape: "dot", text:
|
|
193
|
+
node.status({ fill: "gray", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Update current position to " + node_settings.last_position + "%" });
|
|
192
194
|
|
|
193
195
|
// Runs in the wrong direction at the moment, so stop first
|
|
194
|
-
if (
|
|
196
|
+
if (node_settings.last_direction_up && value > node_settings.last_position)
|
|
195
197
|
{
|
|
196
198
|
// console.log("--- Sub topic ---");
|
|
197
199
|
handleTopic({ topic: "stop" });
|
|
198
200
|
// console.log("-----------------");
|
|
199
201
|
}
|
|
200
|
-
else if (
|
|
202
|
+
else if (node_settings.last_direction_up == false && value < node_settings.last_position)
|
|
201
203
|
{
|
|
202
204
|
// console.log("--- Sub topic ---");
|
|
203
205
|
handleTopic({ topic: "stop" });
|
|
@@ -207,17 +209,17 @@ module.exports = function (RED)
|
|
|
207
209
|
|
|
208
210
|
on_time = now;
|
|
209
211
|
|
|
210
|
-
if (value <
|
|
212
|
+
if (value < node_settings.last_position)
|
|
211
213
|
{
|
|
212
214
|
// Go up
|
|
213
215
|
resultUp = true;
|
|
214
|
-
startAutoOff(false, (
|
|
216
|
+
startAutoOff(false, (node_settings.last_position - value) / 100 * max_time * 1000, value);
|
|
215
217
|
}
|
|
216
|
-
else if (value >
|
|
218
|
+
else if (value > node_settings.last_position)
|
|
217
219
|
{
|
|
218
220
|
// Go down
|
|
219
221
|
resultDown = true;
|
|
220
|
-
startAutoOff(true, (value -
|
|
222
|
+
startAutoOff(true, (value - node_settings.last_position) / 100 * max_time * 1000, value);
|
|
221
223
|
}
|
|
222
224
|
else
|
|
223
225
|
{
|
|
@@ -226,7 +228,7 @@ module.exports = function (RED)
|
|
|
226
228
|
return;
|
|
227
229
|
}
|
|
228
230
|
|
|
229
|
-
node.status({ fill: "green", shape: "dot", text:
|
|
231
|
+
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Set position from " + node_settings.last_position + "% to " + value + "%" });
|
|
230
232
|
break;
|
|
231
233
|
|
|
232
234
|
case "alarm":
|
|
@@ -234,7 +236,7 @@ module.exports = function (RED)
|
|
|
234
236
|
|
|
235
237
|
if (alarm_active)
|
|
236
238
|
{
|
|
237
|
-
node.status({ fill: "red", shape: "dot", text:
|
|
239
|
+
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": ALARM is active" });
|
|
238
240
|
|
|
239
241
|
switch (alarm_action)
|
|
240
242
|
{
|
|
@@ -277,32 +279,30 @@ module.exports = function (RED)
|
|
|
277
279
|
if (wait_time_ms == null)
|
|
278
280
|
{
|
|
279
281
|
if (down)
|
|
280
|
-
wait_time_ms = (100 -
|
|
282
|
+
wait_time_ms = (100 - node_settings.last_position) * max_time / 100 * 1000;
|
|
281
283
|
else
|
|
282
|
-
wait_time_ms =
|
|
284
|
+
wait_time_ms = node_settings.last_position * max_time / 100 * 1000;
|
|
283
285
|
|
|
284
286
|
// Run at least for 5 seconds
|
|
285
287
|
if (wait_time_ms < 5000)
|
|
286
288
|
wait_time_ms = 5000;
|
|
287
289
|
}
|
|
288
290
|
|
|
289
|
-
max_time_on = parseInt(wait_time_ms / 1000);
|
|
290
|
-
|
|
291
291
|
if (wait_time_ms < 0)
|
|
292
292
|
{
|
|
293
|
-
node.status({ fill: "red", shape: "dot", text:
|
|
293
|
+
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": time_on value has to be greater than 0" });
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
if (!alarm_active)
|
|
298
|
-
node.status({ fill: "yellow", shape: "ring", text:
|
|
298
|
+
node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": " + (down ? "Down" : "Up") + ", wait " + helper.formatMsToStatus(wait_time_ms, "until") + " for auto off" });
|
|
299
299
|
|
|
300
300
|
max_time_timeout = setTimeout(() =>
|
|
301
301
|
{
|
|
302
302
|
handleTopic({ topic: "stop" });
|
|
303
303
|
if (new_position != null)
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
node_settings.last_position = new_position;
|
|
305
|
+
smart_context.set(node.id, node_settings);
|
|
306
306
|
}, wait_time_ms);
|
|
307
307
|
};
|
|
308
308
|
|
|
@@ -312,7 +312,7 @@ module.exports = function (RED)
|
|
|
312
312
|
{
|
|
313
313
|
// console.log("stopAutoOff");
|
|
314
314
|
if (!alarm_active)
|
|
315
|
-
node.status({ fill: "green", shape: "dot", text:
|
|
315
|
+
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Stopped at " + Math.round(node_settings.last_position) + "%" });
|
|
316
316
|
clearTimeout(max_time_timeout);
|
|
317
317
|
off_time = Date.now();
|
|
318
318
|
max_time_timeout = null;
|
|
@@ -333,7 +333,7 @@ module.exports = function (RED)
|
|
|
333
333
|
if (off_time + revert_time_ms > now)
|
|
334
334
|
{
|
|
335
335
|
// Output has to possibly wait until the revert time has passed
|
|
336
|
-
if ((
|
|
336
|
+
if ((node_settings.last_direction_up && down) || (node_settings.last_direction_up == false && up))
|
|
337
337
|
{
|
|
338
338
|
// console.log("Start wait timeout for " + (off_time + revert_time_ms - now) + "ms");
|
|
339
339
|
|
|
@@ -360,8 +360,8 @@ module.exports = function (RED)
|
|
|
360
360
|
{
|
|
361
361
|
if (!alarm_active || alarm_action === "UP")
|
|
362
362
|
{
|
|
363
|
-
|
|
364
|
-
node.send([{ payload: true }, { payload: false }, { payload:
|
|
363
|
+
node_settings.last_direction_up = true;
|
|
364
|
+
node.send([{ payload: true }, { payload: false }, { payload: node_settings.last_position }]);
|
|
365
365
|
notifyCentral(true);
|
|
366
366
|
}
|
|
367
367
|
}
|
|
@@ -369,14 +369,14 @@ module.exports = function (RED)
|
|
|
369
369
|
{
|
|
370
370
|
if (!alarm_active || alarm_action === "DOWN")
|
|
371
371
|
{
|
|
372
|
-
|
|
373
|
-
node.send([{ payload: false }, { payload: true }, { payload:
|
|
372
|
+
node_settings.last_direction_up = false;
|
|
373
|
+
node.send([{ payload: false }, { payload: true }, { payload: node_settings.last_position }]);
|
|
374
374
|
notifyCentral(true);
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
else if (stop && !alarm_active)
|
|
378
378
|
{
|
|
379
|
-
node.send([{ payload: false }, { payload: false }, { payload:
|
|
379
|
+
node.send([{ payload: false }, { payload: false }, { payload: node_settings.last_position }]);
|
|
380
380
|
notifyCentral(false);
|
|
381
381
|
}
|
|
382
382
|
};
|
|
@@ -397,8 +397,8 @@ module.exports = function (RED)
|
|
|
397
397
|
// For security reason, stop shutter at node start
|
|
398
398
|
setTimeout(() =>
|
|
399
399
|
{
|
|
400
|
-
node.send([{ payload: false }, { payload: false }, { payload:
|
|
401
|
-
node.status({ fill: "red", shape: "dot", text:
|
|
400
|
+
node.send([{ payload: false }, { payload: false }, { payload: node_settings.last_position }]);
|
|
401
|
+
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Stopped at " + Math.round(node_settings.last_position) + "%" });
|
|
402
402
|
notifyCentral(false);
|
|
403
403
|
}, 10000);
|
|
404
404
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
module.exports = function (RED)
|
|
2
2
|
{
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
3
5
|
function ShutterControlNode(config)
|
|
4
6
|
{
|
|
5
7
|
const node = this;
|
|
6
8
|
RED.nodes.createNode(node, config);
|
|
7
9
|
|
|
8
|
-
const
|
|
10
|
+
const smart_context = require("../persistence.js")(RED);
|
|
9
11
|
const helper = require("../smart_helper.js");
|
|
10
12
|
|
|
11
13
|
// used from text-exec node
|
|
@@ -15,10 +17,10 @@ module.exports = function (RED)
|
|
|
15
17
|
node.exec_text_names = [];
|
|
16
18
|
|
|
17
19
|
// persistent values
|
|
18
|
-
var
|
|
20
|
+
var node_settings = Object.assign({}, {
|
|
19
21
|
last_position: 0, // 0 = opened, 100 = closed
|
|
20
22
|
last_direction_up: true, // remember last direction for toggle action
|
|
21
|
-
},
|
|
23
|
+
}, smart_context.get(node.id));
|
|
22
24
|
|
|
23
25
|
// dynamic config
|
|
24
26
|
|
|
@@ -34,13 +36,13 @@ module.exports = function (RED)
|
|
|
34
36
|
}
|
|
35
37
|
RED.events.on(event, handler);
|
|
36
38
|
|
|
37
|
-
node.status({ fill: "red", shape: "dot", text:
|
|
39
|
+
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Stopped at " + Math.round(node_settings.last_position) + "%" });
|
|
38
40
|
|
|
39
41
|
node.on("input", function (msg)
|
|
40
42
|
{
|
|
41
43
|
handleTopic(msg);
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
smart_context.set(node.id, node_settings);
|
|
44
46
|
});
|
|
45
47
|
|
|
46
48
|
node.on("close", function ()
|
|
@@ -55,64 +57,64 @@ module.exports = function (RED)
|
|
|
55
57
|
var resultStop = null;
|
|
56
58
|
var resultPosition = null;
|
|
57
59
|
|
|
58
|
-
var
|
|
60
|
+
var real_topic = helper.getTopicName(msg.topic);
|
|
59
61
|
|
|
60
62
|
// set default topic
|
|
61
|
-
if (!["status", "status_position", "up_down", "up", "up_stop", "down", "down_stop", "stop", "toggle", "position"].includes(
|
|
62
|
-
|
|
63
|
+
if (!["status", "status_position", "up_down", "up", "up_stop", "down", "down_stop", "stop", "toggle", "position"].includes(real_topic))
|
|
64
|
+
real_topic = "toggle";
|
|
63
65
|
|
|
64
66
|
// skip if button is released
|
|
65
|
-
if (msg.payload === false && ["up", "up_stop", "down", "down_stop", "stop", "toggle"].includes(
|
|
67
|
+
if (msg.payload === false && ["up", "up_stop", "down", "down_stop", "stop", "toggle"].includes(real_topic))
|
|
66
68
|
return;
|
|
67
69
|
|
|
68
70
|
// Correct next topic to avoid handling up_stop, down_stop or toggle separately.
|
|
69
|
-
if ((max_time_on_timeout != null || is_running) && (
|
|
71
|
+
if ((max_time_on_timeout != null || is_running) && (real_topic == "up_stop" || real_topic == "down_stop" || real_topic == "toggle"))
|
|
70
72
|
{
|
|
71
|
-
|
|
73
|
+
real_topic = "stop";
|
|
72
74
|
}
|
|
73
75
|
else if (max_time_on_timeout == null && !is_running)
|
|
74
76
|
{
|
|
75
77
|
// shutter is not running, set next command depending on topic
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
else if (
|
|
79
|
-
|
|
80
|
-
else if (
|
|
81
|
-
|
|
82
|
-
else if (!
|
|
83
|
-
|
|
78
|
+
if (real_topic == "up_stop")
|
|
79
|
+
real_topic = "up";
|
|
80
|
+
else if (real_topic == "down_stop")
|
|
81
|
+
real_topic = "down";
|
|
82
|
+
else if (node_settings.last_direction_up && real_topic == "toggle")
|
|
83
|
+
real_topic = "down";
|
|
84
|
+
else if (!node_settings.last_direction_up && real_topic == "toggle")
|
|
85
|
+
real_topic = "up";
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
|
|
87
|
-
switch (
|
|
89
|
+
switch (real_topic)
|
|
88
90
|
{
|
|
89
91
|
case "status":
|
|
90
92
|
case "status_position":
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
node_settings.last_direction_up = node_settings.last_position > msg.payload;
|
|
94
|
+
node_settings.last_position = msg.payload;
|
|
93
95
|
|
|
94
96
|
if (is_running && (msg.payload == 0 || msg.payload == 100))
|
|
95
97
|
is_running = false;
|
|
96
98
|
|
|
97
|
-
node.status({ fill: "yellow", shape: "ring", text:
|
|
99
|
+
node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": Position status received: " + msg.payload + "%" });
|
|
98
100
|
return;
|
|
99
101
|
|
|
100
102
|
// This is only used to track starting of the shutter
|
|
101
103
|
case "up_down":
|
|
102
|
-
|
|
104
|
+
node_settings.last_direction_up = !msg.payload;
|
|
103
105
|
is_running = true;
|
|
104
106
|
|
|
105
|
-
if (
|
|
106
|
-
node.status({ fill: "green", shape: "dot", text:
|
|
107
|
+
if (node_settings.last_direction_up)
|
|
108
|
+
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Up" });
|
|
107
109
|
else
|
|
108
|
-
node.status({ fill: "green", shape: "dot", text:
|
|
110
|
+
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Down" });
|
|
109
111
|
return;
|
|
110
112
|
|
|
111
113
|
case "up":
|
|
112
|
-
|
|
114
|
+
node_settings.last_direction_up = true;
|
|
113
115
|
is_running = true;
|
|
114
116
|
resultUpDown = false;
|
|
115
|
-
node.status({ fill: "green", shape: "dot", text:
|
|
117
|
+
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Up" });
|
|
116
118
|
startAutoOffIfNeeded(msg);
|
|
117
119
|
break;
|
|
118
120
|
|
|
@@ -120,14 +122,14 @@ module.exports = function (RED)
|
|
|
120
122
|
is_running = false;
|
|
121
123
|
resultStop = true;
|
|
122
124
|
stopAutoOff();
|
|
123
|
-
node.status({ fill: "green", shape: "dot", text:
|
|
125
|
+
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Stopped" });
|
|
124
126
|
break;
|
|
125
127
|
|
|
126
128
|
case "down":
|
|
127
|
-
|
|
129
|
+
node_settings.last_direction_up = false;
|
|
128
130
|
is_running = true;
|
|
129
131
|
resultUpDown = true;
|
|
130
|
-
node.status({ fill: "green", shape: "dot", text:
|
|
132
|
+
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Down" });
|
|
131
133
|
startAutoOffIfNeeded(msg);
|
|
132
134
|
break;
|
|
133
135
|
|
|
@@ -138,7 +140,7 @@ module.exports = function (RED)
|
|
|
138
140
|
if (value > 100) value = 100;
|
|
139
141
|
// is_running = true; // Not guaranteed that the shutter starts running.
|
|
140
142
|
resultPosition = value;
|
|
141
|
-
node.status({ fill: "green", shape: "dot", text:
|
|
143
|
+
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Set position to " + value + "%" });
|
|
142
144
|
break;
|
|
143
145
|
}
|
|
144
146
|
|
|
@@ -166,23 +168,23 @@ module.exports = function (RED)
|
|
|
166
168
|
let timeMs = helper.getTimeInMsFromString(msg.time_on);
|
|
167
169
|
if (isNaN(timeMs))
|
|
168
170
|
{
|
|
169
|
-
node.status({ fill: "red", shape: "dot", text:
|
|
171
|
+
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Invalid time_on value send: " + msg.time_on });
|
|
170
172
|
return;
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
if (timeMs <= 0)
|
|
174
176
|
{
|
|
175
|
-
node.status({ fill: "red", shape: "dot", text:
|
|
177
|
+
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": time_on value has to be greater than 0" });
|
|
176
178
|
return;
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
// Stop if any timeout is set
|
|
180
182
|
stopAutoOff();
|
|
181
183
|
|
|
182
|
-
node.status({ fill: "yellow", shape: "ring", text:
|
|
184
|
+
node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": Wait " + (timeMs / 1000).toFixed(1) + " sec for auto off" });
|
|
183
185
|
max_time_on_timeout = setTimeout(() =>
|
|
184
186
|
{
|
|
185
|
-
node.status({ fill: "green", shape: "dot", text:
|
|
187
|
+
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Stopped" });
|
|
186
188
|
is_running = false;
|
|
187
189
|
node.send([null, { payload: true }, null]);
|
|
188
190
|
notifyCentral(false);
|