Electronics · raspberry pi

Raspberry PI for Controlling Wemo Power

The previous article: TP-Link POWER covered TP-link devices.  They’ve become a little difficult to get ahold of this holiday season, but Wemo devices by Belkin are all over the place.

511ciyeuh5l-_sl1000_

WEMO Switch Outlet

So, I took a little time to figure out how to automate those little puppies.

Its pretty simple, once you track down the right library.  In this case you want: wemo-client

A slight modification to the example code gives us blink!  The wemos are a little slow – so you have to give them a 2 second interval.

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 and off at a 2 second interval
  var state = 1;
  setInterval(() => {
    state = !state;
    client.setBinaryState(state ? 0 : 1);
    console.log("State: " + state);
   }, 2000);
});

Now… to tie them into the remote control wand and make sure it runs forever!

7 thoughts on “Raspberry PI for Controlling Wemo Power

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s