Better log messages
This commit is contained in:
parent
bcf7a34070
commit
59264dddb4
@ -59,7 +59,7 @@ SmartHomeNGConnection.prototype.receive = function(message) {
|
|||||||
if (msg.items) {
|
if (msg.items) {
|
||||||
for (int = 0; int < msg.items.length; int++) {
|
for (int = 0; int < msg.items.length; int++) {
|
||||||
item = msg.items[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) {
|
if (this.updateCallback) {
|
||||||
this.updateCallback(item[0], item[1]);
|
this.updateCallback(item[0], item[1]);
|
||||||
}
|
}
|
||||||
@ -69,24 +69,24 @@ SmartHomeNGConnection.prototype.receive = function(message) {
|
|||||||
|
|
||||||
SmartHomeNGConnection.prototype.setValue = function(item, value) {
|
SmartHomeNGConnection.prototype.setValue = function(item, value) {
|
||||||
var command = '{"cmd":"item","id":"' + item + '","val":"' + value + '"}';
|
var command = '{"cmd":"item","id":"' + item + '","val":"' + value + '"}';
|
||||||
this.log("Sending " + command + " to SmartHomeNG");
|
|
||||||
if (this.connected) {
|
if (this.connected) {
|
||||||
|
this.log("[SmartHomeNGConnection] Sending " + command + " to SmartHomeNG");
|
||||||
this.connection.send(command)
|
this.connection.send(command)
|
||||||
} else {
|
} else {
|
||||||
this.log("Cannot switch " + item + ", no connection to SmartHomeNG !")
|
this.log("[SmartHomeNGConnection] Cannot switch " + item + ", no connection to SmartHomeNG !")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SmartHomeNGConnection.prototype.startMonitoring = function() {
|
SmartHomeNGConnection.prototype.startMonitoring = function() {
|
||||||
if (this.connected && this.tomonitor.length > 0) {
|
if (this.connected && this.tomonitor.length > 0) {
|
||||||
var buffer = {};
|
var buffer = {};
|
||||||
this.log("Start monitoring " + this.tomonitor);
|
this.log("[SmartHomeNGConnection] Start monitoring " + this.tomonitor);
|
||||||
buffer.cmd = 'monitor';
|
buffer.cmd = 'monitor';
|
||||||
buffer.items = this.tomonitor;
|
buffer.items = this.tomonitor;
|
||||||
var command = JSON.stringify(buffer);
|
var command = JSON.stringify(buffer);
|
||||||
this.connection.send(command);
|
this.connection.send(command);
|
||||||
} else {
|
} else {
|
||||||
this.log("Cannot start monitoring, not connected !");
|
this.log("[SmartHomeNGConnection] Cannot start monitoring, not connected !");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
index.js
10
index.js
@ -55,7 +55,7 @@ function SmartHomeNGPlatform(log, config, api) {
|
|||||||
this.api = api;
|
this.api = api;
|
||||||
this.api.on('didFinishLaunching', function() {
|
this.api.on('didFinishLaunching', function() {
|
||||||
this.log("Finished loading " + this.accessoriesCache.length + " accessories");
|
this.log("Finished loading " + this.accessoriesCache.length + " accessories");
|
||||||
this.log(monitoring);
|
// this.log(monitoring);
|
||||||
// Add supported SHNG items to monitoring
|
// Add supported SHNG items to monitoring
|
||||||
var tomonitor = [];
|
var tomonitor = [];
|
||||||
for(i = 0; i < monitoring.length; i++) {
|
for(i = 0; i < monitoring.length; i++) {
|
||||||
@ -110,7 +110,7 @@ SmartHomeNGPlatform.prototype = {
|
|||||||
for (var i = 0; i < monitoring.length; i++) {
|
for (var i = 0; i < monitoring.length; i++) {
|
||||||
// iterate through all registered addresses
|
// iterate through all registered addresses
|
||||||
if (monitoring[i].item == item) {
|
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].lastValue = value;
|
||||||
monitoring[i].callback(item, value, monitoring[i].inverted);
|
monitoring[i].callback(item, value, monitoring[i].inverted);
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ SmartHomeNGAccessory.prototype = {
|
|||||||
//this.log("[" + this.name + "] callback for " + characteristic.displayName);
|
//this.log("[" + this.name + "] callback for " + characteristic.displayName);
|
||||||
characteristic.setValue(value ? (inverted ? 0:1) : (inverted ? 1:0), undefined, 'fromSHNG');
|
characteristic.setValue(value ? (inverted ? 0:1) : (inverted ? 1:0), undefined, 'fromSHNG');
|
||||||
}.bind(this);
|
}.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) {
|
shngregister_percent: function(name, shngitem, characteristic, inverted) {
|
||||||
@ -194,7 +194,7 @@ SmartHomeNGAccessory.prototype = {
|
|||||||
//this.log("[" + this.name + "] callback for " + characteristic.displayName);
|
//this.log("[" + this.name + "] callback for " + characteristic.displayName);
|
||||||
characteristic.setValue(inverted ? 100 - value : value, undefined, 'fromSHNG');
|
characteristic.setValue(inverted ? 100 - value : value, undefined, 'fromSHNG');
|
||||||
}.bind(this);
|
}.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
|
/** get methods
|
||||||
@ -261,7 +261,7 @@ SmartHomeNGAccessory.prototype = {
|
|||||||
// Bind characteristic to service during startup
|
// Bind characteristic to service during startup
|
||||||
bindCharacteristic: function(myService, characteristicType, valueType, shngitem, inverted, defaultValue) {
|
bindCharacteristic: function(myService, characteristicType, valueType, shngitem, inverted, defaultValue) {
|
||||||
var myCharacteristic = myService.getCharacteristic(characteristicType);
|
var myCharacteristic = myService.getCharacteristic(characteristicType);
|
||||||
this.log("SHNGITEM: " + shngitem)
|
//this.log("SHNGITEM: " + shngitem)
|
||||||
if (defaultValue) {
|
if (defaultValue) {
|
||||||
myCharacteristic.setValue(defaultValue);
|
myCharacteristic.setValue(defaultValue);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user