WLED icon indicating copy to clipboard operation
WLED copied to clipboard

Toggle and Brightness in same command won't toggle

Open matthias-steinkamp opened this issue 2 years ago • 2 comments

What happened?

If you use brigthness and on=t, the LEDs will be off (turned on by brightness and turned of by toggle)

To Reproduce Bug

use this json command {"on":"t", "bri":128}

Expected Behavior

brightness is set to 128 LEDs on state is toggled, depending on their former power state

Install Method

Binary from WLED.me

What version of WLED?

WLED 0.13.0-b6 (2112080)

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output

No response

Anything else?

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

matthias-steinkamp avatar Aug 08 '22 08:08 matthias-steinkamp

Could you double check the version you are using . WLED 0.13.0-b6 is the sound reactive fork ?

dosipod avatar Aug 08 '22 11:08 dosipod

Could you double check the version you are using . WLED 0.13.0-b6 is the sound reactive fork ?

The error is confirmed in source. The solution is something like this:

  uint8_t tmpBri = bri;
  getVal(root["bri"], &tmpBri);

  if (root["on"].isNull()) {
    if ((onBefore && tmpBri==0) || (!onBefore && tmpBri>0)) toggleOnOff();
    bri = tmpBri;
  } else {
    bool on = root["on"] | onBefore;
    if (on != onBefore || (root["on"].is<const char*>() && root["on"].as<const char*>()[0] == 't')) {
      toggleOnOff();
      // a hack is needed after toggleOnOf()
      if (!root["bri"].isNull()) {
        if (bri==0) briLast = tmpBri;
        else        bri     = tmpBri;
      }
    }
  }

blazoncek avatar Aug 08 '22 12:08 blazoncek

We are trying to use an MCU for control as a simple smart switch without HA .But turning off received brightness will not work ( unit will not receive on /off ) . I am assuming that is the same case above as ON/OFF and brightness is joined

dosipod avatar Aug 15 '22 13:08 dosipod

Fixed in #2737

blazoncek avatar Aug 18 '22 19:08 blazoncek