Ezlo HTTP API Set RGB Color How?

I think I know how to do it for the WebSocket, because it’s all JSON. If I had to guess for HTTP, though, I’d first try:

https://Ezlo-IP:17000/v1/method/hub.item.value.set?_id=60e47f4e120bab11f9d77f5e&value=%7b%22red%22%3a255%2c%22green%22%3a0%2c%22blue%22%3a0%2c%22cwhite%22%3a0%2c%22wwhite%22%3a0%7d

The value parameter is the URL-encoded JSON string {"red":255,"green":0,"blue":0,"cwhite":0,"wwhite":0}

1 Like

Hi

Just tried that and the browser returns this:

{“error”:{“code”:-32602,“data”:“rpc.params.wrong_field”,“message”:“Wrong field of object”,“reason”:“Unexpected Json format for value type ‘rgb’: "{\"red\":255,\"green\":0,\"blue\":0,\"cwhite\":0,\"wwhite\":0}"”},“id”:“60e8c6e7120bab124281ffac”,“result”:{}}

Well, it was worth a shot. Maybe they’ll update the documentation.

You can see the value object format like that in the API Tool before you expand it:

image

All though the colours are in a different order. I just tried them in that same order in the URL but still the same.

https://Ezlo-IP:17000/v1/method/hub.item.value.set?_id=60e47f4e120bab11f9d77f5e&value={"blue":0,"cwhite":0,"green":0,"red":255,"wwhite":0}

I also tried with both “&value=” and “&value_rgb=”

I would expect that; the order of keys doesn’t usually matter in objects (although you never know how the API might be parsing the data). There are a number of items like this in the API docs that need to be further documented. There’s just too much that’s left to “discovery”, and experience has also shown that if it’s not documented, in the absence of specification there will be variances in functionality/interpretation over time as well. That list of items and values should explicitly describe the structure (for both HTTP and WebSocket APIs), acceptable range of values, and the meaning of values in the range. It’s got default values, which is good. Needs the rest.

Another question in this call is the meaning of cwhite and wwhite. By default, I’d assume that they mean the same thing that they did on Vera (wwhite is 2000K-5500K range scaled 0-255, and cwhite is 5500-9000K range scaled 0-255), but (a) nobody who hasn’t developed for Vera would know that, and (b) who knows if that’s even a correct assumption.

Indeed we are just left guessing and not knowing.

From that link you just posted:

image

I did have a poke around that documentation site earlier, but could not find the answer to this question.

@cw-kid,
here you can find description for RGB value type
https://api.ezlo.com/devices/item_value_types/index.html
I will share several examples here.

Thanks

I saw that page before but it doesn’t help me.

Thanks

I will share several examples here asap.

1 Like

Hi cw-kid,

you should use the POST request with /v1/request. The /v1/method GET is too limited for commands like this.

Cheers Rene

I hope not.

Let me try it in Postman app then with Post.

Why don’t they make this easier ? Grrr !

I don’t know how to do this type of request in Postman with Post.

I can get values back from devices like temperature sensors or a switches ON / OFF state using POST.

But I am not sure how to format the JSON payload for this RGB SET request.

It probably wants to be something that looks more like this:

But I don’t know what the correct JSON data format should be ?

NOTE - In the first screen shot on the left hand side you can see all those other Requests that SET things. They are all GET single one line HTTP commands.

For Ezlo HTTP API, this is a working POST request but its for retrieving a value from a device, in this case a temperature sensor value. Rene you were the one who showed us how to do this.

I still haven’t seen a simple one line HTTP command to get a devices value ???

On Vera HTTP API (Luup Requests) you can just use a GET command:

http://Vera-IP/port_3480/data_request?id=variableget&DeviceNum=678&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature

I just got it working with POST in Postman app using this JSON data, my bulb changed from blue to red !

URL =

https://192.168.0.11:17000/v1/method

JSON Data =

{"method": "hub.item.value.set" , "id" : "_ID_" , "params" : {"_id" : "60e47f4e120bab11f9d77f5e" , "value" : {"red":255,"green":0,"blue":0,"cwhite":0,"wwhite":0}}}

Its a start at least, but I really need to be able to just send a single HTTP command (GET) in to the Ezlo hub.

But maybe this needs to be POST which sucks.

@bill_v

Can I send out a POST command from Home Remote dashboard app? I think all the ones you helped me with before were just GET.

Thanks

It works on Vera firmware controllers with a single GET HTTP command.

I can change the R,G,B colour on a Fibaro RGBW mobile with this command:

http://VERA-IP:3480/data_request?id=action&output_format=json&DeviceNum=176&serviceId=urn:micasaverde-com:serviceId:Color1&action=SetColorRGB&newColorRGBTarget=255,0,0

But seems the new Ezlo HTTP API no longer allows for this potentially.

Yes. You can send a POST request with a Home Remote plugin. It’s not much different than the GET. Just change “http.get” to “http.post” & be sure to include your Content (data) as the 2nd argument to the function. You can read more about it here:

Thanks Bill I will take a look.

Another option might be Multi System Reactor. The first version that supports Ezlo hubs has just been released.

If I can control the colours of the RGB bulb paired to the Ezlo Plus hub via MSR, then I will be able to use MSR’s own much simpler HTTP API and create some different colour “scenes” in MSR and just send GET commands from Home Remote dashboard app to MSR to run those “scenes” etc to in turn control the bulb, effectively cutting out Ezlo’s own HTTP API that requires POST for controlling RGB lights.

I believe the MSR integration uses the wss web socket for interacting with the Ezlo hubs.

I have had it confirmed by an Ezlo developer that it does require POST to set colours on an RGB light, which makes it more difficult for end users to use.

The whole point of the HTTP Server API is for end users to be able to use, not just for developers or more technical types.

So it should be made more simple like the current Vera Luup Requests HTTP API.

Every time they make something POST it ups the difficulty. Also I have some other apps I use that don’t support sending POST commands, so it should all be GET like Vera is now in my opinion.

I know it’s not always possibile, but my own Virtual Plug-in is supporting curl commands, so you should be able to map an Elzo command this way. I’m using it for my own endpoints accepting POSTs and it’s rock solid (and it’s using RGB virtual devices as well). Give it a try.

1 Like

I have MSR up and running controlling devices on my Ezlo Plus hub now !!!

I have created a set of “Global Reactions” that simply turn on my RGB bulb and set it to a particular colour:

“Global Reaction” summary card for RED:

Now using MSR’s simple HTTP API → I can send simple one line GET HTTP commands from my dashboard page in Home Remote.

This is an example of an MSR HTTP command to run a particular “Global Reaction”, in this example it runs my reaction or “scene” for Red colour:

http://MSR-IP:8111/api/v1/reaction/re-kr6dwist/run

I now thanks to the MSR developer, have a dashboard page like this, that works and changes the colours of my RGB bulb paired to the Ezlo Plus hub.

As I said it’s a shame the official Ezlo HTTP Server API can’t control colours on a light with GET instead of the more complicated POST.

image

It can be laggy sometimes however changing colours, when clicking on these buttons too quickly. Likely the Ezlo HTTP web socket API being slow to respond ?

1 Like

That same request you sent with Postman would look something like this in a Home Remote plugin.

var data = {"method": "hub.item.value.set" , "id" : "_ID_" , "params" : {"_id" : "60e47f4e120bab11f9d77f5e" , "value" : {"red":255,"green":0,"blue":0,"cwhite":0,"wwhite":0}}};
http.post("https://192.168.0.11:17000/v1/method", data);
1 Like