fablab-luenen / McLighting

The ESP8266 based multi-client lighting gadget
MIT License
218 stars 30 forks source link

setMode From HTTP Rest API Doesn't Change Color #28

Closed ryancasler closed 5 years ago

ryancasler commented 5 years ago

I'm unable to use the HTTP Rest API to change the colors in an animation to what they are set to in the web UI. The response from the board is correct but the animation uses the old colors. This is the url that I am using:

http://192.168.1.123/set_mode?m=15&r=255&g=0&b=0&r2=0&g2=0&b2=0&c=100&s=180

And this is the response.

{"mode":7,"ws2812fx_mode":15,"ws2812fx_mode_name":"Fade","speed":180,"brightness":254,"color":[0,255,0,0,0,0,0,0,0,0,0,0]}

However, instead of fading between black and red it fades between blue and red which were the last settings I entered into the webUI.

Conversely, when I set the second color manually via the web ui to be no color, then use this: http://192.168.1.123/set_mode?m=15&r=255&g=0&b=0&r2=0&g2=0&b2=255&c=100&s=180

I get a response of {"mode":7,"ws2812fx_mode":15,"ws2812fx_mode_name":"Fade","speed":180,"brightness":254,"color":[0,255,0,0,0,0,0,255,0,0,0,0]}

But the animation doesn't actually change. It doesn't any difference to what I am seeing. The only thing it appears that I am able to change through the HTTP rest api is the mode. Can you please tell me what I am doing wrong?

Update: It does appear that The settings are being sent to the board because as soon as I make any change to the WebUI, it does change the animation on the board. So, how do i get those changes to take affect without going into the webUI?

Starting from Off doesn't help either. The mode is accepted but not the colors. The colors on the strip continue to be the old settings. The new settings are displayed in the webui but do not match what is on the strip.

bpohvoodoo commented 5 years ago

I am investigating on this issue

bpohvoodoo commented 5 years ago

Hello use the 'all' parameter, as the 'set_mode' only changes the mode on the fly. The rest of the parameters should be ignored, but they aren't at the moment. I correct this and will update the Rest-API docu. Please use: http://192.168.1.123/all?m=15&r=255&g=0&b=0&r2=0&g2=0&b2=255&c=100&s=180

bpohvoodoo commented 5 years ago

REST-API Documentation is no up to date!

bpohvoodoo commented 5 years ago

Please test the new version.

ryancasler commented 5 years ago

Ah! Yes, that would make much more sense. Well, that would mean changing a lot of the implementations I currently have using Toblum's original fork and it would mean changing all 5 boards at once (since I can't have some on the old and some on the new and still have everything work. I'll have to do that when I have slightly more time on my hands. But thanks for clarifying!!

ryancasler commented 5 years ago

I can confirm that is is working using the /all instead. Thank you!!!

ryancasler commented 5 years ago

Scratch that...it still doesn't work.
I use: http://192.168.1.142/all?m=15&rgb=0000FF&rgb2=000000&s=180&c=100 and it still doesn't work. It reports back that the correct color is being used but it still doesn't set the color correctly. I have to issue the request to the board twice in order for it to actually make the change that I requested, I went through and updated all my boards based on you saying this was fixed but now nothing is working. Any help you can give to sort this out would be much appreciated.

UPDATE: Only when I change the programmed mode does the board update the color. If I leave it at the same programmed mode from before, it does not change. I have to issue the request twice. So, when I issue the off command and then request the same mode but with a different color, the color doesn't actually change until I issue the request again.

bpohvoodoo commented 5 years ago

I tested it and it is working. first of all you have to give WRGB Values please add 00 in front of your color values as this version has a w channel, see Rest-API doku, even if you don't use rgbw strips.

rgb: Value for color as HEX WRGB value, e.g. 0004d2ff rgb2: Value for color as HEX WRGB value, e.g. 0004d2ff. rgb3: Value for color as HEX WRGB value, e.g. 0004d2ff

If compatiblity is not an issue, i can change the parameter names from rbg to wrgb to make it clearer.

bpohvoodoo commented 5 years ago

Maybe I found what is causing this.

ryancasler commented 5 years ago

It seems that 2.2.6 has solved this problem. The board is behaving normally now using the links I had earlier. Thanks so much for your quick response!!! Saved my butt big-time. 👍