Open Source Software Rules!

The Wemo app is all fine and good, but how does one control these devices from an external script?

A quick Google search reveals some kind soul, with a mind for open source software, has done all the work for us. Better yet, his work is hosted on Github. This can't get any easier!

Check it out here: https://github.com/iancmcc/ouimeaux

To get a copy of the author's source code, clone it to your local drive. From the command line enter:

git clone https://github.com/iancmcc/ouimeaux

Then:

cd ouimeaux

If you get a command not found error then you will need to install the git software by using your system's package manager (i.e. yum, apt, etc).

Oh, hold on. Did I mentioned I'm doing this from a Linux computer? Mac and other *BSD users should be able to follow along. The instructions for a Windows computer will differ. If you are running Windows and want to follow along, you could go buy a Raspberry Pi. They run Linux, are very inexpensive, and it would be a fun learning experience. Now where was I?

Right, let's get the ouimeaux software installed and working.

A Little Script of My Own

At this point you should be able to control your Wemo Switch from the command line with these commands:

wemo switch "CableModem" off

wemo switch "CableModem" on

Use the name you chose for your Wemo Switch when executing these commands. You should verify this works before proceeding.

For a detailed description of the wemo tool options, check out the documentation here.

Final Thoughts

Hey, how do I know this is working? Good question.

Open wemoswitch.sh and change the variable PINGTARGET to an ip address that is not live. You could use "8.8.8.9" for example. Save your changes and either wait up to 15 minutes for cron to run the script again, or just run it yourself from the command line:

[abauer@localhost bin]$ ./wemoswitch.sh

No reply from 8.8.8.9
Charter is at it again!
Cycling Power on the Cable Modem
Watch the power cycle on your cable modem. Don't forget to change the PINGTARGET variable back to a valid ip address!

Since this script runs via cron, you normally won't directly see the output above. Instead, many distros will capture the output of any cron script and send it as an email to the local root user account.  On my own system, I've remapped this to go to my own user account.


Comments

Post your comments and feedback here.