diff --git a/SmartHomeNGConnection.js b/SmartHomeNGConnection.js index 0adaebd..c7b565b 100755 --- a/SmartHomeNGConnection.js +++ b/SmartHomeNGConnection.js @@ -59,7 +59,7 @@ SmartHomeNGConnection.prototype.receive = function(message) { if (msg.items) { for (int = 0; int < msg.items.length; int++) { item = msg.items[int]; - //this.log("Received value " + item[1] + " for item " + item[0]); + //this.log("[SmartHomeNGConnection] Received value " + item[1] + " for item " + item[0]); if (this.updateCallback) { this.updateCallback(item[0], item[1]); } @@ -69,24 +69,24 @@ SmartHomeNGConnection.prototype.receive = function(message) { SmartHomeNGConnection.prototype.setValue = function(item, value) { var command = '{"cmd":"item","id":"' + item + '","val":"' + value + '"}'; - this.log("Sending " + command + " to SmartHomeNG"); if (this.connected) { + this.log("[SmartHomeNGConnection] Sending " + command + " to SmartHomeNG"); this.connection.send(command) } else { - this.log("Cannot switch " + item + ", no connection to SmartHomeNG !") + this.log("[SmartHomeNGConnection] Cannot switch " + item + ", no connection to SmartHomeNG !") } } SmartHomeNGConnection.prototype.startMonitoring = function() { if (this.connected && this.tomonitor.length > 0) { var buffer = {}; - this.log("Start monitoring " + this.tomonitor); + this.log("[SmartHomeNGConnection] Start monitoring " + this.tomonitor); buffer.cmd = 'monitor'; buffer.items = this.tomonitor; var command = JSON.stringify(buffer); this.connection.send(command); } else { - this.log("Cannot start monitoring, not connected !"); + this.log("[SmartHomeNGConnection] Cannot start monitoring, not connected !"); } } diff --git a/index.js b/index.js index ff4fc5b..1968e6e 100755 --- a/index.js +++ b/index.js @@ -55,7 +55,7 @@ function SmartHomeNGPlatform(log, config, api) { this.api = api; this.api.on('didFinishLaunching', function() { this.log("Finished loading " + this.accessoriesCache.length + " accessories"); - this.log(monitoring); + // this.log(monitoring); // Add supported SHNG items to monitoring var tomonitor = []; for(i = 0; i < monitoring.length; i++) { @@ -110,7 +110,7 @@ SmartHomeNGPlatform.prototype = { for (var i = 0; i < monitoring.length; i++) { // iterate through all registered addresses if (monitoring[i].item == item) { - this.log("[" + item + "] Got update from SmartHomeNG with value " + value); + this.log("[" + monitoring[i].name + "] Got update for '" + monitoring[i].characteristic + "' from SmartHomeNG item '" + item + "' with value " + value + "."); monitoring[i].lastValue = value; monitoring[i].callback(item, value, monitoring[i].inverted); } @@ -185,7 +185,7 @@ SmartHomeNGAccessory.prototype = { //this.log("[" + this.name + "] callback for " + characteristic.displayName); characteristic.setValue(value ? (inverted ? 0:1) : (inverted ? 1:0), undefined, 'fromSHNG'); }.bind(this); - monitoring.push({item: shngitem, callback: callback, inverted: inverted}); + monitoring.push({name: name, characteristic: characteristic.displayName, item: shngitem, callback: callback, inverted: inverted}); }, shngregister_percent: function(name, shngitem, characteristic, inverted) { @@ -194,7 +194,7 @@ SmartHomeNGAccessory.prototype = { //this.log("[" + this.name + "] callback for " + characteristic.displayName); characteristic.setValue(inverted ? 100 - value : value, undefined, 'fromSHNG'); }.bind(this); - monitoring.push({item: shngitem, callback: callback, inverted: inverted}); + monitoring.push({name: name, characteristic: characteristic.displayName, item: shngitem, callback: callback, inverted: inverted}); }, /** get methods @@ -261,7 +261,7 @@ SmartHomeNGAccessory.prototype = { // Bind characteristic to service during startup bindCharacteristic: function(myService, characteristicType, valueType, shngitem, inverted, defaultValue) { var myCharacteristic = myService.getCharacteristic(characteristicType); - this.log("SHNGITEM: " + shngitem) + //this.log("SHNGITEM: " + shngitem) if (defaultValue) { myCharacteristic.setValue(defaultValue); }