21 lines
465 B
JavaScript
21 lines
465 B
JavaScript
/**
|
|
* 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(0);
|
|
});
|