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:
HomeAutomationTurnOnOffLightsfrom Dwight Goinson 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:
HomeAutomationChangeLightColorsfrom Dwight Goinson Vimeo.This is great!!! So how did you do it?
I created a Windows 10 UWP applicationand used the Phillips Hue Lighting REST APIto 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 CortanaCortana 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_AncientAfricanLanguagefrom Dwight Goinson 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 I first started with downloading and installing Visual Studio .Net 2015on my Windows 10 computer. Next I downloaded and installed the Windows 10 SDK. 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) 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 Githuband a nice videoexplaining how to include Cortana in your UWP apps. Next I researched how to turn on and off lights in the Hue system from here. I then just created my custom speech commands and invoked the Hue REST api’s to turn on and off the lights. 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
- 8java_web学习(五) JSTL标准标签库