API to change Hue light

OH 2.5.0.M1

Trying to get my head wrapped around using the API and can’t get this to work. Just trying to change a Hue light’s color and brightness using an API call.

curl -k -X PUT --header "Content-Type: text/plain" \
--header "Accept: application/json" -d "155,100,20" \
"https://wopr:8443/rest/items/hue_0210_aabbccddeeff_2_color/state"

Is this possible and I’m not doing it right or is this not a valid way to do that?

Hi Steve,

Of course it is possible to change the Hue light state via their API (see https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state). The data in your example is not a valid JSON. A valid body should look like this:

{
	"hue": 50000,
	"on": true,
	"bri": 200
}

May I ask you one question? Why do you want to submit the request manually? Why not make use of the Hue binding?

It’s mostly curiosity but I do have a couple of ideas for automating a few things that would need to send commands from another system. Just theory at the moment.

Where did you get those values for the json info? The link you provide needs a dev account.

I copied the JSON from the link. And yes, you will need an account over there.

I’d rather do the changes via the openhab api rather than the Hue api. This will let me have similar methods for hue lights, zwave devices or other devices if I add other bindings later on.

:man_facepalming: Oh, yes of course. I should have read your initial post more carefully. Sry to point you into a wrong direction. Maybe you should change the title of this topic to make clear that you want to use the OH2 API …

So the right place to look is here. I guess you have to change PUT to POST and remove the trailing /state from the URL.