diff --git a/package.json b/package.json index 561db72..59abe72 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "atob": "^2.0.3", "babel-preset-es2015": "^6.14.0", "basic-authentication": "^1.7.0", + "better-npm-run": "0.0.13", "body-parser": "^1.15.2", "btoa": "^1.1.2", "cfenv": "1.0.x", @@ -36,8 +37,8 @@ "sugar-date": "^2.0.2", "uuid-pure": "^1.0.10", "websocket": "^1.0.23", - "ws": "^1.1.1", - "better-npm-run": "0.0.13" + "wemo-client": "^0.11.2", + "ws": "^1.1.1" }, "devDependencies": { "after": "^0.8.1", @@ -84,8 +85,8 @@ }, "scripts": { "start": "node server.js", - "build": "gulp default", - "production": "NODE_ENV=production node server.js" + "build": "gulp default", + "production": "NODE_ENV=production node server.js" }, "author": "Martin Donnelly", "license": "ISC", diff --git a/wemo.js b/wemo.js new file mode 100644 index 0000000..c145c39 --- /dev/null +++ b/wemo.js @@ -0,0 +1,20 @@ +/** + * Created by martin on 1/7/17. + */ +var Wemo = require('wemo-client'); +var wemo = new Wemo(); + +wemo.discover(function(deviceInfo) { + console.log('Wemo Device Found: %j', deviceInfo); + + // Get the client for the found device + var client = wemo.client(deviceInfo); + + // Handle BinaryState events + client.on('binaryState', function(value) { + console.log('Binary State changed to: %s', value); + }); + + // Turn the switch on + client.setBinaryState(1); +});