This is going to get a bit convoluted so try and stick with me.
I moved house the end of last year and, as happens every time, I left behind all the alterations and small tweaks I’d done to make my living environment accessible. One of these was the large light switches I’d had installed lower during a door modification to allow me access to turn the light on/off in my bedroom.
Now in my next (current) house I was determined not to spend effort and dollars in such modifications as light switches to be left behind at some future date. I reasoned why not instead spend money on devices I could take with me.
With that in mind I set about looking at how to turn on a light in my bedroom. When I say light I mean any light – anything that’d let me see on my terms, without having to call someone to do it. In this case a lamp plugged into a socket by my bed. I’ve got no access to a light switch in my bedroom so ideally I need to be able to turn the light on from my chair and/or while in bed.
The simple way I’ve found is to use off the shelf remote controlled power switches, the kind that plugs into a wall socket then you plug your device into that and you have a RF remote that controls that.
[picture of kind I use]
These work great. I use a few with the remote on my desk to turn a light on in my home office.
While in bed I use an over bed table that gives me access to a laptop and a few remote controls, for heater, TV etc. using a mouth-stick. However having another remote on my over bed table where I need to operate my bedroom light from is just no good. I’ve already got 3 there and I couldn’t reach another.
My thoughts turned toward the WeMo switch as a possible way of control, however all I knew was the WeMo uses an app on a mobile device. This meant it was out of the question as I’d need to have another, touch compatible mouth-stick for the phone and the phone itself, on my already cluttered space.
Ideally I needed control from my PC.
I then latched onto the idea of having a remote control app on a mobile device that was running the WeMo app and remote access from my PC to the mobile to then control the WeMo app and switch. The mobile would need to be in power somewhere all the time and that meant I couldn’t dedicate my iPhone to the task. I knew on iPhone I’d need to jailbreak it to install a remote control app. So I put out a message to my Facebook friends if someone had an old iPod touch or iPhone they could donate for me to experiment with. My friend Wol offered an old Android powered phone he had retired long ago. I managed to get remote control of it then set about trying to load the WeMo app. But no matter how I tried I couldn’t get the WeMo app loaded.
Then I got an email to Lifekludger from Chris over at Mobilezap asking if I’d be interested in reviewing something for the iPhone 5s or something else from the site. I checked them out and guess what they had? Yes, WeMo switches. I told Chris I didn’t own a iPhone 5s but I could make use of the WeMo! And he gladly sent one over.
Now you’re most likely familiar with what the WeMo products from Belkin do.. they are basically WiFi connected switches and motion sensors that can be controlled via an app on your phone.
As I said earlier, the phone only control was something I’d need to kludge around but otherwise the WeMo units themselves are great.Unfortunately the WeMo units from Mobilezap had the UK style pinouts – odd – they came with one adaptor but a couple adapters later I had them up and running. Setup via the WeMo app is a snap.So now the WeMo switch was operational I set it to automatically switch on at about the time I go to bed and turn off each morning when it’s light. But that’s not where it ends. I sometimes needed to switch the light on/off at different times and given the limitations outline above I set about trying to see if there was anyone doing anything about a desktop/pc app for WeMo devices.At the risk of going down a rabbit hole here, I’d just like to make it known how I’m a bit tired of seeing how much everything is being written for app control from a mobile device and so often there is a very real need for the same app functionality on the desktop/notebook pc. There are real accessibility consequences of only providing for a single platform range – accessibility is about catering for aspects a person cannot change by providing options – no options equals limited accessibility. The continuous march toward “mobile only” – which, as it happens today more and more today equates to “touch only” – really has me concerned, mostly for this reason.
So, to my search on how to control the WeMo from the pc. I discovered that WeMo can interface with IFTTT and I set it up to be able to turn my light on/off by posting a status on my Facebook wall with a certain hashtag. This worked – much to the glee of a couple of my friends who thought it was neat turning my light on/off by copying what I was posting. I quickly turned that channel off and tried something more restricted – control via a hashtag from my twitter account. This proved a bit slow and flakey. So, while nifty fun, it wasn’t a real solution. If I woke up during the night and needed to turn my light on, I would’t be able to see the keyboard enough to type anyway.
I need a way to click something on my pc.
So seeking for a desktop/pc app I found a post on Hackaday on Turning the Belkin WeMo into a deathtrap which lead me to the WeMo forums and a post by cj2902 on some shell scripts he’d modified to control the WeMo and batch file he’d used to run those.
This was the breakthrough piece of the puzzle I’d been looking for.
I copied the script and after looking up the ip address of my WeMo switch ran it on my Mac terminal and viola.. it worked beautifully. So I set to making it work on my Win based laptop over my bed. I installed cygwin which gives a basic unix command shell to windows pcs and tried the script on there. After a bit of mucking around, caused mostly by a corrupt script when I created it, I had it working on the pc. I then created two batch files, one to turn light on, the other to turn it off, and put them on my desktop.
[image iof batch files on desktop]
Now all I need do is grab my mouth-stick and double click and the light responds as desired.
I’ve posted links here to the script and batch files for light on / light off I use.
My thanks to Wol, Chris at Mobilezap and cj2902.
Note re cygwin: Please refer to the pertinent comment by Chris below to install curl.
10 thoughts on “The Great Automatic Light Saga or How to control a WeMo light from your PC”
This was a very useful script thank you for posting this up. Would like to mention that cygwin doesn’t install curl by default, though, so whoever uses this will have to make sure it’s installed for this to all work.
Thanks Chris, good point. I’ll put a note in the post.
BELKIN, are you paying attention??
Why is it that DIYers can do stuff better than Belkin does??
Who needs a crock pot on WEMO! We need RELIABLE devices that we can access with different devices, including a PC!
Thank you, Dave, Chris and the community that helped you.
Thanks for your awesome tutorial.
I am not sure why. The on script fails and cannot find the port however the off script works, and reports port : 49153
Using the same wemo.sh for both scripts.
Wondered if you have any ideas why only the off script works.
Thanks in advance.
DNW, this is great. Thank you for sharing. Using your example, I wrote a batch file that toggles between on and off so you only need the single file. It uses the GETSTATE feature to determine the current state of the switch and then sends a message to flip the state. Here it is:
rem c:\cygwin64\bin\sh.exe D:\Main\Downloads\Wemo\wemo.sh 10.0.0.46 GETSTATE
for /f %%i in (‘c:\cygwin64\bin\sh.exe D:\Main\Downloads\Wemo\wemo.sh 10.0.0.46 GETSTATE’) do set TEST=%%i
if “%TEST%” == “OFF” goto off
if “%TEST%” == “ON” goto on else goto none
c:\cygwin64\bin\sh.exe D:\Main\Downloads\Wemo\wemo.sh 10.0.0.46 ON
c:\cygwin64\bin\sh.exe D:\Main\Downloads\Wemo\wemo.sh 10.0.0.46 OFF
echo Error: Output not recognized
Excellent, thanks folks! Wemo is great.
I run a WAMP server, if I enable the curl module on it can this code be used to write PHP scripts so I can build my own GUI for Wemo?
@andrew – did you try telnet to that port if you can to see if it responds. Only thing I cam think of is a firewall maybe?
@Ian – I’ve no idea.
Thanks everyone for your feedback. Love it!
Thanks for this. Was just umming and ahhing about sniffing wemo traffic to see what it’s doing but this has saved me the effort. Cheers.
WOW, I just tried it on the Anniversary Edition of Windows 10, with the BUILT IN Canonical Ubuntu Bash terminal, and IT WORKS without any modifications.
AWESOME!!! Thanks for posting this!!!