Turning on the Philips Hue lights with Google Glass

'Okay Glass', our Software Developer says. 'Set lights green.' Instantly the lights in his office turn from a soft yellow to green. 'Set lights blue.' The room is now lit blue. It also works with red and purple. How? By simply giving Google Glass a voice command!

How does it work?

How our intern pulled this off? By making a connection between Google Glass and the Philps Hue lamps in our office. He explains it in this video.

Masc's HueGlass application

To develop the HueGlass application we used an interal web servcice we set up ourselves. That internal web service sends requests to the regular Philps Hue web service, the Philips Hue Bridge (PHB). If the lamps are plugged into the electric socket the PHB can control them directly.

Google Glass communiceert via interne API en Hue Bridge met Philps Hue lampen
The tehcnical set-up of the HueGlass app. Left the lamps, the PHB and the internal web service.

Glassware for voice recognition

Since the application is being controlled by voice commands, we added a voice trigger to the Android manifest, that refers to several services. For every command (on, off, blue, red, etc.) a different service is established. The label of the service makes it possible for the voicetrigger decide which service to start.

Every service is derived from a LightService that can start a command and that can register when a command has been executed successfully. When a command is being executed, a new networksafe thread that sends a request to the internal web service is being started in the background. The request is sent in JSON format and the body looks as follows:

{“lightCommand”: “value”}

'Value' can be replaced by the values: on, off, red, green, blue and purple. 
The application can be activated with the following voice command: 'Okay Glass. Set lights "value".' Thereupon the application will start and the lamps will respond with the requested action.