Skip to content

JSON APIs assigned to buttons , e.g {"ps":"1~4~"} #3204

Closed

Description

@dosipod

What happened?

We normally used {"ps":"14"} in a preset and that will work in ui but not when assigned to buttons it does not work only win&PL=~&P1=1&P2=4 works from both ui and when assigned to buttons.

I am not sure that is limited to the above api as assigning other api to buttons like {"on":"t"} will work . I will try to look for more if that is only limited to this

To Reproduce Bug

Add {"ps":"14"} to preset and assign to button action ( clicking on preset will work but button action will not work )
Add win&PL=~&P1=1&P2=4 to preset and assign to button action ( clicking on preset will from ui and button action )

Expected Behavior

{"ps":"14"} and win&PL=~&P1=1&P2=4 is expected to behave the same

Install Method

Self-Compiled

What version of WLED?

WLED 0.14.0-b2 (build 2305090)

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output

More  more info on the same  are here  https://wled.discourse.group/t/physical-button/8289
and here https://discord.com/channels/473448917040758787/473448917543944193/1108240349115191386

The format is messed up in the post because of the use of json so when you see {"ps":"14"} it is like the picture
image

Anything else?

No response

Code of Conduct

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

Activity

  1. blazoncek commented on May 21, 2023

    @blazoncek
    Contributor

    Please check if "Send notifications on button press or IR:" is enabled in Sync settings.
    Unless this setting is checked pressing button will not update UI and WLED state with JSON API call.

    This is by design.

  2. dosipod commented on May 22, 2023

    @dosipod
    ContributorAuthor

    If "Send notifications on button press or IR:" is enabled in Sync settings then other lights on the network will react and still pressing button will not work correctly for json but will work fine with win&PL=~&P1=1&P2=3 , I have attached a pic of the four tests I did with and without changes to Sync settings with both format . I only use the MCU on board GPIO0 button if that could make a difference . If you see otherwise then could be something from our setup
    image

  3. blazoncek commented on May 22, 2023

    @blazoncek
    Contributor

    Then we may need to wait for @Aircoookie to look into it as notification logic is still a bit mystery to me.

  4. blazoncek commented on May 22, 2023

    @blazoncek
    Contributor

    I have traced the workings and it looks like the JSON preset cycling will not work with buttons due to the way how button calls preset.

    From your example:

    • preset 4 contains "ps":"1~3~" and is assigned to a button
    • when button is pressed it schedules applying preset 4 (presets are asynchronous since 0.14)
    • when the (async) schedule is due it loads preset 4 from FS and removes "ps" property to prevent recursive crash
    • resulting preset is empty so execution does nothing
  5. blazoncek commented on May 31, 2023

    @blazoncek
    Contributor

    I have an idea!
    Will provide binary for testing soon (via Discord).

  6. added a commit that references this issue on Jun 6, 2023
  7. added
    fixed in source
    on Jun 6, 2023
  8. added a commit that references this issue on Aug 6, 2023
  9. added a commit that references this issue on Aug 18, 2026
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

    bugfixed in source

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions