node-red-contrib-knx-ultimate 3.2.8 → 3.2.10

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
@@ -6,6 +6,12 @@
6
6
 
7
7
  # CHANGELOG
8
8
 
9
+ **Version 3.2.10** - October 2024<br/>
10
+ - Fixed a race condition happening whenever FULL DEPLOY is pressed in the node-red interface, preventing the HUE bridge node to gracefully disconnect from the HUE Bridge.<br/>
11
+
12
+ **Version 3.2.9** - October 2024<br/>
13
+ - Maintenance release: added some log to better identify problems.<br/>
14
+
9
15
  **Version 3.2.8** - October 2024<br/>
10
16
  - KNX Node: fixed "read status at startup" field not showing up in very old versions.<br/>
11
17
 
@@ -66,11 +66,16 @@ module.exports = (RED) => {
66
66
  try {
67
67
  const serverId = RED.nodes.getNode(req.query.serverId); // Retrieve node.id of the config node.
68
68
  if (serverId.hueAllResources === null || serverId.hueAllResources === undefined) {
69
- res.json({ ready: false });
69
+ (async function main() {
70
+ await serverId.loadResourcesFromHUEBridge();
71
+ res.json({ ready: false });
72
+ }()).catch();
70
73
  } else {
71
74
  res.json({ ready: true });
72
75
  }
73
76
  } catch (error) {
77
+ RED.log.error(`Errore RED.httpAdmin.get('/knxultimateCheckHueConnected' ${error.message}`);
78
+
74
79
  res.json({ ready: false });
75
80
  }
76
81
  });
@@ -477,18 +477,17 @@ module.exports = (RED) => {
477
477
  node.on("close", (done) => {
478
478
  try {
479
479
  if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger = null;
480
- loggerEngine.destroy();
481
480
  node.nodeClients = [];
482
- node.hueManager.removeAllListeners();
481
+ if (node.hueManager !== undefined && node.hueManager !== null) node.hueManager.removeAllListeners();
483
482
  (async () => {
484
483
  try {
485
484
  await node.hueManager.close();
486
485
  node.hueManager = null;
487
486
  delete node.hueManager;
487
+ done();
488
488
  } catch (error) {
489
- /* empty */
489
+ done();
490
490
  }
491
- done();
492
491
  })();
493
492
  } catch (error) {
494
493
  done();
@@ -720,11 +720,14 @@
720
720
  });
721
721
 
722
722
  // Timer connection to backend ####################################################
723
- this.timerWaitBackEnd;
724
723
  let timerWaitBackEndCounter = 0;
725
724
  function checkConnection() {
726
- if (this.timerBlinkBackground !== undefined) clearTimeout(this.timerBlinkBackground);
727
- this.timerBlinkBackground = setTimeout(() => {
725
+ if (this.timerWaitBackEnd !== undefined) clearTimeout(this.timerWaitBackEnd);
726
+ if ($("#node-input-serverHue").val() === undefined) {
727
+ // Someone has FULL deployed node-red, exit.
728
+ return;
729
+ }
730
+ this.timerWaitBackEnd = setTimeout(() => {
728
731
  timerWaitBackEndCounter++;
729
732
  if (timerWaitBackEndCounter > 20) {
730
733
  timerWaitBackEndCounter = 0;
@@ -121,7 +121,7 @@ module.exports.getBridgeDetails = async (_ip) => {
121
121
  simpleget.concat(opt, (err, res, data) => {
122
122
  try {
123
123
  if (err) {
124
- reject(err);
124
+ reject(new Error(err.message || 'getBridgeDetails general error'));
125
125
  } else {
126
126
  // log.trace('http data ' + data);
127
127
  if (res.statusCode >= 100 && res.statusCode < 400) {
@@ -44,8 +44,11 @@ class classHUE extends EventEmitter {
44
44
  });
45
45
 
46
46
  try {
47
- this.es.close();
48
- this.es = null;
47
+ if (this.es !== null && this.es !== undefined) {
48
+ this.es.removeEventListener();
49
+ this.es.close();
50
+ this.es = null;
51
+ }
49
52
  } catch (error) {
50
53
  /* empty */
51
54
  }
@@ -78,7 +81,7 @@ class classHUE extends EventEmitter {
78
81
  this.es.onopen = () => {
79
82
  // if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.error('KNXUltimatehueEngine: classHUE: SSE-Connected')
80
83
  this.emit("connected");
81
-
84
+ if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.info(`KNXUltimatehueEngine: classHUE: this.es.onopen: connected`);
82
85
  // Check wether the hue bridge is connected or not
83
86
  if (this.timerCheckConnected !== null) clearInterval(this.timerCheckConnected);
84
87
  this.timerCheckConnected = setInterval(() => {
@@ -86,7 +89,9 @@ class classHUE extends EventEmitter {
86
89
  }, 30000);
87
90
  };
88
91
 
89
- // this.es.onerror = (error) => {
92
+ this.es.onerror = (error) => {
93
+ if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.error(`KNXUltimatehueEngine: classHUE: this.es.onopen: ${error.status || ''} ${error.message}`);
94
+ };
90
95
  // 29/08/2023 NON riattivare, perchè alla disconnessione, va in loop e consuma tutto il pool di risorse.
91
96
  // try {
92
97
  // this.es.close();
@@ -97,19 +102,6 @@ class classHUE extends EventEmitter {
97
102
  // // this.emit('error', error)
98
103
  // };
99
104
 
100
- // 31/07/2023 Every now and then, restart the connection to the eventsource, because it can goes down without knowing that
101
- if (this.timerReconnect !== undefined) clearInterval(this.timerReconnect);
102
- this.timerReconnect = setInterval(() => {
103
- try {
104
- this.es.close();
105
- this.es = null;
106
- } catch (error) {
107
- /* empty */
108
- }
109
- try {
110
- this.Connect();
111
- } catch (error) { }
112
- }, 10 * (60 * 1000)); // 10 minutes
113
105
  };
114
106
 
115
107
  // Process single item in the queue
@@ -222,15 +214,14 @@ class classHUE extends EventEmitter {
222
214
  close = async () =>
223
215
  new Promise((resolve, reject) => {
224
216
  try {
225
- if (this.timerReconnect !== undefined) clearInterval(this.timerReconnect);
226
- this.closePushEventStream = true; // Signal to exit all loops
227
- try {
228
- if (this.es !== null && this.es !== undefined) this.es.close();
229
- } catch (error) { }
230
- this.es = null;
217
+ this.closePushEventStream = true; // Signal to exit all loops
231
218
  setTimeout(() => {
219
+ try {
220
+ if (this.es !== null && this.es !== undefined) this.es.close();
221
+ } catch (error) { }
222
+ this.es = null;
232
223
  resolve(true);
233
- }, 500);
224
+ }, 2000);
234
225
  } catch (error) {
235
226
  reject(error);
236
227
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": ">=16.0.0"
5
5
  },
6
- "version": "3.2.8",
6
+ "version": "3.2.10",
7
7
  "description": "Control your KNX intallation via Node-Red! A bunch of KNX nodes, with integrated Philips HUE control and ETS group address importer. Easy to use and highly configurable.",
8
8
  "dependencies": {
9
9
  "binary-parser": "2.2.1",