node-red-contrib-knx-ultimate
Advanced tools
Comparing version
@@ -5,4 +5,6 @@ /* eslint-disable max-len */ | ||
const http = require("./http"); | ||
const pleaseWait = t => new Promise((resolve, reject) => setTimeout(resolve, t)) | ||
class classHUE extends EventEmitter { | ||
constructor(_hueBridgeIP, _username, _clientkey, _bridgeid, _sysLogger) { | ||
@@ -17,6 +19,5 @@ super(); | ||
// eslint-disable-next-line max-len | ||
this.timerwriteQueueAdd = setTimeout(this.handleQueue, 10000); // First start. Allow the KNX to connect | ||
setTimeout(this.handleQueue, 10000); // First start. Allow the KNX to connect | ||
this.sysLogger = _sysLogger; | ||
this.timerCheckConnected = undefined; | ||
this.timerCheckConnected = null; | ||
} | ||
@@ -80,3 +81,3 @@ | ||
// Check wether the hue bridge is connected or not | ||
if (this.timerCheckConnected !== undefined) clearInterval(this.timerCheckConnected); | ||
if (this.timerCheckConnected !== null) clearInterval(this.timerCheckConnected); | ||
this.timerCheckConnected = setInterval(() => { | ||
@@ -126,4 +127,5 @@ this.writeHueQueueAdd(null, null, "Ping"); | ||
} catch (error) { | ||
if (this.sysLogger !== undefined && this.sysLogger !== null) | ||
this.sysLogger.info(`KNXUltimatehueEngine: classHUE: handleQueue: setLight light: ${error.message}`); | ||
if (this.sysLogger !== undefined && this.sysLogger !== null) { | ||
this.sysLogger.info(`KNXUltimatehueEngine: classHUE: handleQueue: setLight light: ${error.message}. CHECK WETHER THE DEVICE IS POWERED ON`); | ||
} | ||
} | ||
@@ -167,3 +169,3 @@ break; | ||
if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.error(`KNXUltimatehueEngine: classHUE: handleQueue: Ping: ${error.message}`); | ||
if (this.timerCheckConnected !== undefined) clearInterval(this.timerCheckConnected); | ||
if (this.timerCheckConnected !== null) clearInterval(this.timerCheckConnected); | ||
this.commandQueue.length = []; | ||
@@ -178,4 +180,4 @@ this.emit("disconnected"); | ||
// The Hue bridge allows about 10 telegram per second, so i need to make a queue manager | ||
//await new Promise(resolve => setTimeout(resolve, 2000)); | ||
this.timerwriteQueueAdd = setTimeout(this.handleQueue, 200); | ||
await pleaseWait(150); // Waits | ||
if (this.closePushEventStream === false) this.handleQueue(); | ||
}; | ||
@@ -189,6 +191,6 @@ | ||
/** | ||
* Clears all items fo _lightID from the HUE sending queue. Useful to clear unwanted dimming commands | ||
* @param {string} _lightID HUE Light ID | ||
* @returns {} | ||
*/ | ||
* Clears all items fo _lightID from the HUE sending queue. Useful to clear unwanted dimming commands | ||
* @param {string} _lightID HUE Light ID | ||
* @returns {} | ||
*/ | ||
deleteHueQueue = async (_lightID) => { | ||
@@ -204,3 +206,3 @@ // Add the new item | ||
if (this.timerReconnect !== undefined) clearInterval(this.timerReconnect); | ||
this.closePushEventStream = true; | ||
this.closePushEventStream = true; // Signal to exit all loops | ||
try { | ||
@@ -207,0 +209,0 @@ if (this.es !== null && this.es !== undefined) this.es.close(); |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "3.0.0-beta3", | ||
"version": "3.0.0", | ||
"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.", | ||
@@ -9,0 +9,0 @@ "dependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7158874
0.02%19937
0.01%1
-50%