This library aims to provide a simple interface to a Belkin WeMo Power Sockets (http://www.belkin.com/wemo).
npm install wemo.js
var WeMo = require('wemo.js');
WeMo.discover(function(wemos) {
console.log(wemos);
});
var client = WeMo.createClient('x.x.x.x'); // x.x.x.x being the IP of the WeMo obtained in the previous step
client.state(function(err,state) {
if (state===1) {
// WeMo if on, turn it off
client.off();
} else {
// WeMo is off, turn it on
client.on();
}
});
hostname
being the IP of the WeMo.
Discovers WeMo power sockets on your local network.
Attempts to turn the WeMo on. cb
will be passed an error if this failed, or if the device is already on.
Attempts to turn the WeMo off. cb
will be passed an error if this failed, or if the device is already off.
Fetch the state of the WeMo, 1 is on, 0 is off.