Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
FreakyJ opened this issue Mar 10, 2024 · 4 comments · Fixed by #4104
Open
1 task done

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

FreakyJ opened this issue Mar 10, 2024 · 4 comments · Fixed by #4104
Labels
bug fixed in source This issue is unsolved in the latest release but fixed in master

Comments

@FreakyJ
Copy link

FreakyJ commented Mar 10, 2024

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

  • I agree to follow this project's Code of Conduct
@FreakyJ FreakyJ added the bug label Mar 10, 2024
@blazoncek
Copy link
Collaborator

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
Copy link
Collaborator

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

Copy link

Hey! This issue has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs.
Thank you for using WLED! ✨

@github-actions github-actions bot added the stale This issue will be closed soon because of prolonged inactivity label Jul 11, 2024
@softhack007 softhack007 removed the stale This issue will be closed soon because of prolonged inactivity label Jul 12, 2024
@FreakyJ
Copy link
Author

FreakyJ commented Aug 14, 2024

I've created the pull request, sorry that it took so long...
#4102

@softhack007 softhack007 linked a pull request Aug 15, 2024 that will close this issue
softhack007 added a commit that referenced this issue Aug 16, 2024
Fixes #3809 Loxone JSON parser doesn't handle lx=0 correctly
@blazoncek blazoncek added the fixed in source This issue is unsolved in the latest release but fixed in master label Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixed in source This issue is unsolved in the latest release but fixed in master
Projects
None yet
3 participants