GithubHelp home page GithubHelp logo

arrebagrove / windows-appsample-huelightcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/windows-appsample-huelightcontroller

0.0 0.0 0.0 170 KB

Sample app for Philips Hue lighting with Cortana and Bluetooth LE for the Universal Windows Platform.

License: MIT License

C# 100.00%

windows-appsample-huelightcontroller's Introduction

Hue Lights sample

HueLightController is a Universal Windows Platform (UWP) app sample that explores integrating Windows features with intelligent home automation. Specifically, it shows how you can use Cortana and Bluetooth Low Energy (Bluetooth LE) to create an interactive experience with the Phillips Hue Lights (a Wi-Fi enabled lighting system).

![Using Cortana and Bluetooth LE with Hue Lights Video](Screenshots/Using Cortana and Bluetooth LE with Hue Lights Video.png)

With Cortana integration, users are able to naturally interact with the lights through speech. They can turn the lights off, change their color, or even engage with Cortana in a back-and-forth conversation to adjust a specific light or change all the lights at once.

Additionally, through Bluetooth LE, the app supports a proximity scenario where the lights are automatically turned on/off depending on a user's device relative to a Bluetooth LE beacon.

HueApp connect screen HueApp light screen

Features

The HueLightController app demonstrates:

  • Using the HttpClient methods and Newtonsoft.json to interact with the Hue lights' RESTful interface.
  • Extending Cortana to provide an intuitive voice interface for manipulating the lights.
  • Using BLE APIs in the background to watch for a BLE beacon indicating proximity to the lights.
  • Showing an extended splash screen for more time while the app connects to the Hue hub and searches for lights.

Universal Windows Platform development

This sample requires Visual Studio 2015 and the Windows Software Development Kit (SDK) for Windows 10.

Get a free copy of Visual Studio 2015 Community Edition with support for building Universal Windows apps

Additionally, to be informed of the latest updates to Windows and the development tools, join the Windows Insider Program.

Running the sample

The default project is HueApp and you can Start Debugging (F5) or Start Without Debugging (Ctrl+F5) to try it out. The app will run in the emulator or on physical devices, though functionality related to Cortana and Bluetooth LE is dependent on hardware support. Specific requirements are:

  • Phillips Hue lighting system (any version).
  • A device running Windows 10 that is connected to the Internet, on the same local network as the Hue lights, and supports Bluetooth LE 4.0 or higher (for Bluetooth LE).
  • A second device that supports Bluetooth LE running the Windows 10 Bluetooth advertisement sample to act as the proximity beacon. You can also use a standalone Bluetooth LE device, but you'll need to modify HueLightController's code to receive the correct signal.

Code at a glance

If you’re just interested in code snippets for certain API and don’t want to browse or run the full sample, check out the following files for examples of some highlighted features:

Hue lights:

  • Bridge.cs handles core Hue interactions with the Hue hub, such as registering the app, finding lights, getting light state, and sending HTTP commands to the lights.
  • Light.cs represents a Hue light on the network. It contains properties such as on/off, color, brightness, and so on. Changes to these properties will be reflected on the actual light.
  • HsbColor.cs converts standard aRGB colors (used in Universal Windows apps) to HSB (used by the Hue lighting system).

Extended splash screen:

  • Initializer.xaml contains the image and layout to use for the extended splash screen.
  • Initializer.xaml.cs manages positioning the extended splash screen, loading all the relevant Hue resouces, and then dismissing the extended splash when finished.

Cortana:

  • VoiceCommands.xml defines the structure of voice commands Cortana should recognize as Hue-related so that they can be routed to the HueLightController app. At first, VoiceCommands.xml only specifies the types of phrases Cortana is looking for - the actual words she accepts are added programatically by Initializer.xaml.cs. For example, VoiceCommands.xml states Cortana is listening for a phrase like "Turn my lights [color]," while Initializer.xaml.cs modifies VoiceCommands.xml to include the list of valid colors (red, blue, etc).
  • Initializer.xaml.cs prepares Cortana so she's ready to process Hue commands in the background, even if HueLightController isn't running. This includes dynamically modifying VoiceCommands.xml with the list of valid lights and colors.
  • Cortana.cs receives voice commands from Cortana in the background, processes the user's request (including requesting clarification from the user, if needed), and then sends the appropriate command to the Hue lights.

Bluetooth LE:

  • MainPage.xaml.cs enables or disables the Bluetooth LE background proximity background watcher.
  • Bluetooth.cs processes Bluetooth LE advertisements and turns the lights on or off depending on the user's proximity to the beacon device.

See also

Cortana interactions
Display an extended splash screen for more time
Bluetooth advertisement sample
Cortana voice command sample
Philips Hue Developer Program

windows-appsample-huelightcontroller's People

Contributors

awkoren avatar joshuapartlow avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.