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.
@@ -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 smartContext = require("../persistence.js")(RED);
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 nodeSettings = Object.assign({}, {
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
- }, smartContext.get(node.id));
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
- smartContext.set(node.id, nodeSettings);
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 realTopic = helper.getTopicName(msg.topic);
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(realTopic))
69
- realTopic = "toggle";
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(realTopic))
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 (realTopic == "up_down")
78
+ if (real_topic == "up_down")
77
79
  {
78
80
  if (msg.payload)
79
- realTopic = "down";
81
+ real_topic = "down";
80
82
  else
81
- realTopic = "up";
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 && (realTopic == "up_stop" || realTopic == "down_stop" || realTopic == "toggle"))
87
+ if (max_time_timeout != null && (real_topic == "up_stop" || real_topic == "down_stop" || real_topic == "toggle"))
86
88
  {
87
- realTopic = "stop";
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 (realTopic == "up_stop")
93
- realTopic = "up";
94
- else if (realTopic == "down_stop")
95
- realTopic = "down";
96
- else if (nodeSettings.last_direction_up && realTopic == "toggle")
97
- realTopic = "down";
98
- else if (!nodeSettings.last_direction_up && realTopic == "toggle")
99
- realTopic = "up";
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: " + realTopic);
104
+ // console.log("Convert topic to: " + real_topic);
103
105
 
104
- switch (realTopic)
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 (nodeSettings.last_direction_up)
112
+ if (node_settings.last_direction_up)
111
113
  return;
112
114
 
113
115
  // Runs down at the moment, so stop first
114
- if (nodeSettings.last_direction_up == false)
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: (new Date()).toLocaleString() + ": Up" });
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 (nodeSettings.last_direction_up)
138
- nodeSettings.last_position = Math.max(0, nodeSettings.last_position - change_percentage);
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
- nodeSettings.last_position = Math.min(100, nodeSettings.last_position + change_percentage);
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: (new Date()).toLocaleString() + ": Stopped at " + Math.round(nodeSettings.last_position) + "%" });
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 (nodeSettings.last_direction_up == false)
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 (nodeSettings.last_direction_up)
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: (new Date()).toLocaleString() + ": Down" });
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 (nodeSettings.last_direction_up)
187
- nodeSettings.last_position = Math.max(0, nodeSettings.last_position - change_percentage);
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
- nodeSettings.last_position = Math.min(100, nodeSettings.last_position + change_percentage);
191
+ node_settings.last_position = Math.min(100, node_settings.last_position + change_percentage);
190
192
 
191
- node.status({ fill: "gray", shape: "dot", text: (new Date()).toLocaleString() + ": Update current position to " + nodeSettings.last_position + "%" });
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 (nodeSettings.last_direction_up && value > nodeSettings.last_position)
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 (nodeSettings.last_direction_up == false && value < nodeSettings.last_position)
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 < nodeSettings.last_position)
212
+ if (value < node_settings.last_position)
211
213
  {
212
214
  // Go up
213
215
  resultUp = true;
214
- startAutoOff(false, (nodeSettings.last_position - value) / 100 * max_time * 1000, value);
216
+ startAutoOff(false, (node_settings.last_position - value) / 100 * max_time * 1000, value);
215
217
  }
216
- else if (value > nodeSettings.last_position)
218
+ else if (value > node_settings.last_position)
217
219
  {
218
220
  // Go down
219
221
  resultDown = true;
220
- startAutoOff(true, (value - nodeSettings.last_position) / 100 * max_time * 1000, 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: (new Date()).toLocaleString() + ": Set position from " + nodeSettings.last_position + "% to " + value + "%" });
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: (new Date()).toLocaleString() + ": ALARM is active" });
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 - nodeSettings.last_position) * max_time / 100 * 1000;
282
+ wait_time_ms = (100 - node_settings.last_position) * max_time / 100 * 1000;
281
283
  else
