Support for the AllJoyn protocol to run home automation is built into Windows, and it's really easy to build apps against AllJoyn with tooling right inside Visual Studio 2015 to generate client code.
The idea behind AllJoyn is to be the glue between all the other Home Automation Standards, as well as standing on its own. For instance the LIFX bulbs now has AllJoyn support built right into them, and you can use the standardized "AllJoyn Lighting Service Framework" (LSF) to interact with any AllJoyn enabled lightbulb.
But what about other smart-bulbs that aren't AllJoyn enabled? This is where AllJoyn Device Service Bridges (DSB) comes into play. Visual Studio even has a DSB Project Template built in, that makes it really easy to build LSF DSB bridges. The most popular smart bulbs today are probably the Philips Hue bulbs. They are however using ZigBee Light Link, and controlled by a Hue Bridge (not to be confused by the AllJoyn DSB - The Hue bridge is the glue between ZigBee Light Link and IP networks). We can instead build a Hue to AllJoyn Device Service Bridge that exposes all the light bulbs on Philips Hue to AllJoyn using standard LSF. This actually means any app that's built to control AllJoyn enabled lightbulbs will automatically be able to control Philips Hue bulbs, including LIFX' app !
To get started, the first thing you need to do is download my AllJoyn Philips Hue DSB from GitHub: https://github.com/dotMorten/AllJoynPhilipsHueDSB
Just grab the zip file and open it up in Visual Studio. Set the build configuration to ARM and Release, and select the "HeadlessAdapterApp" as the startup project. Next right-click this project and go into project settings -> Debug, and set target device to "Remote Machine", and enter the IP or name of your Raspberry running Windows IoT Core and use the "Universal" authentication mode. It should look something like this:
Next hit CTRL+F5 to launch the app on your Raspberry. That's it! You now have an AllJoyn device service bridge for Philips Hue running on your network!
Note however that if you restart your Raspberry, that the service won't start up automatically again. You can register it as a startup task from powershell using the following command:
IotStartup startup headless PhilipsHueDSB
That way the DSB service is always running - and if it were to crash for some reason, it will automatically restart again.
However there's a little more to it than just installing and starting the DSB. We need to actually configure the DSB to allow connecting to the Philips Hue devices. We'll use Microsoft's AllJoyn Explorer to do this, which can be downloaded here including instructions how to install it:
http://ms-iot.github.io/content/en-US/win10/AllJoyn.htm#AllJoynExplorer
After installing, launch the explorer, and you should see an entry for the Philips Hue DSB:
The DSB itself doesn't really do much other than handle the bridging between AllJoyn and the Philips Hue Bridge. However if one or more Philips Hue bridges are detected on the network, you'll also see those shown:
Click the PhilipsHue bridge tile, then click "PhilipsHue" -> "MainInterface" -> "Link"
Now before you press the Invoke button here, you need to press the button on the Philips Hue bridge. After pressing it, invoke the button, and you should be notified that the bridge is now successfully linked. The registration is stored in app so if you powercycle the raspberry the link status is remembered, so you only need to do this once.
If you don't press the hue link button, or wait too long to invoke this command after pressing the hue button you'll see the following message:
After a successful link, you can now navigate back to the root in AllJoyn explorer, and you should automatically see all the bulbs the Hue bridge controls. You can now control these through the AllJoyn Explorer.
To control a bulb, click it, then org/allseen/LSF/Lamp -> org.allseen.LSF.LampState -> OnOff and flip the value in the drop down:
Now that's it ! You can now build generic light controlling apps using AllJoyn for any AllJoyn enabled bulb. You could also install an existing AllJoyn enabled app like the "LIFX" app, and enable AllJoyn in it, and it'll now also control your Philips Hue bulbs.
For more great resources on AllJoyn on Windows IoT Core go here:
http://ms-iot.github.io/content/en-US/win10/AllJoyn.htm
Comments