scope and name fixes

removed deprecated node-hue-api methods and change this to that.
This commit is contained in:
madmod
2015-06-27 19:27:39 -06:00
parent 39a7550d67
commit 479dfb6329
+11 -9
View File
@@ -83,19 +83,21 @@ var execute = function(api, device, characteristic, value) {
// Get the ip address of the first available bridge with meethue.com or a network scan. // Get the ip address of the first available bridge with meethue.com or a network scan.
var locateBridge = function (callback) { var locateBridge = function (callback) {
var that = this;
// Report the results of the scan to the user // Report the results of the scan to the user
var getIp = function (err, bridges) { var getIp = function (err, bridges) {
if (!bridges || bridges.length === 0) { if (!bridges || bridges.length === 0) {
this.log("No Philips Hue bridges found."); that.log("No Philips Hue bridges found.");
callback(err || new Error("No bridges found")); callback(err || new Error("No bridges found"));
return; return;
} }
if (bridges.length > 1) { if (bridges.length > 1) {
this.log("Warning: Multiple Philips Hue bridges detected. The first bridge will be used automatically. To use a different bridge set ip_address manually in configuration."); that.log("Warning: Multiple Philips Hue bridges detected. The first bridge will be used automatically. To use a different bridge set ip_address manually in configuration.");
} }
this.log( that.log(
"Philips Hue bridges found:", "Philips Hue bridges found:",
bridges.map(function (bridge) { bridges.map(function (bridge) {
// Bridge name is only returned from meethue.com so use id instead if it isn't there // Bridge name is only returned from meethue.com so use id instead if it isn't there
@@ -107,16 +109,16 @@ var locateBridge = function (callback) {
}; };
// Try to discover the bridge ip using meethue.com // Try to discover the bridge ip using meethue.com
this.log("Attempting to discover Philips Hue bridge with network scan."); that.log("Attempting to discover Philips Hue bridge with network scan.");
api.locateBridges(function (locateError, bridges) { hue.nupnpSearch(function (locateError, bridges) {
if (locateError) { if (locateError) {
this.log("Philips Hue bridge discovery with meethue.com failed. Register your bridge with the meethue.com for more reiable discovery."); that.log("Philips Hue bridge discovery with meethue.com failed. Register your bridge with the meethue.com for more reiable discovery.");
this.log("Attempting to discover Philips Hue bridge with network scan."); that.log("Attempting to discover Philips Hue bridge with network scan.");
api.searchForBridges(function (searchError, bridges) { hue.upnpSearch(function (searchError, bridges) {
if (err) { if (err) {
this.log("Philips Hue bridge discovery with network scan failed. Check your network connection or set ip_address manually in configuration."); that.log("Philips Hue bridge discovery with network scan failed. Check your network connection or set ip_address manually in configuration.");
getIp(new Error("Scan failed")); getIp(new Error("Scan failed"));
} else { } else {
getIp(null, bridges); getIp(null, bridges);