Send HTTP command to hue lamp

I’d like to activate the alert command of a hue lamp using the HTTP binding.

According to the hue manual this should be possible similiar like this (example for the state command, I need the alert command with command text lselect):

Address http:///api/1028d66426293e821ecfd9ef1a0731df/lights/1/state
Body {“on”:false}
Method PUT

see hue getting started

I tried this without success (no error message, no reaction on hue lamp):

String Hue_Alarm_Http (Light, Sensors) { http=">[*:PUT:http://192.168.0.34/api/key/lights/1/state?alert=lselect" }

sendCommand(Hue_Alarm_Http, “select”)

How can I send the correct http put?

You are missing the “p” at Hue_Alarm_Http.

If this is not the solution, try to use the method instead of action:

Hue_Alarm_Http.sendCommand("select")

Andreas

Hello Andreas,

the missing ‘p’ was a typo in the question only - in the real code it is correctly spelled.

I tried the command below without success :frowning:

Hue_Alarm_Http.sendCommand(“select”)

Hello Horst,

I think you are not sending the JSON format to your HUE gateway. According to your linked geting started you need to send
{"alert":"select"}
in your message body, which I can’t see in your item.

I think you should use a switch item to “PUT” the JSON-String to your HUE instead of a string item?!?!

I have no experience with this, but with some exmaples from other users you don’t need the http binding. Others are using “ExecuteCommandLine” with curl.

Search the forum for examples and maybe this link helps you as well (escape the quotes):
https://developers.meethue.com/comment/310#comment-310

Andreas

1 Like

I got it working by using the built in sendHttpPostRequest :slight_smile:

Let`s trigger the hue alert for one lamp:

var url_light=‘http://192.168.0.34/api/username/lights/5/state’
var content=’{“alert”: “lselect”}’ // use select for one blink, lselect for many

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

2 Likes