From 4b6bb332ef0b44620a1c2bdf4c4d4f11a73ec4bf Mon Sep 17 00:00:00 2001 From: Jon Maddox Date: Mon, 18 May 2015 22:07:17 -0400 Subject: [PATCH] Wink platform library --- platforms/Wink.js | 204 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 platforms/Wink.js diff --git a/platforms/Wink.js b/platforms/Wink.js new file mode 100644 index 0000000..f7a36f1 --- /dev/null +++ b/platforms/Wink.js @@ -0,0 +1,204 @@ +var types = require("../lib/HAP-NodeJS/accessories/types.js"); +var wink = require('wink-js'); + +var model = { + light_bulbs: require('wink-js/lib/model/light') +}; + + +function WinkPlatform(log, config){ + + // auth info + this.client_id = config["client_id"]; + this.client_secret = config["client_secret"]; + this.username = config["username"]; + this.password = config["password"]; + + this.log = log; +} + +WinkPlatform.prototype = { + accessories: function(callback) { + this.log("Fetching Wink devices."); + + var that = this; + var foundAccessories = []; + + wink.init({ + "client_id": this.client_id, + "client_secret": this.client_secret, + "username": this.username, + "password": this.password + }, function(auth_return) { + if ( auth_return === undefined ) { + that.log("There was a problem authenticating with Wink."); + } else { + // success + wink.user().devices('light_bulbs', function(devices) { + for (var i=0; i