From 396b56e3a535ad1f946f4898811eb8431cd539bf Mon Sep 17 00:00:00 2001 From: Jon Maddox Date: Thu, 25 Jun 2015 02:00:37 -0400 Subject: [PATCH] add methods to Wink accessory to fetch brightness and power state --- platforms/Wink.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/platforms/Wink.js b/platforms/Wink.js index f7a36f1..58b09a9 100644 --- a/platforms/Wink.js +++ b/platforms/Wink.js @@ -56,6 +56,40 @@ function WinkAccessory(log, device) { } 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) { if (!this.device) {