Looking for help with button actions

I replaced my old under-cabinet lighting in the kitchen with led strips using WLED. I also added over-cabinet lighting during this time. I have a button hooked up and everything is wire correctly. I’m using version 0.12.0. Here are the things I’m trying to do.

  1. Long press to toggle power. I have this setup by creating a preset (ID 1) with T=2 as the API command value, then I use the macros config section to point the Long press button action at preset 1. Is this the proper way to accomplish this? Seems a bit out of place to have a preset/favorite that just toggles power?

  2. Single press to toggle lighting modes. My wife/family is used to the switch just turning on the under-cabinet lights. So to keep it the same, I’d like to single press to cycle through some lighting modes. The first would be just the under-cabinet lights. The next would be just the over-cabinet lights. Then both lights. Lastly, I want an “alert” mode (a bright colored lighting effect, used as an alert/reminder to do something before going to bed). I created 4 presets for these modes (ID 3 for under lights, ID 4 for over lights, ID 5 for both under/over, ID 6 for the alert effect). Then I created another preset (ID 2 which uses PL=~ as the API command. In the macros config section, I pointed the Single press action at preset ID 2. However, this doesn’t really work. I’d like it to just cycle between those 4 lighting modes/presets. But I can’t seem to figure out how to only use those 4 presets. It seems to hit the preset ID 1 in the cycle which toggles the power off.

I’ve seen docs showing how to define presets in a playlist, but I don’t want to automatically switch between those 4 presets on a timer. I want to press the button once to get mode 1, press the button again to go to mode 2, again for 3, again for 4, then again to start back at mode 1, etc.

Anyone have suggestions for accomplishing this? Thanks in advance!

Unfortunately the presets for control get mixed in with the presets for display. I think AC said he was planning on addressing this in the future. I wonder if you could make a preset 7 with the command PL=3.

If that didn’t work, you could change preset 1 to T=2&PL=3 and change preset 2 to PL=~1 so it doesn’t wrap around. If you get to preset 6 and need to go down, you’d long press to turn off and back on but it would also switch to preset 3.

When I try to change preset 1 to this value, nothing happens when I do the long press. When it’s set to just T=2 the toggle function works for the long press, but as soon as I add &PL=3 to the end of the command, it fails to function (nothing seems to happen).

My main issue is that preset 2 which is set to PL=~ isn’t properly cycling through my presets. When I single press, it seems to load my preset 3 ok, but then pressing it again does nothing. If I press it 3 or 4 times, it will eventually get to my preset 6 for the “alert” mode. But it seems to be skipping the presets between 3 and 6. After getting to the “alert” mode in the cycle, I have to single press the button few times before anything happens again and it’ll eventually show preset 3 again. So it seems like the cycle is trying to work, but always skips over presets 4 and 5.

On another (possibly related) note, I think I’m either doing something wrong, or something isn’t working properly… I have preset 2 set to PL=~ and is activated on the single press button action. When I press the button (or tap the preset 2 from the WLED UI), the info shown in the browser for http://my-led-ip/win shows:

<ps>2</ps>

This indicates that it’s currently using preset 2, which seems like it should be fine I guess. Continuing to press the button shows the same ps value in the output of that page when I refresh. It always shows 2 for the <ps> tag value. However, if I issue the following command in my browser instead of using the button or WLED ui:

http://my-led-ip/win&PL=~

then I check the output shown at http://my-led-ip/win and it shows:

<ps>1</ps>

Then refreshing/re-issuing the browser command shows:

<ps>2</ps>

refreshing again shows:

<ps>3</ps>

and so on… So the <ps> value seems to cycle and properly increments with the browser commands. But using the button or WLED ui for preset 2 always shows <ps>2</ps> no matter how many times I press it. Any idea why this might be? It seems like this may have something to do with the issue mentioned above where the single press doesn’t seem to do anything unless I do it a few times.

Have you checked to see if the input is at 3.3V then goes to 0V when you press the button? You may need a pull-up resistor.

I haven’t checked that specifically. I can check later. However, the issue doesn’t seem to be with the button actions not firing. It seems to be an issue with the cycling of the presets. There are two presets that seem to not get loaded every cycle. All others work fine. It’s only those same two presets every time. I’ve hard-reset it multiple times and still the same two presets just don’t load in the cycle. Also, the long press and double press actions work perfectly fine.

I wasn’t sure if it would let you set a preset and toggle the lights at the same time. But I did successfully test my second suggestion. I added a preset at the end, in your case 6, that loads the start of the preset cycle, (PL=3).

You should set your initial preset to 3 (in LED Preferences) and short pressing the button or calling /win&PL=~ should cycle 3,4,5,3,4,5…

I didn’t test with a button. But that is the behavior calling from http.

Ok, I got it working. I did a factory reset first. Then I made my light mode presets 1-4. Then I made the power toggle preset and cycle preset with IDs 50 & 51. It seems like that makes the preset cycle work. It loops through the presets properly now.

@docmattman I’m trying to recreate your success but no love. Can you be more specific about what you put in 50 and 51 and what presets you put in button macro fields. I assume there are no other presets 5-49? Maybe post your entire preset json?

I’d do long press for T=2 and then short press to cycle through a specific range of presets. Seems like this would be easy no? It just doesn’t seem possible to make a cycle of presets with range PL=~1-4 which would have been intuitive for me.

Well I found the solution in an issue. The syntax is close.

put win&P1=1&P2=4&PL=~ in a preset (in your case in 51), then set that id to short and id for preset that has T=2 to long press.

Really this issue is there is no documenation for the API and its syntax.

1 Like

I think really the issue is you not reading the documentation for the API. HTTP request API · Aircoookie/WLED Wiki · GitHub

2 Likes

excellent thx, that’s the page I could not find. So reading not my issue, finding was my issue and also being one of those inconsiderate noobs with a tude.