From 4baab268790f355f7ee9c7218efccfa8395063e9 Mon Sep 17 00:00:00 2001 From: GeorgeNet Date: Mon, 6 Mar 2017 18:32:06 +0300 Subject: [PATCH] Update index.js --- index.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 38d2732..0c269ab 100644 --- a/index.js +++ b/index.js @@ -21,14 +21,15 @@ var pollingtoevent = require('polling-to-event'); this.brightness_url = config["brightness_url"]; this.brightnesslvl_url = config["brightnesslvl_url"]; this.http_method = config["http_method"] || "GET";; - this.http_brightness_method = config["http_brightness_method"] || this.http_method; - this.username = config["username"] || ""; - this.password = config["password"] || ""; + this.http_brightness_method = config["http_brightness_method"] || this.http_method; + this.username = config["username"] || ""; + this.password = config["password"] || ""; this.sendimmediately = config["sendimmediately"] || ""; - this.service = config["service"] || "Switch"; + this.service = config["service"] || "Switch"; this.name = config["name"]; this.brightnessHandling = config["brightnessHandling"] || "no"; - this.switchHandling = config["switchHandling"] || "no"; + this.switchHandling = config["switchHandling"] || "no"; + //realtime polling info this.state = false; @@ -43,7 +44,11 @@ var pollingtoevent = require('polling-to-event'); that.httpRequest(powerurl, "", "GET", that.username, that.password, that.sendimmediately, function(error, response, body) { if (error) { that.log('HTTP get power function failed: %s', error.message); - done(error); + try { + done(new Error("Network failure that must not stop homebridge!")); + } catch(err) { + that.log(err.message); + } } else { done(null, body); }