Hue - using sendHttpPutRequest to select scenes


I’m trying to use the sendHttpPutRequest command to select a scene saved on the Hue bridge.

When I use the /debug/clip.html the Put request works fine, but I’m struggling to get the right format for adding it to a hue rule.

I’ve seen that the format should be:
sendHttpPutRequest(String url, String contentType, String content)

I’m unclear on what to put for String contentType

Grateful for any help in fixing this.

rule looks like:

rule "Set lights"
Item lgNightLight received command
switch(receivedCommand) {
case ON : sendHttpPutRequest(http:///api//groups/1/action/,‘Content-Type’: ‘text/plain’,“scene”: “”)
case OFF : sendHttpPutRequest(http:///api//groups/1/action/,‘Content-Type’: ‘text/plain’,“scene”: )

This works for me:

sendHttpPutRequest(url_light, “application/x-www-form-urlendcoded”, content)


I’m stuck at activating my scenes via Http-Put.

If I use the CLIP API Debugger it totally works as follows:


Message Body:
“scene”: “80zQpRDoDG1blKE”

How do I put both arguments into a single sendHttpPutRequest in my rules file?

There is another post that contains the solution which does NOT use sendHttpPutRequest
Activating Hue Scenes via rule

Any Answer regarding the sendHttpPutRequest is still appreciated. :wink:

This works to select a scene with sendHttpPutRequest:

val String bridgeURL = "http://<bridge IP>/api/<username>/"
val String scene_id = "<your scene id>"
val String scene_group = "<your scene group>"
sendHttpPutRequest(bridgeURL + "groups/" + scene_group + "/action", "application/json", '{"scene": "' + scene_id + '"}')

And this works aswell:

var String hueApiCall = "curl@@-X@@PUT@@-d@@{\"scene\": %s }@@http://<bridgeIP>/api/<username/groups/<scenegroup>/action"
executeCommandLine(String::format(hueApiCall, '"<scene id>"'))
1 Like