node-red-contrib-looptimer-advanced 0.0.8 → 0.0.9

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/README.md CHANGED
@@ -50,7 +50,7 @@ You can define maximum number of loops with `msg.loop.maxloops`
50
50
 
51
51
  Setting the Max Loops and Max Timeout settings to high values can, for all intents, ensure that the loop can only be stopped by an incoming `stop` payload, however, the stability of the loop has not been tested over an extended number of hours.
52
52
 
53
-
53
+ **0.0.9** - Bugfix for Minutes, and minor improvements to code quality
54
54
  **0.0.8** - Fix Until Node-Red Does Not Get Fixed on issue #3867
55
55
  **0.0.7** - Update Loop Dependency version as older version is not compatible with higher version Node.JS
56
56
  **0.0.6** - Added Example Flow and updated dependencies
@@ -10,7 +10,13 @@ module.exports = function (RED) {
10
10
  { unit: "Day", multiplier: 24, get duration() { return unitMap[3].duration * unitMap[4].multiplier } }
11
11
  ]
12
12
 
13
- var CalcDuration = function (unit, duration) { return (unitMap.find(o => o.unit === unit).duration * duration); }
13
+ var CalcDuration = function (unit, duration) {
14
+ const unitObj = unitMap.find(o => o.unit === unit);
15
+ if (!unitObj) {
16
+ throw new Error(`Invalid unit: ${unit}`);
17
+ }
18
+ return unitObj.duration * duration;
19
+ };
14
20
  function LoopTimer(n) {
15
21
  RED.nodes.createNode(this, n);
16
22
 
@@ -44,11 +50,11 @@ module.exports = function (RED) {
44
50
  if (msg.loop != undefined) {
45
51
 
46
52
  if (msg.loop.units != undefined) {
47
- if ((msg.loop.units === "Millisecond") || (msg.loop.units === "Second") || (msg.loop.units === "Hour") || (msg.loop.units === "Day")) {
53
+ if ((msg.loop.units === "Millisecond") || (msg.loop.units === "Second") || (msg.loop.units === "Minute") || (msg.loop.units === "Hour") || (msg.loop.units === "Day")) {
48
54
  node.units = msg.loop.units;
49
55
  } else {
50
- node.status({ fill: "red", shape: "ring", text: "Invalid attribbute msg.loop.units" });
51
- node.error('Invalid Attribbute: msg.loop.units, allowed values are Millisecond, Second, Minute, Hour, and Day');
56
+ node.status({ fill: "red", shape: "ring", text: "Invalid Attribute msg.loop.units" });
57
+ node.error('Invalid Attribute: msg.loop.units, allowed values are Millisecond, Second, Minute, Hour, and Day');
52
58
  return;
53
59
  }
54
60
  }
@@ -59,17 +65,17 @@ module.exports = function (RED) {
59
65
  node.duration = msg.loop.duration;
60
66
  } else {
61
67
  node.status({ fill: "red", shape: "ring", text: "msg.loop.units must be an Integer" });
62
- node.error('Invalid Attribbute: msg.loop.duration, value must be an Integer');
68
+ node.error('Invalid Attribute: msg.loop.duration, value must be an Integer');
63
69
  return;
64
70
  }
65
71
  }
66
72
 
67
73
  if (msg.loop.maxtimeoutunits != undefined) {
68
- if ((msg.loop.maxtimeoutunits === "Millisecond") || (msg.loop.maxtimeoutunits === "Second") || (msg.loop.maxtimeoutunits === "Hour") || (msg.loop.maxtimeoutunits === "Day")) {
74
+ if ((msg.loop.maxtimeoutunits === "Millisecond") || (msg.loop.maxtimeoutunits === "Second") || (msg.loop.maxtimeoutunits === "Minute") || (msg.loop.maxtimeoutunits === "Hour") || (msg.loop.maxtimeoutunits === "Day")) {
69
75
  node.maxtimeoutunits = msg.loop.maxtimeoutunits;
70
76
  } else {
71
- node.status({ fill: "red", shape: "ring", text: "Invalid attribbute msg.loop.maxtimeoutunits" });
72
- node.error('Invalid Attribbute: msg.loop.maxtimeoutunits, allowed values are Millisecond, Second, Minute, Hour, and Day');
77
+ node.status({ fill: "red", shape: "ring", text: "Invalid Attribute msg.loop.maxtimeoutunits" });
78
+ node.error('Invalid Attribute: msg.loop.maxtimeoutunits, allowed values are Millisecond, Second, Minute, Hour, and Day');
73
79
  return;
74
80
  }
75
81
  }
@@ -80,7 +86,7 @@ module.exports = function (RED) {
80
86
  node.maxtimeout = msg.loop.maxtimeout;
81
87
  } else {
82
88
  node.status({ fill: "red", shape: "ring", text: "msg.loop.maxtimeout must be an Integer" });
83
- node.error('Invalid Attribbute: msg.loop.maxtimeout, value must be an Integer');
89
+ node.error('Invalid Attribute: msg.loop.maxtimeout, value must be an Integer');
84
90
  return;
85
91
  }
86
92
  }
@@ -89,7 +95,7 @@ module.exports = function (RED) {
89
95
  node.maxloops = msg.loop.maxloops;
90
96
  } else {
91
97
  node.status({ fill: "red", shape: "ring", text: "msg.loop.maxloops must be an Integer" });
92
- node.error('Invalid Attribbute: msg.loop.maxloops, value must be an Integer');
98
+ node.error('Invalid Attribute: msg.loop.maxloops, value must be an Integer');
93
99
  return;
94
100
  }
95
101
  }
@@ -108,7 +114,7 @@ module.exports = function (RED) {
108
114
  stopped = false;
109
115
  clearTimeout(timeout);
110
116
  timeout = null;
111
- if (msg.payload == "stop" || msg.payload == "STOP") {
117
+ if (msg.payload.toLowerCase() === "stop") {
112
118
  node.status({
113
119
  fill: "red",
114
120
  shape: "ring",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-looptimer-advanced",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Sends the msg through the first output, then continues to do so in a loop, once per the duration specified, until a payload of 'stop' or 'STOP' is received. Supports override with messages!",
5
5
  "main": "looptimer_advanced.js",
6
6
  "scripts": {},