June 17th, 2014
Summary: Control a lamp with a script on your PC via WiFi and a WeMo Switch
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.
[wemo switch and motion]
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.
Dave - Lifekludger
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.