Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Devices/MiPhilipsCeilingLamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,48 +71,48 @@ MiPhilipsCeilingLampLight.prototype.getServices = function() {
CeilingLampOnCharacteristic
.on('get', function(callback) {
this.device.call("get_prop", ["power"]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp - getPower: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp (" + that.device.address + ") - getPower: " + result);
callback(null, result[0] === 'on' ? true : false);
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp - getPower Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp (" + that.device.address + ") - getPower Error: " + err);
callback(err);
});
}.bind(this))
.on('set', function(value, callback) {
that.device.call("set_power", [value ? "on" : "off"]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp - setPower Result: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp (" + that.device.address + ") - setPower Result: " + result);
if(result[0] === "ok") {
callback(null);
} else {
callback(new Error(result[0]));
}
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp - setPower Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp (" + that.device.address + ") - setPower Error: " + err);
callback(err);
});
}.bind(this));
CeilingLampService
.addCharacteristic(Characteristic.Brightness)
.on('get', function(callback) {
this.device.call("get_prop", ["bright"]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp - getBrightness: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp (" + that.device.address + ") - getBrightness: " + result);
callback(null, result[0]);
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp - getBrightness Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp (" + that.device.address + ") - getBrightness Error: " + err);
callback(err);
});
}.bind(this))
.on('set', function(value, callback) {
if(value > 0) {
this.device.call("set_bright", [value]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp - setBrightness Result: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp (" + that.device.address + ") - setBrightness Result: " + result);
if(result[0] === "ok") {
callback(null);
} else {
callback(new Error(result[0]));
}
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp - setBrightness Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp (" + that.device.address + ") - setBrightness Error: " + err);
callback(err);
});
} else {
Expand All @@ -123,10 +123,10 @@ MiPhilipsCeilingLampLight.prototype.getServices = function() {
.getCharacteristic(Characteristic.ColorTemperature)
.on('get', function(callback) {
this.device.call("get_prop", ["cct"]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp - getColorTemperature: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp (" + that.device.address + ") - getColorTemperature: " + result);
callback(null, result[0] * 350);
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp - getColorTemperature Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp (" + that.device.address + ") - getColorTemperature Error: " + err);
callback(err);
});
}.bind(this))
Expand All @@ -139,14 +139,14 @@ MiPhilipsCeilingLampLight.prototype.getServices = function() {
}
that.platform.log.debug("[MiPhilipsLightPlatform]MiPhilipsCeilingLamp - setColorTemperature : " + value + "%");
this.device.call("set_cct", [value]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp - setColorTemperature Result: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsCeilingLamp (" + that.device.address + ") - setColorTemperature Result: " + result);
if(result[0] === "ok") {
callback(null);
} else {
callback(new Error(result[0]));
}
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp - setColorTemperature Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsCeilingLamp (" + that.device.address + ") - setColorTemperature Error: " + err);
callback(err);
});
}.bind(this));
Expand Down
24 changes: 12 additions & 12 deletions Devices/MiPhilipsSmartBulb.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,36 +73,36 @@ MiPhilipsSmartBulbLight.prototype.getServices = function() {
MiPhilipsSmartBulbLight.prototype.getPower = function(callback) {
var that = this;
this.device.call("get_prop", ["power"]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light - getPower: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light (" + that.device.address + ") - getPower: " + result);
callback(null, result[0] === 'on' ? true : false);
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light - getPower Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light (" + that.device.address + ") - getPower Error: " + err);
callback(err);
});
}

MiPhilipsSmartBulbLight.prototype.setPower = function(value, callback) {
var that = this;
that.device.call("set_power", [value ? "on" : "off"]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light - setPower Result: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light (" + that.device.address + ") - setPower Result: " + result);
if(result[0] === "ok") {
callback(null);
} else {
callback(new Error(result[0]));
}
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light - setPower Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light (" + that.device.address + ") - setPower Error: " + err);
callback(err);
});
}

MiPhilipsSmartBulbLight.prototype.getBrightness = function(callback) {
var that = this;
this.device.call("get_prop", ["bright"]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light - getBrightness: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light (" + that.device.address + ") - getBrightness: " + result);
callback(null, result[0]);
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light - getBrightness Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light (" + that.device.address + ") - getBrightness Error: " + err);
callback(err);
});
}
Expand All @@ -111,14 +111,14 @@ MiPhilipsSmartBulbLight.prototype.setBrightness = function(value, callback) {
var that = this;
if(value > 0) {
this.device.call("set_bright", [value]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light - setBrightness Result: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light (" + that.device.address + ") - setBrightness Result: " + result);
if(result[0] === "ok") {
callback(null);
} else {
callback(new Error(result[0]));
}
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light - setBrightness Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light (" + that.device.address + ") - setBrightness Error: " + err);
callback(err);
});
} else {
Expand All @@ -129,10 +129,10 @@ MiPhilipsSmartBulbLight.prototype.setBrightness = function(value, callback) {
MiPhilipsSmartBulbLight.prototype.getColorTemperature = function(callback) {
var that = this;
this.device.call("get_prop", ["cct"]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light - getColorTemperature: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light (" + that.device.address + ") - getColorTemperature: " + result);
callback(null, result[0] * 350);
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light - getColorTemperature Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light (" + that.device.address + ") - getColorTemperature Error: " + err);
callback(err);
});
}
Expand All @@ -146,14 +146,14 @@ MiPhilipsSmartBulbLight.prototype.setColorTemperature = function(value, callback
}
var that = this;
this.device.call("set_cct", [value]).then(result => {
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light - setColorTemperature Result: " + result);
that.platform.log.debug("[MiPhilipsLightPlatform][DEBUG]MiPhilipsSmartBulb - Light (" + that.device.address + ") - setColorTemperature Result: " + result);
if(result[0] === "ok") {
callback(null);
} else {
callback(new Error(result[0]));
}
}).catch(function(err) {
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light - setColorTemperature Error: " + err);
that.platform.log.error("[MiPhilipsLightPlatform][ERROR]MiPhilipsSmartBulb - Light (" + that.device.address + ") - setColorTemperature Error: " + err);
callback(err);
});
}
Loading