Part 2: Building the Home Automation App – Tell Windows 10 Cortana to Control your Lights


This weekend I decided to take on a personal endeavour and step through my adventures of automating my Home with Windows 10 and IoT (Internet of my Things). You can read about a general overview in part 1 here.

This posting is about my steps and experiences around using Windows 10, an IoT device called the Phillips Hue Lighting system, and some custom code to control my office lights. Let’s first see it in action:

HomeAutomationTurnOnOffLights from Dwight Goins on Vimeo.

In the above video clip, I speak to my Windows 10 personal assistant: Cortana. I tell Cortana to turn my office lights on and off. I can even tell it to change office colors:

HomeAutomationChangeLightColors from Dwight Goins on Vimeo.

This is great!!! So how did you do it?

I created a Windows 10 UWP application and used the Phillips Hue Lighting REST API to control the lights and light colors.

Ok that’s the simple answer so let me expound some more on that. Windows 10 allows you to create Universal Windows Platform applications which target the Windows 10 operating system. The Windows 10 operating system has some core components which make it fairly easy to work with IoT devices. One example of this is controlling the Hue lights. Controlling the Hue lights is accomplished by way of a wireless signal through a local network which Windows 10 can send to the lighting system.

Windows 10 also has a built in personal assistant like that off Apple’s Siri on iPhones. The personal assistant is called Cortana Cortana comes with all Windows 10 devices capable of processing speech and accessing the internet. Cortana can do everything Siri can do and a lot more. As you’ve already seen, one can tell Cortana to perform new and custom actions based on speech, custom code and body gestures. Cortana even supports multiple languages, for those ancient languages that aren’t apart of Cortana, you’ll have to get creative and “englibic” it. Here’s an example:

HomeAutomation_AncientAfricanLanguage from Dwight Goins on Vimeo.

Thus inside the Home automation App, I’m going to tell Cortana to turn on and off the lights, and change the light colors. Cortana will process my speech commands and inform my Home Automation App of which actions it should take. The Home Automation App will then send the commands over the network to the Phillips Hue Lighting system.

Steps

  1. I first started with downloading and installing Visual Studio .Net 2015 on my Windows 10 computer.
  2. Next I downloaded and installed the Windows 10 SDK.
  3. After my environment was setup, I opened up Visual Studio .Net 2015 and I created a new Universal project for Windows 10. (To learn how to do this view getting started)
  4. Next I started researching to find out exactly how to teach Cortana about new speech commands, and how to have Cortana tell my Home Automation App what to do. What I found was a sample project on Github and a nice video explaining how to include Cortana in your UWP apps.
  5. Next I researched how to turn on and off lights in the Hue system from here.
  6. I then just created my custom speech commands and invoked the Hue REST api’s to turn on and off the lights.
  7. Lastly, I looked at the hue, brightness, and saturation fields from the Hue system to get a range of colors and added those colors into my Home Automation app to support changing colors.

Overall this took about 4-5 hours to get it all working and I was impressed how easy it all was.

Now on to my next adventure: Controlling the Sonos Wireless Stereo system. I suspect that this is going to be harder, because I know for a fact that the Sonos system does not provide a documented API to control it, so that means I’ll have to hack it.

Stay Tuned for part 3: Automating a Sonos Stereo system with Windows 10 and IoT

2 thoughts on “Part 2: Building the Home Automation App – Tell Windows 10 Cortana to Control your Lights

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s