Since there is no lifx binding for openHAB 1.x I am using “executeCommandLine”-action with curl to set my predefined light scenes.
executeCommandLine(lifxcurl + "@@-k@@-H@@Authorization: Bearer " + lifxtoken + “@@-XPUT@@” + lifxurl + “/scenes/scene_id:” + lifx_scene_hell + “/activate”)
translates to
2015-11-22 15:51:09.317 [INFO ] [g.openhab.io.net.exec.ExecUtil] - executed commandLine ‘[/usr/bin/curl, -k, -H, Authorization: Bearer XxXxXxXx, -XPUT, https://api.lifx.com:443/v1/scenes/scene_id:xxx-xxx-xxx-xxx/activate]’
This works fine so far.
Now I want to send some JASON data with the request.
This curl command works in the shell:
/usr/bin/curl -k -H “Content-Type: application/json” -H “Authorization: Bearer c7a38a4e32ed7c8c46fe7e19c795bfedb0fb4abc2fbe50d34d0731a80662a98c” -XPUT -d ‘{“power”:“on”,“color”:“ue:50 saturation:0 kelvin:3000”,“brightness”:0.5,“duration”:10}’ https://api.lifx.com/v1/lights/label:Kommode,label:Subwoofer/state`
But I cannot get it to work in openHAB.
This (simplified command) is in the log and does not work:
executed commandLine ‘[/usr/bin/curl, -k, -H, Content-Type: application/json, -H, Authorization: Bearer c7a38a4e32ed7c8c46fe7e19c795bfedb0fb4abc2fbe50d34d0731a80662a98c, -XPUT, -d, ‘{“power”:“on”}’, https://api.lifx.com:443/v1/lights/all/state]’
I think there might be a problem with the quotation marks after “-d” in the JSON-part.
But I have no idea what I should change.
I already tried several syntaxes.
Does anybody have a working JSON-PUT-request in openhab?
My workaround would be to call a bash script with the working curl command.