Philips Hue Control

Originally written on December 2, 2016 by ti8
Last modified on April 12, 2018 by ti8

Connecting To the Network

To get the hue on the network at NYU, you need to enter its MAC address via computer.registration.nyu.edu. All the ones ITP owns should be on the network, but if not, check with Marlon Evans.

To find the Hue’s MAC address, look on the bottom. If it’s a Hue Hub 1, there should be a six-byte address like so:  aa:bb:cc:dd:ee:ff. If it’s a Hue Hub 2, there will be a six-character address like this: 1A2B3C. The hub’s MAC address will be that number preceded by 00:17:88, e.g. 00:17:88:1A:2B:3C.

If you’re on the same subnet as the hue (in other words, you’re on the wired ethernet subnet, not the wireless subnets), you can use the command line to discover it. Send a broadcast ping to the subnet,  like so:

$ ping -c 2 255.255.255.255

Then use arp to find it. You know it will start with 0:17:88, so you can do this:

arp -a | grep '0:17:88'

You should get a result like this:

? (192.168.0.21) at 0:17:88:1A:07:A3 on en2 ifscope [ethernet]

Details found at these links:

Connecting to the hub

Once you’ve got the hub’s address, you need to create a user on the hub. Go to http://<hub’s address>/debug/clip.html. Philips’ Getting Started With the Hue API guide will explain how, and help you get going.

To set up a new user, press the hub button, then immediately send the following using the debug interface:

  • URL: /api
  • Method: POST
  • Body: {“devicetype”:”your_app_name”}

You should get a reply including a new user ID like so:

[[ { "success": { "username": "mogX0Q2-OsyTA3WGdryZzz4WEGFA5PyKjgMq9dFj" } }]

That’s the username you’ll need from now on.

Control of the Hue Hub

Here is a repository of examples on controlling the Hue Hub from node.js or client-side JavaScript. Start with the client example, it’s the simplest to understand, especially if you don’t know node.js. You can just open the index.html file in a browser locally and it’ll run.

Adding Hue Bulbs

If you’ve got a new Hue bulb, just give it power and do a search for new bulbs from the debug tool as described in the Getting Started with the API guide. Here’s the command for the debug interface:

  • Url: /api/<your username>/lights
  • Method: POST
  • Body: empty

You should get a reply like this:

[[ { "success": { "/lights": "Searching for new devices" } }]

If your (not so new) bulb won’t show up in the new lamp search, it may have been previously claimed by another hub. You can “steal” it back by using the debug tool. PLace your lamp within 30cm of the hub, power it, and  and enter the following:

  • Url: /api/<your username>/config
  • Method: PUT
  • Body: {“touchlink”:true}

Adding GE Link Bulbs

GE Link bulbs can be added to a Hue hub. To do so, first put the bulb in a working socket and turn it on. Then turn it on and off again every three seconds until it blinks once. This should take about five on-off cycles. When the bulb blinks, run the new light discovery routine on the hub, and the hub should discover and claim the bulb.

Command Line Control

Since the Hue is controlled entirely by HTTP requests, you can use the command line tool curl to control it. For example:

To get a list of all the lights:

$ curl -X GET http://<hub ip address>/api/<your username>/lights

To search for new lights:

$ curl -X POST http://<hub ip address>/api/<your username>/lights

To list discovered lights:

$ curl -X POST http://<hub ip address>/api/<your username>/lights/new

To “steal” a light for your hub:

$ curl -X PUT -d '{"touchlink":true}' http://<hub ip address>/api/<your username>/config

To turn a light on:

curl -X PUT -d '{"on":true}' http://<hub ip address>/api/<your username>/lights/4/state

Compatibility Guide

iConnecthue has a good guide to compatible third party products.