smart-nodes 0.4.4 → 0.4.7
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
CHANGED
|
@@ -98,3 +98,15 @@
|
|
|
98
98
|
## Version 0.4.4:
|
|
99
99
|
|
|
100
100
|
- Fixed the delay node to not restart the time if "only on change" option is enabled.
|
|
101
|
+
|
|
102
|
+
## Version 0.4.5:
|
|
103
|
+
|
|
104
|
+
- Fixed the status of hysteresis node.
|
|
105
|
+
|
|
106
|
+
## Version 0.4.6:
|
|
107
|
+
|
|
108
|
+
- Fixed the status of hysteresis node.
|
|
109
|
+
|
|
110
|
+
## Version 0.4.7:
|
|
111
|
+
|
|
112
|
+
- Added blink topic to light node
|
package/hysteresis/hysteresis.js
CHANGED
|
@@ -173,7 +173,7 @@ module.exports = function (RED)
|
|
|
173
173
|
let setStatus = () =>
|
|
174
174
|
{
|
|
175
175
|
if (node_settings.last_result == null)
|
|
176
|
-
node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": ❓ S: " + node_settings.setpoint + " - H: " + node_settings.hysteresis + " - V: null" });
|
|
176
|
+
node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": ❓ S: " + node_settings.setpoint + " - H: " + node_settings.hysteresis + " - V: " + (node_settings.last_value?.toFixed(2) ?? "null") });
|
|
177
177
|
else
|
|
178
178
|
node.status({ fill: node_settings.last_result ? "green" : "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": " + (node_settings.last_result ? "⬆️" : "⬇️") + " S: " + node_settings.setpoint + " - H: " + node_settings.hysteresis + " - V: " + node_settings.last_value?.toFixed(2) });
|
|
179
179
|
}
|
package/light/light.js
CHANGED
|
@@ -62,6 +62,9 @@ module.exports = function (RED)
|
|
|
62
62
|
// The timeout starts only if the motion sensor goes off.
|
|
63
63
|
let isMotion = false;
|
|
64
64
|
|
|
65
|
+
// If this is on, ignore all state changes and don't restart any time measurement.
|
|
66
|
+
let isBlinking = false;
|
|
67
|
+
|
|
65
68
|
// Here the date is stored, when the light should go off.
|
|
66
69
|
// This is used to calculate the node status.
|
|
67
70
|
let timeout_end_date = null;
|
|
@@ -109,6 +112,10 @@ module.exports = function (RED)
|
|
|
109
112
|
switch (real_topic)
|
|
110
113
|
{
|
|
111
114
|
case "status":
|
|
115
|
+
// Ignore if is in blinking mode
|
|
116
|
+
if (isBlinking)
|
|
117
|
+
return;
|
|
118
|
+
|
|
112
119
|
// Make sure it is bool
|
|
113
120
|
msg.payload = !!msg.payload;
|
|
114
121
|
|
|
@@ -230,6 +237,24 @@ module.exports = function (RED)
|
|
|
230
237
|
|
|
231
238
|
break;
|
|
232
239
|
|
|
240
|
+
case "blink":
|
|
241
|
+
if (!node_settings.alarm_active)
|
|
242
|
+
{
|
|
243
|
+
isBlinking = true;
|
|
244
|
+
node.send({ payload: !node_settings.last_value });
|
|
245
|
+
setStatus();
|
|
246
|
+
setTimeout(
|
|
247
|
+
() =>
|
|
248
|
+
{
|
|
249
|
+
isBlinking = false;
|
|
250
|
+
node.send({ payload: node_settings.last_value });
|
|
251
|
+
setStatus();
|
|
252
|
+
},
|
|
253
|
+
helper.getTimeInMsFromString(msg.time_on, 500)
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
return;
|
|
257
|
+
|
|
233
258
|
default:
|
|
234
259
|
node_settings.last_value_sended = !node_settings.last_value;
|
|
235
260
|
|
|
@@ -335,6 +360,10 @@ module.exports = function (RED)
|
|
|
335
360
|
{
|
|
336
361
|
node.status({ fill: "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": ALARM is active" });
|
|
337
362
|
}
|
|
363
|
+
else if (isBlinking)
|
|
364
|
+
{
|
|
365
|
+
node.status({ fill: "yellow", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Blink" });
|
|
366
|
+
}
|
|
338
367
|
else if (node_settings.last_value)
|
|
339
368
|
{
|
|
340
369
|
if (isPermanent || isMotion || timeout == null)
|
|
@@ -107,6 +107,14 @@
|
|
|
107
107
|
</td>
|
|
108
108
|
<td>Ja</td>
|
|
109
109
|
</tr>
|
|
110
|
+
<tr>
|
|
111
|
+
<td><code>blink</code></td>
|
|
112
|
+
<td>
|
|
113
|
+
Schaltet den Ausgang zweimal kurz um, ohne die laufende Zeitmessung zu unterbrechen. Dies kann verwendet werden um eine optische Rückmeldung für eine bestimmte Aktion zu ermöglichen.<br/>
|
|
114
|
+
Die Standardzeit beträgt 0,5 Sekunden, kann aber mittels <code>msg.time_on</code> überschrieben werden.
|
|
115
|
+
</td>
|
|
116
|
+
<td>Ja</td>
|
|
117
|
+
</tr>
|
|
110
118
|
</tbody>
|
|
111
119
|
</table>
|
|
112
120
|
</p>
|
|
@@ -106,6 +106,14 @@
|
|
|
106
106
|
</td>
|
|
107
107
|
<td>Yes</td>
|
|
108
108
|
</tr>
|
|
109
|
+
<tr>
|
|
110
|
+
<td><code>blink</code></td>
|
|
111
|
+
<td>
|
|
112
|
+
Toggles the output twice briefly without interrupting the ongoing time measurement. This can be used to provide visual feedback for a specific action.<br/>
|
|
113
|
+
The default time is 0.5 seconds, but can be overridden using <code>msg.time_on</code>.
|
|
114
|
+
</td>
|
|
115
|
+
<td>Yes</td>
|
|
116
|
+
</tr>
|
|
109
117
|
</tbody>
|
|
110
118
|
</table>
|
|
111
119
|
</p>
|
|
@@ -233,12 +233,9 @@ module.exports = function (RED)
|
|
|
233
233
|
// Calculate change time
|
|
234
234
|
// Change time in ms for 1%
|
|
235
235
|
let moving_time = time_total * 1000 / 100;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
// 20 °C diff => 5% change
|
|
240
|
-
moving_time *= helper.scale(Math.min(temp_diff, 20), 0, 20, 0, 5);
|
|
241
|
-
}
|
|
236
|
+
// 0 °C diff => 0% change
|
|
237
|
+
// 20 °C diff => 2% change
|
|
238
|
+
moving_time *= helper.scale(Math.min(temp_diff, 20), 0, 20, 0, 2);
|
|
242
239
|
|
|
243
240
|
// calculate direction
|
|
244
241
|
let adjustAction = ADJUST_CLOSE;
|
|
@@ -263,9 +260,9 @@ module.exports = function (RED)
|
|
|
263
260
|
|
|
264
261
|
// Already oppened/closed
|
|
265
262
|
if (adjustAction == ADJUST_OPEN && node_settings.last_position == 100)
|
|
266
|
-
|
|
267
|
-
if (adjustAction == ADJUST_CLOSE && node_settings.last_position == 0)
|
|
268
|
-
|
|
263
|
+
time_ms = time_total * 1000 / 200; // Change at least 1/200 => 0.5 %
|
|
264
|
+
else if (adjustAction == ADJUST_CLOSE && node_settings.last_position == 0)
|
|
265
|
+
time_ms = time_total * 1000 / 200; // Change at least 1/200 => 0.5 %
|
|
269
266
|
|
|
270
267
|
adjusting_start_time = Date.now();
|
|
271
268
|
if (adjustAction == ADJUST_OPEN)
|
package/package.json
CHANGED
package/smart_helper.js
CHANGED
|
@@ -95,11 +95,11 @@ module.exports = {
|
|
|
95
95
|
* - m or min
|
|
96
96
|
* - h
|
|
97
97
|
*/
|
|
98
|
-
getTimeInMs(value, unit)
|
|
98
|
+
getTimeInMs(value, unit, defaultValue = 0)
|
|
99
99
|
{
|
|
100
100
|
value = parseFloat(value);
|
|
101
101
|
if (isNaN(value) || value == 0)
|
|
102
|
-
return
|
|
102
|
+
return defaultValue;
|
|
103
103
|
|
|
104
104
|
switch (unit)
|
|
105
105
|
{
|
|
@@ -161,23 +161,23 @@ module.exports = {
|
|
|
161
161
|
* - m or min
|
|
162
162
|
* - h
|
|
163
163
|
*/
|
|
164
|
-
getTimeInMsFromString(value)
|
|
164
|
+
getTimeInMsFromString(value, defaultValue = 0)
|
|
165
165
|
{
|
|
166
166
|
// default in ms
|
|
167
167
|
if (typeof value == "number")
|
|
168
168
|
return value;
|
|
169
169
|
|
|
170
170
|
if (typeof value != "string")
|
|
171
|
-
return
|
|
171
|
+
return defaultValue;
|
|
172
172
|
|
|
173
173
|
// Split 123min into ["123", "min"]
|
|
174
174
|
let values = value.match(/^([0-9]+[,.]?[0-9]*)(ms|s|sec|m|min|h|)?$/);
|
|
175
175
|
|
|
176
176
|
// string doesn't match
|
|
177
177
|
if (values == null)
|
|
178
|
-
return
|
|
178
|
+
return defaultValue;
|
|
179
179
|
|
|
180
|
-
return this.getTimeInMs(values[1].replace(",", "."), values[2] || "ms");
|
|
180
|
+
return this.getTimeInMs(values[1].replace(",", "."), values[2] || "ms", defaultValue);
|
|
181
181
|
},
|
|
182
182
|
|
|
183
183
|
/**
|