mirror of
https://github.com/mtan93/homebridge.git
synced 2026-05-31 06:11:47 +01:00
add methods to Wink accessory to fetch brightness and power state
This commit is contained in:
@@ -56,6 +56,40 @@ function WinkAccessory(log, device) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WinkAccessory.prototype = {
|
WinkAccessory.prototype = {
|
||||||
|
getPowerState: function(callback){
|
||||||
|
if (!this.device) {
|
||||||
|
this.log("No '"+this.name+"' device found (yet?)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
this.log("checking power state for: " + this.name);
|
||||||
|
wink.user().device(this.name, function(light_obj){
|
||||||
|
powerState = light_obj.desired_state.powered
|
||||||
|
that.log("power state for " + that.name + " is: " + powerState)
|
||||||
|
callback(powerState);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
getBrightness: function(callback){
|
||||||
|
if (!this.device) {
|
||||||
|
this.log("No '"+this.name+"' device found (yet?)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
this.log("checking brightness level for: " + this.name);
|
||||||
|
wink.user().device(this.name, function(light_obj){
|
||||||
|
level = light_obj.desired_state.brightness * 100
|
||||||
|
that.log("brightness level for " + that.name + " is: " + level)
|
||||||
|
callback(level);
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
setPowerState: function(powerOn) {
|
setPowerState: function(powerOn) {
|
||||||
if (!this.device) {
|
if (!this.device) {
|
||||||
|
|||||||
Reference in New Issue
Block a user