Skip to content

WLED - buttons label incorrect #5613

Closed

Description

@xplosv1

What happened?

In the latest WLED version (16.0.0) in the action button presets each button is labeled wrong and or erroneously

Image

push/switch is single press
short is long press
long is double press

To Reproduce Bug

Set presets, push button

Expected Behavior

push/switch is single press -> should be labelled as press
short is long press -> should be labelled as long press
long is double press -> should be labelled as double press

Install Method

Binary from WLED.me

What version of WLED?

WLED 16.0.0 (2605030)

Which microcontroller/board are you seeing the problem on?

ESP32-C3

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 14, 2026

    @softhack007
    Member

    @coderabbitai please compare the related source code of the main and 0_15_x branch. Is the reported behaviour a regression since release 0.15.4? If yes, what is the root cause?

  2. coderabbitai commented on May 14, 2026

    @coderabbitai
    Contributor
    🧩 Analysis chain

    Let me first read the issue and then compare the relevant source code between the branches.


    🏁 Script executed:

    #!/bin/bash
    # Fetch the issue details
    gh issue view 5613 --repo wled/WLED --comments
    

    Length of output: 254


    The issue body seems missing. Let me fetch more details.


    🏁 Script executed:

    #!/bin/bash
    # Fetch the full issue body
    gh api repos/wled/WLED/issues/5613 | jq '{title, body, labels: [.labels[].name], state}'
    
    # Also fetch all comments
    gh api repos/wled/WLED/issues/5613/comments | jq '.[] | {user: .user.login, body}'
    

    Length of output: 1289


    Now I understand the issue. Let me search for the button label source code in both branches.


    🏁 Script executed:

    #!/bin/bash
    # Find files related to button labels in main branch
    echo "=== Files with button-related label strings ==="
    gh api repos/wled/WLED/git/trees/main?recursive=1 | jq -r '.tree[].path' | grep -iE '(button|btn)' | head -40
    
    echo ""
    echo "=== Searching for button action label strings in main branch ==="
    # Check the main wled.h or button.cpp files
    for f in $(gh api repos/wled/WLED/git/trees/main?recursive=1 | jq -r '.tree[].path' | grep -iE '\.(cpp|h|js|htm|html)$' | grep -iE '(button|btn|usermods)'); do
      echo "FILE: $f"
    done
    

    Length of output: 5320


    🏁 Script executed:

    #!/bin/bash
    # Find all web/HTML/JS files in the repo
    echo "=== Web/HTML/JS files ==="
    gh api repos/wled/WLED/git/trees/main?recursive=1 | jq -r '.tree[].path' | grep -iE '\.(htm|html|js)$' | grep -v usermod | head -30
    
    echo ""
    echo "=== button.cpp in main branch ==="
    gh api repos/wled/WLED/contents/wled00/button.cpp?ref=main | jq -r '.content' | base64 -d
    
    echo ""
    echo "=== button.cpp in 0_15_x branch ==="
    gh api repos/wled/WLED/contents/wled00/button.cpp?ref=0_15_x | jq -r '.content' | base64 -d
    

    Length of output: 32704


    The button logic is the same. The bug is in the UI labels. Let me check the settings HTML files.


    🏁 Script executed:

    #!/bin/bash
    # List all settings-related htm files
    echo "=== Settings HTM files in main ==="
    gh api repos/wled/WLED/git/trees/main?recursive=1 | jq -r '.tree[].path' | grep -i settings
    
    echo ""
    echo "=== Check settings.htm in main for button label strings ==="
    gh api repos/wled/WLED/contents/wled00/data/settings.htm?ref=main | jq -r '.content' | base64 -d | grep -n -i -E "(push|switch|short|long|double|press|macroButton|macro)" | head -60
    
    echo ""
    echo "=== Check settings.htm in 0_15_x for button label strings ==="
    gh api repos/wled/WLED/contents/wled00/data/settings.htm?ref=0_15_x | jq -r '.content' | base64 -d | grep -n -i -E "(push|switch|short|long|double|press|macroButton|macro)" | head -60
    

    Length of output: 808


    🏁 Script executed:

    #!/bin/bash
    echo "=== settings_time.htm in main - button/macro label strings ==="
    gh api repos/wled/WLED/contents/wled00/data/settings_time.htm?ref=main | jq -r '.content' | base64 -d | grep -n -i -E "(push|switch|short|long|double|press|macro|button|btn|label|M1|M2|M3|Action)" | head -80
    
    echo ""
    echo "=== settings_time.htm in 0_15_x - button/macro label strings ==="
    gh api repos/wled/WLED/contents/wled00/data/settings_time.htm?ref=0_15_x | jq -r '.content' | base64 -d | grep -n -i -E "(push|switch|short|long|double|press|macro|button|btn|label|M1|M2|M3|Action)" | head -80
    

    Length of output: 3572


    🏁 Script executed:

    #!/bin/bash
    echo "=== settings_time.htm in main - full button block JS (lines 230-290) ==="
    gh api repos/wled/WLED/contents/wled00/data/settings_time.htm?ref=main | jq -r '.content' | base64 -d | sed -n '220,295p'
    
    echo ""
    echo "=== settings_time.htm in 0_15_x - full button block JS (lines 80-130) ==="
    gh api repos/wled/WLED/contents/wled00/data/settings_time.htm?ref=0_15_x | jq -r '.content' | base64 -d | sed -n '75,130p'
    

    Length of output: 4974


    @softhack007 — Yes, this is a confirmed regression in the main branch. Here's the detailed analysis:


    Root Cause Analysis

    Variable Mapping (identical in both branches)

    In settings_time.htm, the addRow(i, p, l, d) function maps the three macro selects the same way in both branches:

    Select name Variable Firmware meaning
    MP${b} p macroButton = short/press (push button) / on→off (switch)
    ML${b} l macroLongPress = long press (push button) / off→on (switch)
    MD${b} d macroDoublePress = double press (push button)

    Labels in 0_15_x — ✅ Correct

    The old table layout had 4 header columns for 4 data cells (Button label + 3 macros):

    Header col 0 Header col 1 Header col 2 Header col 3
    push / switch short / on→off long / off→on double / N/A
    Button i: (label) MP (press) ✓ ML (long press) ✓ MD (double press) ✓

    The first header cell (push/switch) was effectively the column header for the row label ("Button i:"). Each macro input was correctly labelled: short → MP, long → ML, double → MD.


    Labels in main — ❌ Incorrect (regression)

    When the UI was refactored from a table to a block/card layout in main, the labels were reassigned incorrectly (settings_time.htm, ~lines 258–266):

    <label>Push/Switch</label>
    <select name="MP${b}">   ← macroButton = short press ✓ (OK)
    
    <label>Short (on→off)</label>
    <select name="ML${b}">   ← macroLongPress = LONG press ❌ label says "Short"
    
    <label>Long (off→on)</label>
    <select name="MD${b}">   ← macroDoublePress = DOUBLE press ❌ label says "Long"

    The 2nd and 3rd labels are wrong. When the old table header was adapted into per-field labels, the logic shifted by one — the push/switch column header (which referred to the row identifier, not a macro) was incorrectly turned into the first macro's label, cascading the remaining labels onto the wrong fields.


    Observed User Impact

    What user sees Underlying select What it actually controls
    Push/Switch MP ✅ Short press / on→off for switch
    Short (on→off) ML ❌ Actually long press / off→on for switch
    Long (off→on) MD ❌ Actually double press

    This exactly matches the bug report: "short is long press" and "long is double press".


    Suggested Fix in wled00/data/settings_time.htm (main)

    - <label>Short (on→off)</label>
    + <label>Long (off→on)</label>
      <select name="ML${b}" ...>
    
    - <label>Long (off→on)</label>
    + <label>Double Press</label>
      <select name="MD${b}" ...>
  3. softhack007 commented on May 14, 2026

    @softhack007
    Member

    @coderabbitai which commit introduced this regression?

  4. coderabbitai commented on May 14, 2026

    @coderabbitai
    Contributor
    🧩 Analysis chain

    🏁 Script executed:

    #!/bin/bash
    # Get the git log for settings_time.htm on main branch to find the regression commit
    gh api "repos/wled/WLED/commits?path=wled00/data/settings_time.htm&sha=main&per_page=20" \
      | jq -r '.[] | "\(.sha[0:12]) \(.commit.author.date[0:10]) \(.commit.author.name): \(.commit.message | split("\n")[0])"'
    

    Length of output: 1481


    🏁 Script executed:

    #!/bin/bash
    echo "=== Diff for 14bd5d615baf (UI readability improvements) ==="
    gh api repos/wled/WLED/commits/14bd5d615baf | jq -r '.files[] | select(.filename == "wled00/data/settings_time.htm") | .patch' 2>/dev/null | head -120
    
    echo ""
    echo "=== Diff for 4a6ff64519fe (more macro/timer slots) ==="
    gh api repos/wled/WLED/commits/4a6ff64519fe | jq -r '.files[] | select(.filename == "wled00/data/settings_time.htm") | .patch' 2>/dev/null | head -120
    

    Length of output: 8961


    🏁 Script executed:

    #!/bin/bash
    echo "=== addRow function diff in 4a6ff64519fe ==="
    gh api repos/wled/WLED/commits/4a6ff64519fe | jq -r '.files[] | select(.filename == "wled00/data/settings_time.htm") | .patch' 2>/dev/null | grep -A 5 -B 5 -i "addRow\|Short\|Long\|Double\|Push\|Switch\|label\|ML\|MP\|MD" | head -100
    
    echo ""
    echo "=== addRow function diff in 14bd5d615baf ==="
    gh api repos/wled/WLED/commits/14bd5d615baf | jq -r '.files[] | select(.filename == "wled00/data/settings_time.htm") | .patch' 2>/dev/null | grep -A 5 -B 5 -i "addRow\|Short\|Long\|Double\|Push\|Switch\|label\|ML\|MP\|MD" | head -100
    
    echo ""
    echo "=== addRow function diff in ceed494cf793 ==="
    gh api repos/wled/WLED/commits/ceed494cf793 | jq -r '.files[] | select(.filename == "wled00/data/settings_time.htm") | .patch' 2>/dev/null | grep -A 5 -B 5 -i "addRow\|Short\|Long\|Double\|Push\|Switch\|label\|ML\|MP\|MD" | head -100
    

    Length of output: 5120


    🏁 Script executed:

    #!/bin/bash
    echo "=== Full patch for 4a6ff64519fe - lines mentioning label/addRow/rBPO/Short/Long/Double/Push ==="
    gh api repos/wled/WLED/commits/4a6ff64519fe | jq -r '.files[] | select(.filename == "wled00/data/settings_time.htm") | .patch' 2>/dev/null | grep -n "addRow\|rBPO\|label\|Short\|Long\|Double\|Push\|Switch\|select name\|MP\|ML\|MD" | head -80
    
    echo ""
    echo "=== State of addRow function AFTER 4a6ff64519fe (current main) ==="
    gh api repos/wled/WLED/contents/wled00/data/settings_time.htm?ref=4a6ff64519fe | jq -r '.content' | base64 -d | grep -n -A 30 "function addRow\|function rBPO"
    
    echo ""
    echo "=== State of addRow function BEFORE 4a6ff64519fe (parent commit 14bd5d615baf) ==="
    gh api repos/wled/WLED/contents/wled00/data/settings_time.htm?ref=14bd5d615baf | jq -r '.content' | base64 -d | grep -n -A 30 "function addRow\|function rBPO"
    

    Length of output: 5696


    @softhack007 — The exact commit introducing the regression is pinpointed:


    Regression introduced in commit 4a6ff64519fe

    "add more macro/timer slots" (#5140) — 2026-03-29 by Benjam Welker


    What changed

    In that commit, the addRow() function was completely rewritten. The old code (in 14bd5d615baf) used a plain <table> with bare <input type="number"> fields — no inline labels, relying on the table's <thead> column headers for labelling:

    // BEFORE (14bd5d615baf) — no inline labels, table headers provided the column names
    td.innerHTML = `Button ${i}:`;
    td.innerHTML = `<input name="MP${b}" type="number" ...>`;  // column header: "short / on→off"
    td.innerHTML = `<input name="ML${b}" type="number" ...>`;  // column header: "long / off→on"
    td.innerHTML = `<input name="MD${b}" type="number" ...>`;  // column header: "double / N/A"

    The new code in 4a6ff64519fe switched to a block/card layout with <select> dropdowns and per-field <label> elements. The labels were taken from the old table's column headers but shifted by one position — the "Push/Switch" header (which described the button type row, not a macro action) was repurposed as the first macro's label, pushing all subsequent labels onto the wrong field:

    // AFTER (4a6ff64519fe) — labels shifted off by one ❌
    <label>Push/Switch</label>   → <select name="MP${b}">  // macroButton = short press ✅ (label is ambiguous but not wrong)
    <label>Short (on→off)</label> → <select name="ML${b}">  // macroLongPress = LONG press ❌
    <label>Long (off→on)</label>  → <select name="MD${b}">  // macroDoublePress = DOUBLE press ❌

    Suggested fix (same as before, now with confirmed commit context)

    In wled00/data/settings_time.htm, lines ~262–267 of main:

      <label>Push/Switch</label>
      <select name="MP${b}" class="s" required>${presetOpts}</select>
    
    - <label>Short (on→off)</label>
    + <label>Long (off→on)</label>
      <select name="ML${b}" class="s" required>${presetOpts}</select>
    
    - <label>Long (off→on)</label>
    + <label>Double press</label>
      <select name="MD${b}" class="s" required>${presetOpts}</select>

    This can be fixed directly in PR #5140 or as a follow-up patch.

  5. DedeHai commented on May 14, 2026

    @DedeHai
    Collaborator

    @benjamw are you able to provide a fix?

  6. mkdzabel commented on May 17, 2026

    @mkdzabel

    This Info just saved my night. Was debugging endlessly when trying to trigger a playlist via PIR. Can confirm the bug. Changing to short switches correctly from off to on when motion is detected.

  7. benjamw commented on May 21, 2026

    @benjamw
    Contributor

    I'll get a fix in soon.

  8. linked a pull request that will close this issuefix button label regression #5636on May 22, 2026
  9. DedeHai commented on Jun 1, 2026

    @DedeHai
    Collaborator

    @benjamw it was mentioned that analog buttons no longer work with the dropdowns, see https://kno.wled.ge/features/macros/#analog-button

    can you please check if this is the case and open an issue (or a fix PR)?

  10. reopened this on Jun 9, 2026
  11. DedeHai commented on Jun 9, 2026

    @DedeHai
    Collaborator

    @benjamw in the macros I see this:

    Image

    but I think it shold be "short press" , "long press", "double press". can you check?

  12. benjamw commented on Jun 10, 2026

    @benjamw
    Contributor

    I've added more to the PR. Try again. This is what I'm seeing:

    Image
  13. benjamw commented on Jun 10, 2026

    @benjamw
    Contributor

    What branch are you looking at? My fix PR for this issue went into main.

    My new PR for the updated analog buttons also is based off of main.

  14. DedeHai commented on Jun 10, 2026

    @DedeHai
    Collaborator

    I was looking at 16.0, forgot you already made some updates

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions