Using pushbutton to change presets

Can some one give me an idea of how to write instructions so that my D1 Mini push-button on D3 can force, while pressed (pulling it to ground) forces WLED to go to preset 2. once button released WLED goes back to preset 1.
Thank you for any help and teachings.

You would need to set up your button as a switch in LED Preferences, then define “off” and “on” presets in Time & Macros.

Hi, thank you for your help.
I have assigned button 0=13
I have read and re-read all the commands and few samples that work with push button switches,
I know that presets under the preset name a little window open, right? And here’s where I should put the commands but I cannot find a way to do this:
1.-D1Mini boots to preset one (done);
2.- when push button is pressed, D1Mini jumps from preset one to preset 2 and stay there until button is released.
That’s it!
I’m learning as much as I can an I humbly realize that for you guys, the ones with more knowledge and experience this is not much of a challenge for for now for me it is…
Please help me a little more.

Sorry forgot this;
When button is released D1 Mini goes back to preset one preferable after 30 second delay

I’m not sure about staying at 2 while the button is being pressed. But for long press you could start a playlist that plays 2 for 30 seconds then goes back to 1.

{"playlist": {"ps": [2,1], "dur": 300, "transition": 7, "repeat": 1} 
1 Like

can I add this code directly on the small window on the presets? right below the name.

Yep. In the input that appears when you unclick current state.

Thank you. I’m going to do it tonight.

I tried {“playlist”: {“ps”: [2,1], “dur”: 300, “transition”: 7, “repeat”: 1}
but there was a report of SYNTAX ERROR so I changed it to this:
{“playlist”: {“ps”: [2,1], “dur”: 300, “transition”: 7, “repeat”: 1}}
but didnt work either.
what else can I do?

playlist: {
ps: [26, 20, 18, 20],
dur: [30, 20, 10, 50]|
transition: 0,
repeat: 10,
end: 21
what can be wrong?
“playlist”: {
“ps”: [26, 20, 18, 20],
“dur”: [30, 20, 10, 50],
“transition”: 0,
“repeat”: 10,
“end”: 21

You need to quote your attribute names. And do you have a preset 21?

Oh and what version are you running?

version v0.13.0-b3 “Toki”
sorry for the confusion. the code i Added was something I found on WLED and I tried it but didn’t work either. it had the same SYNTAX ERROR as the code you gave me.
{“playlist”: {“ps”: [2,1], “dur”: 300, “transition”: 7, “repeat”: 1}}
What syntax error can it be?

I entered your code all by itself on the API screen and it accepted it BUT, is not doing switching between presets. It switches modes I think. I think is only switching through colors.
where on the preset do I specify the button number? I assigned 4 and 5

Now that you have the playlist preset, note it’s preset id. Then go over to Time and Macros and set that id for your button’s short or long press.

It works!!!
Now I’m dealing with the output from my motion detector and light detector but that’s not so hard.
Thank you for helping me.

You say that like you’re surprised. Which surprises me because of your name.

Hahaha… is not surprise, is reaction to a good accomplishment and thankfulness for your help

I connected the new IR and is working great!!
Now I want to add a photo sensor to deactivate (turn off) the light strip during the day. I thought on using a relay or mosfet to turn off power to the strip but I want to be able to manually with the app turn it on during the day. I been trilingual to use this to turn off the strip:

While you may be able to use a photosensor to do what you want, the builtin Sunrise/Sunset Macro options (with a time offset) may get the effect you want more easily.

{“playlist”: {“ps”: 3, “dur”: 300, “transition”: 7}}
Ps 3 is the preset that deals with the button 0 that makes the preset switch from one to another momentarily
I tried several times with some changes but no luck. The button has been assigned properly…
Thanks for reading my msg