smart-nodes 0.3.33 → 0.3.35
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/delay/delay.js +4 -2
- package/forwarder/forwarder.js +1 -1
- package/hysteresis/hysteresis.js +2 -2
- package/light-control/light-control.js +1 -1
- package/package.json +1 -1
- package/smart_helper.js +10 -0
package/delay/delay.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const smart_helper = require("../smart_helper.js");
|
|
2
|
+
|
|
1
3
|
module.exports = function (RED)
|
|
2
4
|
{
|
|
3
5
|
"use strict";
|
|
@@ -140,7 +142,7 @@ module.exports = function (RED)
|
|
|
140
142
|
if (delay_ms <= 0)
|
|
141
143
|
{
|
|
142
144
|
node.status({ fill: "yellow", shape: "dot", text: helper.getCurrentTimeForStatus() + ": " + "Sended " + getMessageStatusText(msg) });
|
|
143
|
-
node_settings.last_message = msg
|
|
145
|
+
node_settings.last_message = helper.cloneObject(msg);
|
|
144
146
|
|
|
145
147
|
if (config.save_state)
|
|
146
148
|
smart_context.set(node.id, node_settings);
|
|
@@ -155,7 +157,7 @@ module.exports = function (RED)
|
|
|
155
157
|
{
|
|
156
158
|
timeout = null;
|
|
157
159
|
node.status({ fill: "yellow", shape: "dot", text: helper.getCurrentTimeForStatus() + ": " + "Sended " + getMessageStatusText(msg) });
|
|
158
|
-
node_settings.last_message = msg
|
|
160
|
+
node_settings.last_message = helper.cloneObject(msg);
|
|
159
161
|
|
|
160
162
|
if (config.save_state)
|
|
161
163
|
smart_context.set(node.id, node_settings);
|
package/forwarder/forwarder.js
CHANGED
package/hysteresis/hysteresis.js
CHANGED
|
@@ -114,10 +114,10 @@ module.exports = function (RED)
|
|
|
114
114
|
node.send(out_msg);
|
|
115
115
|
|
|
116
116
|
node_settings.last_result = result;
|
|
117
|
+
node_settings.last_message = out_msg;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
node_settings.last_value = value;
|
|
120
|
-
node_settings.last_message = out_msg;
|
|
121
121
|
|
|
122
122
|
setStatus(result === null);
|
|
123
123
|
|
|
@@ -168,7 +168,7 @@ module.exports = function (RED)
|
|
|
168
168
|
})
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
if (config.save_state && config.resend_on_start && node_settings.last_result
|
|
171
|
+
if (config.save_state && config.resend_on_start && node_settings.last_result !== null && node_settings.last_message !== null)
|
|
172
172
|
{
|
|
173
173
|
setTimeout(() =>
|
|
174
174
|
{
|
|
@@ -222,7 +222,7 @@ module.exports = function (RED)
|
|
|
222
222
|
}
|
|
223
223
|
else if (node_settings.last_value)
|
|
224
224
|
{
|
|
225
|
-
if (isPermanent || isMotion ||
|
|
225
|
+
if (isPermanent || isMotion || max_time_on_timeout == null)
|
|
226
226
|
node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": On" });
|
|
227
227
|
else if (max_time_on_timeout)
|
|
228
228
|
node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": Wait " + helper.formatDateToStatus(timeout_end_date, "until") + " for auto off" });
|
package/package.json
CHANGED
package/smart_helper.js
CHANGED
|
@@ -295,5 +295,15 @@ module.exports = {
|
|
|
295
295
|
return date.getHours().toString().padStart(2, "0") + ":" +
|
|
296
296
|
date.getMinutes().toString().padStart(2, "0") + ":" +
|
|
297
297
|
date.getSeconds().toString().padStart(2, "0");
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Creates a new independend object and copies all properties to the new one
|
|
302
|
+
* @param {*} obj The Object to copy
|
|
303
|
+
* @returns A new Object
|
|
304
|
+
*/
|
|
305
|
+
cloneObject(obj)
|
|
306
|
+
{
|
|
307
|
+
return Object.assign({}, obj);
|
|
298
308
|
}
|
|
299
309
|
};
|