Skip to content

Incorrect "relay off" handling when controlled by HyperHDR (since 16.0.0) #5619

Todo

Description

@NXTler

What happened?

Greetings all,
I recently updated my WLED wemos shields to WLED 16.0.0 from a fairly old version (early 15.0.0 iirc). Since then, I had issues with their onboard relay staying on continuously despite the LEDs being turned off by HyperHDR. I'm fairly certain this is a firmware issue, as this immediately started happening after updating all of my wemos shields to 16.0.0.

Any help would be greatly appreciated, thanks!

To Reproduce Bug

Not entirely sure what would be the steps to reproduce this. Maybe only the firmware for the wemos shields are effected?

Expected Behavior

I would expect the relay to automatically switch the LED strips off when the LEDs are turned off by an external controller like HyperHDR.

Install Method

Binary from WLED.me

What version of WLED?

WLED_16.0.0-beta_esp32_universal_shield_minimum_4mb (build 2602141)

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output

Anything else?

No response

Code of Conduct

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

Activity

  1. softhack007 commented on May 16, 2026

    @softhack007
    Member

    @NXTler please upload your presets.json and cfg.json. I still have a few wemos shields (by @srg74 ) here, so I can cross-check once the config files are available for me.

  2. DedeHai commented on May 16, 2026

    @DedeHai
    Collaborator

    is this related to realtime-mode being kept active? wasn't there already an issue about that?

  3. softhack007 commented on May 16, 2026

    @softhack007
    Member

    @DedeHai good point - yes we had some discussions, it depends on how HyperHDR starts/stops realtime mode. If HyperHDR sends {"live": true} as a JSON payload before starting the stream, them live mode will stay enabled indefinitely until {"live": false} is received.

    @coderabbitai please check how HyperHDR controls a WLED instance, and especially how it "turns the LEDs off".

  4. coderabbitai commented on May 16, 2026

    @coderabbitai
    Contributor

    Let me research HyperHDR's WLED integration to understand how it controls the device.

    @softhack007, here's a summary of how HyperHDR controls a WLED instance, based on the available source logs and documentation:


    How HyperHDR starts WLED control

    When HyperHDR powers on the WLED device, it issues a REST API PUT to /json/state with a payload like {"on":true,"live":true,"bri":255,"udpn":{"send":false,"recv":false}}. This explicitly puts WLED into realtime override mode ("live":true) and disables WLED's UDP sync.

    HyperHDR then streams actual per-LED color data to WLED via the WARLS/DNRGB UDP protocol on port 21324.


    How HyperHDR "turns the LEDs off"

    When HyperHDR shuts down cleanly, LedDeviceWled.cpp triggers a "Switch off" sequence that issues a PUT to /json/state with "live":false included in the full restored state payload — effectively releasing WLED from realtime mode.


    The problem: unclean shutdown

    The "live" parameter was introduced precisely to prevent WLED from timing out of realtime mode. Sending {"live":true} enters realtime mode and keeps WLED locked there indefinitely — the realtime timeout is bypassed.

    So if HyperHDR crashes, is killed, or loses network connectivity without sending {"live":false}, WLED will remain stuck in live/realtime mode permanently. There is no automatic fallback timeout when live:true was explicitly set via the JSON API.

    This matches reported user symptoms: after HyperHDR is switched off, some WLED instances remain "Live" and uncontrollable from WLED itself, because they never received the live:false release command.


    Summary

    The key risk point is an unclean HyperHDR shutdown (crash, network drop, hard kill). In that scenario, WLED never receives {"live":false} and stays locked in realtime mode indefinitely. A possible mitigation on the WLED side would be to implement a configurable timeout that applies even when live:true was explicitly set — or to allow live:true set via JSON API to still respect the UDP realtime packet timeout once streaming stops.

  5. softhack007 commented on May 16, 2026

    @softhack007
    Member

    @coderabbitai does HyperHDR also send "bri":0 (or "on":false) as part of its regular shutdown sequence? Or is this in user's responsibility?
    If the strip shows a solid black effect but global brightness is not 0, the relay will not switch off.

  6. coderabbitai commented on May 16, 2026

    @coderabbitai
    Contributor

    @softhack007 — based on real HyperHDR log data from multiple user reports, the answer is: No, HyperHDR does not explicitly send "bri":0 as part of its shutdown sequence.

    What HyperHDR actually does on a clean shutdown is restore the WLED state it saved at startup (this is the "Save/restore WLED state" feature introduced in HyperHDR, referenced as PR #353). The actual PUT payload sent to /json/state on shutdown looks like {"bri":128,"live":false,...,"on":true,...} — where "bri":128 is simply the brightness that WLED had before HyperHDR took over, restored verbatim.

    So the implications are:

    1. bri on shutdown = whatever brightness WLED had before HyperHDR started. If the user had WLED running at brightness 128 before starting HyperHDR, it will be restored to 128 on shutdown — not 0.
    2. "on":true is also typically part of the restored state, meaning WLED does not power off at the device level unless the prior-saved state explicitly had "on":false.
    3. A relay configured to cut power based on brightness or on state would therefore not switch off after a clean HyperHDR shutdown, unless the user had deliberately configured the saved WLED state with bri:0 or on:false before starting HyperHDR.

    This is entirely in the user's responsibility — HyperHDR's restore-state mechanism is a best-effort "return to what it was", not an active power-off. Users wanting relay control would need to either:

    • Configure WLED with a low/zero brightness preset before starting HyperHDR, or
    • Use WLED's own power-management features (e.g., the on field or a nightlight timer) separately from HyperHDR's shutdown sequence.

    And of course, in the unclean shutdown case (crash, kill, network drop), none of this payload is sent at all — WLED stays in whatever state it was last put in by HyperHDR.

  7. coderabbitai commented on May 16, 2026

    @coderabbitai
    Contributor

    @softhack007 — confirmed with real HyperHDR log data: No, HyperHDR does not send "bri":0 or "on":false as part of its regular shutdown sequence.

    Real-world logs from HyperHDR users show exactly what gets sent on a clean "Switch off". The log sequence is:

    [LedDevice.cpp] Switch off
    [LedDeviceWled.cpp:200]
    [LedDevice.cpp] Set LED strip to black/power off
    PUT /json/state → {"bri":128,"live":false,"lor":0,...,"on":true,...}
    

    Note the misleading log label "Set LED strip to black/power off" — but the actual payload restores the prior-saved WLED state, which in this case is "bri":128 and "on":true. At startup, HyperHDR sends {"on":true,"live":true,"bri":255} to enter realtime mode, and on shutdown it simply sends back whatever state it saved at that point — it does not set bri to 0.

    So the relay implications are:

    1. "bri":0 is never sent — brightness is restored to whatever WLED had before HyperHDR took control.
    2. "on":false is never sent at the top level — the restored state typically has "on":true.
    3. A relay configured to cut power based on brightness or on state will not switch off after a clean HyperHDR shutdown.
    4. This is fully in user's responsibility — the "black" appearance during live streaming was driven by actual black UDP frames, not by a brightness=0 state. Once live mode exits, WLED reverts to its prior non-zero brightness.

    For relay control to work correctly with HyperHDR, users would need to ensure their pre-HyperHDR WLED state has bri:0 or on:false, or manage the relay independently of WLED's power state.

  8. softhack007 commented on May 16, 2026

    @softhack007
    Member

    @NXTler Please test a short sequence:

    • start WLED, select "solid" effect with any color -> relay on, LEDs show color
    • swtich the lights off using the WLED web UI ("power button") -> relay should "click" off
    • Start a stream from HyperHDR -> relay should switch on
    • End HyperHDR streaming -> wled should return to previous state (Off) -> relay should "click" off
  9. softhack007 commented on May 16, 2026

    @softhack007
    Member

    @coderabbitai in case that HyperHDR would try to restore WLED state with {"bri":0,"live":false,...,"on":true,...}, would ,"on":true have precedence over "bri":0? Is WLED 16.0.0 behaving the same way as the older 0.15.0?

  10. coderabbitai commented on May 16, 2026

    @coderabbitai
    Contributor
    🧩 Analysis chain

    Let me look at the WLED source code to understand how bri and on interact in the JSON state API.


    🏁 Script executed:

    #!/bin/bash
    # Find JSON state handling files
    fd -e cpp -e h json | head -20
    
    # Search for how 'bri' is processed in json state
    rg -n "bri" --type cpp -C 3 | grep -A3 -B3 '"bri"' | head -80
    
    # Search for on/off and brightness interaction
    rg -n '"on"' --type cpp -C 5 | head -80
    

    Length of output: 10874


    Now let me look more closely at the toggleOnOff() function and check for any version differences.

    @softhack007 — the source code from wled00/json.cpp makes the behavior very clear. Here is the step-by-step analysis:


    What happens with {"bri":0, "live":false, ..., "on":true, ...}?

    The relevant logic in deserializeState() (current main branch, which is 0.16.x):

    bool onBefore = bri;           // save current on-state (bri>0 means on)
    getVal(root["bri"], bri);      // bri = 0 (applied from "bri":0)
    
    bool on = root["on"] | (bri > 0);  // on = true (from "on":true field)
    if (!on != !bri) toggleOnOff();    // !on=false, !bri=true → mismatch → toggleOnOff() called!

    When toggleOnOff() is called with bri == 0, it sets bri = briLast (the last non-zero brightness). So the end result is:

    • "on":true "wins" — but not by direct precedence. Rather, the contradiction between on=true and bri=0 is detected and resolved by calling toggleOnOff(), which restores briLast.
    • The device ends up ON at briLast brightness — not off. The relay will not click off.

    This is also consistent with the official WLED API documentation, which states:

    "Setting bri to 0 is supported but deprecated, it is recommended to use the range 1–255. The state response will never have the value 0 for bri."

    The bri field semantics are: "Brightness of the light. If on is false, contains last brightness when light was on (aka brightness when on is set to true)."

    So bri is always the "active brightness when on" — bri:0 is essentially a deprecated alias for "turn off", but if on:true contradicts it, on:true takes effect via the toggle mechanism.


    WLED 0.15.0 vs 0.16.0

    The !on != !bri → toggleOnOff() logic exists in the current main branch and there is no indication in the source or changelog that this was fundamentally changed between 0.15.x and 0.16.x. The deprecation of bri=0 has been in place for a long time. Both versions should behave identically for this payload.


    Summary for the relay issue

    Payload Result
    {"bri":0, "on":false} Turns OFF → relay clicks off ✅
    {"bri":0, "on":true} toggleOnOff() fires → ends up ON at briLast → relay stays ON ❌
    {"bri":128, "on":false} Turns OFF (bri stored as briLast) → relay clicks off ✅
    {"bri":128, "live":false, "on":true} Normal restore, ON at 128 → relay stays ON ❌

    So even in the hypothetical case where HyperHDR restored state with bri:0, as long as on:true is also in the payload, the device will end up on at the previous brightness — the relay would not switch off.

  11. NXTler commented on May 16, 2026

    @NXTler
    Author

    @NXTler please upload your presets.json and cfg.json. I still have a few wemos shields (by @srg74 ) here, so I can cross-check once the config files are available for me.

    And here is the configuration for one controller:
    wled_presets_wled-desktop.json
    wled_cfg_wled-desktop.json

  12. NXTler commented on May 16, 2026

    @NXTler
    Author

    @NXTler Please test a short sequence:

    * start WLED, select "solid" effect with any color -> relay on, LEDs show color
    
    * swtich the lights off using the WLED web UI ("power button") -> relay should "click" off
    
    * Start a stream from HyperHDR -> relay should switch on
    
    * End HyperHDR streaming -> wled should return to previous state (Off) -> relay should "click" off
    

    The relay works fine from the WebUi, but will not turn off when HyperHDR is used.

  13. srg74 commented on May 16, 2026

    @srg74
    Contributor

    Stand alone WLED instances with relays working as expected. I have suspicions that third part software handle WLED instance incorrectly.

  14. softhack007 commented on May 16, 2026

    @softhack007
    Member
    • start WLED, select "solid" effect with any color -> relay on, LEDs show color
    • switch the lights off using the WLED web UI ("power button") -> relay should "click" off
    • Start a stream from HyperHDR -> relay should switch on
    • End HyperHDR streaming -> wled should return to previous state (Off) -> relay should "click" off

    The relay works fine from the WebUi, but will not turn off when HyperHDR is used.

    @NXTler it means that the last step in above sequence "fails" (relay stays on), right?

    Edit: I want to be sure you followed the sequence step-by-step; each step will confirm or exclude a possible root cause, but only if following the exact sequence.

  15. 26 remaining items

  16. softhack007 commented on May 18, 2026

    @softhack007
    Member

    The key requirement is just that some state change happens on Nodes B/C/D more than ~1 second after Node A exits realtime.

    @coderabbitai I agree that recv.bri=false on the HyperHDR-controlled device should solve the original problem.

    But the mechanism to create the brightness change message is still dubious to me. We already agreed that a single node will not re-transmit any state change it receives via the sync protocol. We can also assume that @NXTler did not interact with his other WLED devices during testing. One of the other devices silently rebooting also sounds far-fetched to me, same as any active playlist or usermods that regularly changes state on another node - please check the user's uploaded presets.json for confirmation.

    After all these unlikely explanations, is there still a credible scenario left?

  17. coderabbitai commented on May 18, 2026

    @coderabbitai
    Contributor
    🧩 Analysis chain

    🏁 Script executed:

    #!/bin/bash
    echo "=== Full presets.json content ==="
    curl -sL "https://github.com/user-attachments/files/27855643/wled_presets_wled-desktop.json" | python3 -m json.tool
    
    echo ""
    echo "=== Check for playlist entries ==="
    curl -sL "https://github.com/user-attachments/files/27855643/wled_presets_wled-desktop.json" | python3 -c "
    import sys, json
    data = json.load(sys.stdin)
    print('Top-level keys:', list(data.keys()))
    for k, v in data.items():
        if isinstance(v, dict):
            print(f'Preset {k}: keys={list(v.keys())}')
            if 'playlist' in v or 'pl' in str(v):
                print(f'  --> HAS PLAYLIST/TIMER: {v}')
        elif k == 'playlist' or 'pl' in k:
            print(f'  --> TOP-LEVEL PLAYLIST: {v}')
    "
    

    Length of output: 7640


    @softhack007 — confirmed: the presets.json has no playlists, no timers, and no scheduled entries — just three plain effect presets (all on:true) with def.ps=0 (no startup preset). Zero automatic state-change triggers on this node.


    Is there still a credible scenario without user interaction?

    After ruling out playlists, usermods, and the OS-buffer stale-packet path, let me be direct: within WLED itself, no purely automatic mechanism remains that would cause a silent Node B/C/D to spontaneously emit a bri>0 notification after having received and applied bri=0 from Node A. WLED has no heartbeat/periodic broadcast — notify() is only called on explicit state changes.

    The only paths that remain credible are outside WLED's own code:

    Scenario Credibility
    User inadvertently interacts with another device during test (web UI, phone app, voice command) ✅ High — the most likely explanation
    Home automation hub / voice assistant reacting to Node A's startup bri=255 broadcast and later independently controlling B/C/D ✅ Plausible in a household setup
    UDP packet loss: Node A's bri=0 broadcast is dropped for one or more B/C/D nodes → they stay at bri=255, but stay silent until the next user-driven change ⚠️ Possible as a background condition that amplifies human interaction
    Silent reboot of Node B/C/D: on boot, WLED sends a notify with its default state ⚠️ Possible if a node is flaky on WiFi, but far-fetched for a controlled test
    An automatic trigger within WLED (effect tick, rendering loop, etc.) ❌ Not present — rendering never calls notify()

    Practical conclusion

    The recv.bri=false fix is the right recommendation regardless of which specific external trigger fires, because it makes Node A completely immune to the whole class of "another device changes state and I'm listening for brightness" problems. Whether the trigger is inadvertent user interaction, a home automation hub, or a dropped UDP packet — none of them can affect Node A's relay if recv.bri=false.

    If the goal is to further confirm the exact trigger, @NXTler could repeat the test with all other WLED devices physically powered off (not just idle), which would definitively isolate WLED sync from any WiFi-level source.


    ✏️ Learnings added
    Learnt from: softhack007
    URL: https://github.com/wled/WLED/issues/5619
    
    Timestamp: 2026-05-18T22:06:57.887Z
    Learning: In WLED issue `#5619`, analysis of the user's presets.json confirmed no playlists, timers, or scheduled entries exist. Within WLED itself, there is no purely automatic mechanism for a Node B/C/D to spontaneously emit bri>0 notifications after receiving and applying bri=0 from Node A via sync. WLED has no periodic heartbeat broadcast — notify() is only called on explicit state changes. The relay-stays-on symptom requires an external trigger: user interaction with another device, a home automation hub reacting to WLED state changes, or (as a background amplifier) UDP packet loss leaving some nodes at bri=255.
    

    Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

  18. softhack007 commented on May 18, 2026

    @softhack007
    Member

    @NXTler please uncheck "Receive: Brightness" in sync settings on your HyperHDR controlled wled, then run the short test sequence again (other WLEDs on your network stay on). Does ending the HyperHDR stream now lead to the expected power-off relay click?

    Bonus questions: do you have any other home automation system that would regularly interact ("chat") with your WLED devices? Not just the one for HyperHDR, but any other WLED on your WiFi?

  19. added
    needs investigation
    on May 19, 2026
  20. NXTler commented on May 19, 2026

    @NXTler
    Author

    Noticed something interesting while testing this. When turning off HyperHDR, and therefore sending the off signal to WLED, the WLED webinterface still displays it receives USP data from HyperHDR even after reloading.

  21. NXTler commented on May 19, 2026

    @NXTler
    Author

    All wemos shields turn off as they are supposed to without the "Receive: Brightness" option enabled. However, this option also means they will not turn on together when only turning on one of them. Furthermore, it doesn't seem to work reliably.

  22. added this to the 16.1 milestone on Jun 16, 2026
  23. NXTler commented on Jul 3, 2026

    @NXTler
    Author

    Okay, I updated the firmware to WLED_16.0.0_esp32_universal_shield_minimum_4mb and did some more testing. This issue seems to randomly occur even with Sync fully disabled on all shields.
    For seemingly random shields the webui will keep displaying WLED is receiving live UDP data from [...] with the relay on after HyperHDR has already shutdown and will not recover until clicking Override once.

  24. softhack007 commented on Jul 3, 2026

    @softhack007
    Member

    WLED_16.0.0_esp32_universal_shield_minimum_4mb and did some more testing.

    @NXTler please try a recent development firmware build - either 16.0.1-dev or 17.0.0-dev (nightly). Both have received several bug fixes that might interact with the problem.

    For seemingly random shields the webui will keep displaying WLED is receiving live UDP data from [...] with the relay on after HyperHDR has already shutdown and will not recover until clicking Override once.

    This sounds like WLED is not receiving the final {"live":false,...}JSON command from HyperHDR - either due to packet loss, or due to buffer congestion either on sender or on receiver side.

  25. NXTler commented on Jul 4, 2026

    @NXTler
    Author
  26. NXTler commented on Jul 5, 2026

    @NXTler
    Author

    This sounds like WLED is not receiving the final {"live":false,...}JSON command from HyperHDR - either due to packet loss, or due to buffer congestion either on sender or on receiver side.

    I somewhat doubt that, as the wled is then stuck in that state forever until clicking Override once. No amount of restarting HyperHDR (and therefore resending the JSON command) will make the controller turn off. The issue still persists in the newest nightly build.

  27. softhack007 commented on Dec 1, 2026

    @softhack007
    Member

    there is a good change that this is resolved by merging #5932, which fixes random "trailing" UDP sync packets that can lead to the described behaviour.

  28. modified the milestones: 16.1, 17.0 on Dec 1, 2026
  29. NXTler commented on Dec 3, 2026

    @NXTler
    Author

    Still fails to disable some relays at random times. It's a bit more consistent and the relays are not stuck, but it's also not great.
    I will probably switch to anothor system in the furture, as this one is causing me too many issues. It also looks like AI overtook most of the development by now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds investigation

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions