using the host from the document.location

This commit is contained in:
Martin Donnelly 2017-01-07 18:05:26 +00:00
parent c9b90f2221
commit a00d110f51
2 changed files with 25 additions and 4 deletions

View File

@ -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",

20
wemo.js Normal file
View File

@ -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);
});