0

I tried to put my Hue Lamp on with the Clip API debug tool (as here explained: http://www.developers.meethue.com/documentation/getting-started ) and all works fine.

Now i want to do the same thing over the browser command line and i dont know how to write the url. I tried some variations but none worked....

The url should look something like this: http://192.168.0.18/api/MyHashcode/lights/2/state{"on":true}&mode=put

The problem is the json code shown in the messagebody (link above), i dont know how to embed it in the url. How is the right syntax to get this working?

Thanks in advance, kyi

kyi
  • 43
  • 1
  • 10

1 Answers1

0

In order to modify light state, you have to use a PUT method where the JSON payload is in the BODY of the HTML request. You can't put the JSON in the URL query string.

You can, however, send JSON to the bridge in many languages. Here is an example using AppleScript:

-- define baseUrl to point to your Hue hub address and one of the keys in your whitelist
set baseUrl to " http://YOUR-HUB-IP/api/YOUR-WHITELIST-ENTRY"

-- define some JSON to set a light state
set lightStateOn to the quoted form of " {\"on\": true,\"bri\": 254,\"hue\": 8000,\"sat\": 254} "

-- send the JSON to set a light state (on and with specified hue, saturation, and brightness)
do shell script "curl --request PUT --data " & lightStateOn & baseUrl & "/lights/1/state/"
Ron Reuter
  • 1,287
  • 1
  • 8
  • 14