Skip to content
probonopd edited this page Jul 5, 2015 · 9 revisions

Hue API

When developing the emulator, i found it useful to see actual requests and responses. For that I used sudo java -jar HueEmulator-v0.4.jar from http://steveyo.github.io/Hue-Emulator/. No information on this page is coming from actual Hue devices or proprietary sources, everything is derived by looking at the responses given by the Open Source HueEmulator-v0.4.jar.

Step 1: Discover the bridge

To discover the bridge, clients can use the mechanisms described in this Wiki under "Discovery". The result of the discovery phase is that the client has the IP address of the bridge. (Interestingly enough, the client was not able to retrieve the IP from HueEmulator-v0.4.jar which might be a bug therein).

Step 2: Authenticate

The client sends the following HTTP POST data to /api:

{  "username" : "e7x4kuCaC8h885jo",  "devicetype" : "clientname#devicename"}

with clientname = the name of the client app and devicename = the name of the device the client app is running on.

The bridge responds with

[  
   {  
      "error":{  
         "address":"",
         "description":"link button not pressed",
         "type":"101"
      }
   }
]

Note that there are brackets around this response.

However, if the button on the bridge is pressed (or if the username has been whitelisted before), then the bridge responds with

[  
   {  
      "success":{  
         "username":"e7x4kuCaC8h885jo"
      }
   }
]

Note that there are brackets around this response.

At this time the Bridge probably persists (saves) the username and the devicetype, and whitelists them. The purpose of this is so that only clients can interact with the bridge which have been authorized by pressing the button on the bridge.

Step 3: Get information about the bridge

To get information about the bridge (but NOT about the connected devices), the client sends a HTTP GET request to /api/e7x4kuCaC8h885jo/config. The bridge responds with:

{  
   "portalservices":false,
   "gateway":"192.168.2.1",
   "mac":"00:00:88:00:bb:ee",
   "swversion":"01005215",
   "linkbutton":false,
   "ipaddress":"192.168.0.13:80",
   "proxyport":0,
   "swupdate":{  
      "text":"",
      "notify":false,
      "updatestate":0,
      "url":""
   },
   "netmask":"255.255.255.0",
   "name":"Philips hue",
   "dhcp":true,
   "proxyaddress":"",
   "whitelist":{  
      "e7x4kuCaC8h885jo":{  
         "name":"clientname#devicename",
         "last use date":"2015-07-05T16:48:18",
         "create date":"2015-07-05T16:48:17"
      }
   },
   "UTC":"2012-10-29T12:05:00"
}

Note that there are no brackets around this response.

Get ALL information about the bridge

To get ALL information about the bridge (including information about all connected devices), the client sends a HTTP GET request to /api/e7x4kuCaC8h885jo.

The bridge responds with

{  
   "lights":{  
      "1":{  
         "state":{  
            "on":true,
            "bri":254,
            "hue":4444,
            "sat":254,
            "xy":[  
               0.0,
               0.0
            ],
            "ct":0,
            "alert":"none",
            "effect":"none",
            "colormode":"hs",
            "reachable":true
         },
         "type":"Extended color light",
         "name":"Hue Lamp 1",
         "modelid":"LCT001",
         "swversion":"65003148",
         "pointsymbol":{  
            "1":"none",
            "2":"none",
            "3":"none",
            "4":"none",
            "5":"none",
            "6":"none",
            "7":"none",
            "8":"none"
         }
      },
      "2":{  
         "state":{  
            "on":true,
            "bri":254,
            "hue":23536,
            "sat":144,
            "xy":[  
               0.346,
               0.3568
            ],
            "ct":201,
            "alert":"none",
            "effect":"none",
            "colormode":"hs",
            "reachable":true
         },
         "type":"Extended color light",
         "name":"Hue Lamp 2",
         "modelid":"LCT001",
         "swversion":"65003148",
         "pointsymbol":{  
            "1":"none",
            "2":"none",
            "3":"none",
            "4":"none",
            "5":"none",
            "6":"none",
            "7":"none",
            "8":"none"
         }
      },
      "3":{  
         "state":{  
            "on":true,
            "bri":254,
            "hue":65136,
            "sat":254,
            "xy":[  
               0.346,
               0.3568
            ],
            "ct":201,
            "alert":"none",
            "effect":"none",
            "colormode":"hs",
            "reachable":true
         },
         "type":"Extended color light",
         "name":"Hue Lamp 3",
         "modelid":"LCT001",
         "swversion":"65003148",
         "pointsymbol":{  
            "1":"none",
            "2":"none",
            "3":"none",
            "4":"none",
            "5":"none",
            "6":"none",
            "7":"none",
            "8":"none"
         }
      }
   },
   "schedules":{  
      "1":{  
         "time":"2012-10-29T12:00:00",
         "description":"",
         "name":"schedule",
         "command":{  
            "body":{  
               "on":true,
               "xy":null,
               "bri":null,
               "transitiontime":null
            },
            "address":"/api/newdeveloper/groups/0/action",
            "method":"PUT"
         }
      }
   },
   "config":{  
      "portalservices":false,
      "gateway":"192.168.2.1",
      "mac":"00:00:88:00:bb:ee",
      "swversion":"01005215",
      "linkbutton":false,
      "ipaddress":"192.168.0.13:80",
      "proxyport":0,
      "swupdate":{  
         "text":"",
         "notify":false,
         "updatestate":0,
         "url":""
      },
      "netmask":"255.255.255.0",
      "name":"Philips hue",
      "dhcp":true,
      "proxyaddress":"",
      "whitelist":{  
         "newdeveloper":{  
            "name":"test user",
            "last use date":"2012-10-29T12:00:00",
            "create date":"2012-10-29T12:00:00"
         },
         "e7x4kuCaC8h885jo":{  
            "name":"clientname#devicename",
            "last use date":"2015-07-05T17:04:02",
            "create date":"2015-07-05T16:58:10"
         }
      },
      "UTC":"2012-10-29T12:05:00"
   },
   "groups":{  
      "1":{  
         "name":"Group 1",
         "action":{  
            "on":true,
            "bri":254,
            "hue":33536,
            "sat":144,
            "xy":[  
               0.346,
               0.3568
            ],
            "ct":201,
            "alert":null,
            "effect":"none",
            "colormode":"xy",
            "reachable":null
         },
         "lights":[  
            "1",
            "2"
         ]
      }
   },
   "scenes":{  

   }
}

Note that there are no brackets around this response.