Aircoookie / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!
https://kno.wled.ge
MIT License
14.25k stars 3.03k forks source link

Loxone JSON parser doesn't handle lx=0 correctly #3809

Open FreakyJ opened 3 months ago

FreakyJ commented 3 months ago

What happened?

I connected WLED to Loxone using the UDP Jason API to control individual segments: {"seg":[{"id":0,"lx":<v>}]} However, when I tunred the stripe off in loxone, it never turned off... I then debuged it using CURL: curl -X POST -H "Content-Type: application/json" -d '{"seg":[{"id":0,"lx":0}]}' 192.168.3.245/json I got success, but nothing changed. Using this command, the stripe looked off (change: "lx":1): curl -X POST -H "Content-Type: application/json" -d '{"seg":[{"id":0,"lx":1}]}' 192.168.3.245/json

I checked the code and in the json.cpp in line 191 and 196 I saw: `if (lx > 0) {

if (ly = 0) {` but it mus be greater or equal, since loxone sends a 0 to turn everything off. Changing the code to this works fine with loxone:

`// lx parser

ifdef WLED_ENABLE_LOXONE

int lx = elem[F("lx")] | -1; if (lx >= 0) { parseLxJson(lx, id, false); } int ly = elem[F("ly")] | -1; if (ly >= 0) { parseLxJson(ly, id, true); }

endif`

To Reproduce Bug

send curl -X POST -H "Content-Type: application/json" -d '{"seg":[{"id":0,"lx":0}]}' 192.168.3.245/json stripe won't turn off

Expected Behavior

stripe should turn off

Install Method

Self-Compiled

What version of WLED?

0.14.2-b1

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output

No response

Anything else?

No response

Code of Conduct

blazoncek commented 3 months ago

I never used Loxone so bear with me.

There is no logic within WLED to turn WLED off from Loxone and there never was (explicitly).

  // lx parser
  #ifdef WLED_ENABLE_LOXONE
  int lx = elem[F("lx")] | -1;
  if (lx > 0) {
    parseLxJson(lx, id, false);
  }
  int ly = elem[F("ly")] | -1;
  if (ly > 0) {
    parseLxJson(ly, id, true);
  }
  #endif

So I do not know if this is a bug or not but the last change to Loxone code was 3 years ago.

blazoncek commented 3 months ago

If you do think this will solve Loxone problem, open a PR, please.