Well, it’s remarkably easy.
I started with a single one-liner built in Apple Shortcuts. I called it Toggle LEDs. It turns my whole WLED setup on and off. In the Shortcut app what it does is simply a “Get Contents of” call with the parameter of “https://[my-leds].local/win&T=2”. Where obviously [my-leds] is the mDNS name for my local WLED instance. If you don’t have mDNS enabled, just use the IP address.
I created that shortcut, checked “Pin in Menu Bar” and “Show on Apple Watch”. Boom, it shows up on my Mac’s menu bar at the top, on my iPhone, and yes, even on my watch. Easy peasy, and super cool.
So that got me thinking, how about doing presets? So I created a bunch of presets in WLED, numbered them 1-7, then went into Apple Shortcuts again. Now this took some fiddling and debugging. Fortunately, Shortcuts natively understands JSON, so it’s pretty easy.
I think I can share this safely, here it is: Shortcuts
What it does is:
- Get the JSON state from WLED (using …/json/state)
- Get the ps (current preset value) from that result, again Shortcuts parses the JSON
- Add one to it
- Do a POST request with JSON that sets the “ps” to the new value (writing to …/json/state)
- Check the ps state – it’s returned in the POST call (I set the “v” parameter).
- If it hasn’t changed, it means I’m off the top of the list of presets, so POST again with value of 1
Then saved this shortcut in the same way. And holy cow, it works. Mac, phone, watch. Very cool.
Some caveats:
- I requires you to have your presets numbered in the order you want to cycle.
- It requires that you have an empty space at the end for the cycle to wrap around. I have a bunch more presets, but they are numbered in the 10s, 20s, 30s, etc.
This is pretty simple. I can imagine all kinds of cool stuff with Shortcuts. Like several different preset lists in different orders. Or even setting custom colors based on all kinds of things – just like the OP requested.
The Shortcuts app is a little convoluted if you’re a regular programmer like me (40+ years of programming), but it works and the whole “works all over the Apple ecosystem” aspect is very slick.
Hope this helps, ask any questions you have.
Chris