WeMo Insight on Wot.io
When looking around the smart home market, it's hard to miss the Belkin WeMo line of products. They've got many different kinds of compatible devices, from light bulbs to power sockets to space heaters. All of which have some sort of data associated with them, from the state of the device to the state of the surrounding environment. So why don't we integrate our devices into Wotio, just like we did with the Philips Hue.
What if the WeMo's light sensors, bulbs, and just about every other device was already pre-integrated into a single system, including devices on other platforms? What if the only thing needed to get them working together was a short script? What if you could then tack on other services from 3rd parties (maybe SQL storage, or tweeting specific events) with little extra effort? And someone else did all of the hosting and scaling work for you? Well, then you'd be using Wot. So in this post I'll be showing you how easy it is to integrate the WeMo system into Wotio, and how Wotio can be used to leverage it.
WeMo devices can be controlled two ways - either via their Cloud API, or via the local Device Management Platform ( Unfortunately, their DMP doesn't have an open API and is (at least publicly) undocumented. So in this post we'll be seeing how to bypass their DMP and still retain control of our devices over the internet, and then in a future post, how to replace theirs with one on Wotio. If you're cringing right now, you've probably done some system integration before. But don't worry, that's what makes Wot so powerful - it makes these integrations so quick and easy that we don't have to worry about them anymore.
To get started, you'll need the following:
- A Belkin WeMo device (in this demo, we'll use an Insight Switch)
- A computer, virtual machine, or cloud instance with Python 2.7 installed and a network connection to the Hue bridge
- A Wotio access token and path
For this integration, we'll be using Python. Even if you don't know it it's fairly easy lanugage to read and understand what's going on.
You can find the code here:
Download it, then from that directory run:
sudo python setup.py install wotwemo <visit http://wot.io for your wot.io path>
<UUID> is a random string you've generated to identify your application. If you're doing multiple integrations and want them to communicate, this should be kept as the same value.
And that's it! Your wemo devices are now integrated into Wotio. The trick here is in the
wotwrapper library. What it does is it takes the functions in a python class (in this case the
WotWemo class) and wraps them into Wot-style JSON commands.
JSON Message received | Function Called ------------------------------------------------------------------ ["list_devices"] | wemo.list_devices() ["help","<device_name>"] | wemo.help(device_name)
For detailed usage, see the code and documentation at WoTio/wot-wemo on Github.
The Wot side
Now that we've got our switch wrapped, let's check out it's data stream on Wot, and attempt to control it over the internet.
We can connect to Wotio using several different protocols, but for our purposes we're going to use websockets. Why? Because we can use any number of mechanisms to view the data streams we're generating in real-time. If you don't have a websocket shell installed, you can try progrium/wssh. It's also based on Python 2.7, so if you've gotten this far in the integration it should work for you perfectly fine. So let's use it to open a websocket connection to our data stream on wotio:
wssh <visit http://wot.io for your wot.io path>
And you should see the data stream coming from the insight switch! To control it, all you have to do is type a command:
Notice how each time you send one of these commands, you not only toggle the switch, but change the data coming out of it as well? That's what gives Wot it's power. There are lots of pre-integrated services that can act on this data. You can even integrate another device (just as easily, mind you) and Wotio gives you the power to link them together so that they can communicate no matter where they are in the world; all they need is an internet connection. And all of this is production-ready, with no infrastructure for you to maintain, should you want to take your devices (or services) to market.
And if you've got another device connected as described on the blog, you should be able to send and receive commands on it as well!
If you'd like to see a sample of the power you can get out of Wotio, visit the wot.io website and we'll call you to schedule a meeting.