282
- wait_time_ms = nodeSettings.last_position * max_time / 100 * 1000;
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: (new Date()).toLocaleString() + ": time_on value has to be greater than 0" });
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: (new Date()).toLocaleString() + ": " + (down ? "Down" : "Up") + ", wait " + helper.formatMsToStatus(max_time_on, "until") + " for auto off" });
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
- nodeSettings.last_position = new_position;
305
- smartContext.set(node.id, nodeSettings);
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: (new Date()).toLocaleString() + ": Stopped at " + Math.round(nodeSettings.last_position) + "%" });
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 ((nodeSettings.last_direction_up && down) || (nodeSettings.last_direction_up == false && up))
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
- nodeSettings.last_direction_up = true;
364
- node.send([{ payload: true }, { payload: false }, { payload: nodeSettings.last_position }]);
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
- nodeSettings.last_direction_up = false;
373
- node.send([{ payload: false }, { payload: true }, { payload: nodeSettings.last_position }]);
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: nodeSettings.last_position }]);
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: nodeSettings.last_position }]);
401
- node.status({ fill: "red", shape: "dot", text: (new Date()).toLocaleString() + ": Stopped at " + Math.round(nodeSettings.last_position) + "%" });
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 smartContext = require("../persistence.js")(RED);
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 nodeSettings = Object.assign({}, {
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
- }, smartContext.get(node.id));
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: (new Date()).toLocaleString() + ": Stopped at " + Math.round(nodeSettings.last_position) + "%" });
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
- smartContext.set(node.id, nodeSettings);
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 realTopic = helper.getTopicName(msg.topic);
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(realTopic))
62
- realTopic = "toggle";
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(realTopic))
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) && (realTopic == "up_stop" || realTopic == "down_stop" || realTopic == "toggle"))
71
+ if ((max_time_on_timeout != null || is_running) && (real_topic == "up_stop" || real_topic == "down_stop" || real_topic == "toggle"))
70
72
  {
71
- realTopic = "stop";
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 (realTopic == "up_stop")
77
- realTopic = "up";
78
- else if (realTopic == "down_stop")
79
- realTopic = "down";
80
- else if (nodeSettings.last_direction_up && realTopic == "toggle")
81
- realTopic = "down";
82
- else if (!nodeSettings.last_direction_up && realTopic == "toggle")
83
- realTopic = "up";
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 (realTopic)
89
+ switch (real_topic)
88
90
  {
89
91
  case "status":
90
92
  case "status_position":
91
- nodeSettings.last_direction_up = nodeSettings.last_position > msg.payload;
92
- nodeSettings.last_position = msg.payload;
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: (new Date()).toLocaleString() + ": Position status received: " + msg.payload + "%" });
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
- nodeSettings.last_direction_up = !msg.payload;
104
+ node_settings.last_direction_up = !msg.payload;
103
105
  is_running = true;
104
106
 
105
- if (nodeSettings.last_direction_up)
106
- node.status({ fill: "green", shape: "dot", text: (new Date()).toLocaleString() + ": Up" });
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: (new Date()).toLocaleString() + ": Down" });
110
+ node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Down" });
109
111
  return;
110
112
 
111
113
  case "up":
112
- nodeSettings.last_direction_up = true;
114
+ node_settings.last_direction_up = true;
113
115
  is_running = true;
114
116
  resultUpDown = false;
115
- node.status({ fill: "green", shape: "dot", text: (new Date()).toLocaleString() + ": Up" });
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: (new Date()).toLocaleString() + ": Stopped" });
125
+ node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Stopped" });
124
126
  break;
125
127
 
126
128
  case "down":
127
- nodeSettings.last_direction_up = false;
129
+ node_settings.last_direction_up = false;
128
130
  is_running = true;
129
131
  resultUpDown = true;
130
- node.status({ fill: "green", shape: "dot", text: (new Date()).toLocaleString() + ": Down" });
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: (new Date()).toLocaleString() + ": Set position to " + value + "%" });
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: (new Date()).toLocaleString() + ": Invalid time_on value send: " + msg.time_on });
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: (new Date()).toLocaleString() + ": time_on value has to be greater than 0" });
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: (new Date()).toLocaleString() + ": Wait " + (timeMs / 1000).toFixed(1) + " sec for auto off" });
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: (new Date()).toLocaleString() + ": Stopped" });
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);