How to "erase" segments?

Hi at all,

in the evening, I’m using three LED-rings as candles for ambient lightning. I grouped them to have independent flicker on every ring and stored this to preset 16 (because of handling segments).
I call the candle effect with:

http://ip_of_wled/win&CL=hFFA000&A=&FX=88&PL=16

In the morning, I would like to use the sunset effect, but I’m stuck in the segment preset…and therefore the candle effect.

I tried with:

http://ip_of_wled/win&CL=hff0000&C2=hffe0a0&A=3&NL=15&NT=180&NF=2&SM=0&S=0&S2=36&FX=0&S=1&FX=0&S=2&FX=0
to set as one big segments (3 rings with 12 leds) and set the effect on SOLID on all segments, but this doesn’t seems to work right… Any ideas?

I shut off the candle effect in the evening by : http://ip_of_wled/win&T=0 , maybe there’s the mistake…

Kind regards,

Clubsport

Someone very recently posted how to delete segments.
Use the JSON API (not the HTTP API), and set segment stop lower than segment start. Poof, segment gone.

To be honest, I don’t know how to use the JSON-API , nor to implement it in Loxone… Never had to do with it… :frowning:

To be honest, neither do I, until I try it. I bet if you made an honest effort of it, looking for tools like CURL that can send JSON data, and requesting JSON data and then using a browser extension or VS Code or Notepad++ where it can pretty up the JSON, you will see the value of it very quickly.

Oddly enough, I’m dealing with a JSON api on a work related project using Azure DevOps. I create the URL to request data. When it comes back, I paste it into Notepad++, hit the JSON Viewer Plug-in and select Format JSON. Like Magic all those grouped / nested key:value pairs start to show structure visually, and it starts to make sense how useful it can be.

The neat thing about WLED’s JSON API is you can:

  1. Request the entire WLED settings as a JSON blob
  2. Edit the results in Notepad++ (or VS Code…) with the values you want, like ON->OFF, or a different time value, or different effect name (which unfortunately might take a couple attempts to get spelled exactly right if you don’t change the effect and capture the JSON blob again!)
  3. Using something like CURL or a browser extension / plug-in and SEND the JSON data to WLED
  4. WLED will make the requested changes.

It works with segments too!

It’s worth a bit of frustration for the results you can get quickly and easily. You can save these JSON blobs as distinct WLED settings files.

Once they are in file format, CURL (a command line tool) can send them to any/every WLED instance.

One minor word of warning which probably goes without saying to most people, yourself included.

When saving entire backup style JSON blobs that you may send out to other WLED instances around your home or car or where ever, REMOVE the unique things like hostname & IP address (and others perhaps).

This might not be required, but it’s a very good idea to make sure you don’t end up with all your WLED’s named the same and causing IP address conflicts on your wireless network.

If anyone ever skipped that step and caused this problem, I’d appreciate you giving a like to this post so we can see if this is a big problem!

Okay, after a little bit of frustration, I finally get the first steps done…
There is only one little problem left.
I used the following way to get my json-String: I adjusted everything like i wanted in the Web-Interface, and then used IP/json/state to extract the json-String.

I have one candle effect with three segments, the output is:

{“on”:true,“bri”:100,“transition”:7,“ps”:16,“pss”:49152,“pl”:-1,“ccnf”:{“min”:1,“max”:5,“time”:12},“nl”:{“on”:false,“dur”:15,“fade”:true,“mode”:2,“tbri”:180},“udpn”:{“send”:false,“recv”:true},“lor”:0,“mainseg”:1,“seg”:[{“id”:1,“start”:0,“stop”:12,“len”:12,“grp”:1,“spc”:0,“on”:true,“bri”:255,“col”:[[255,160,0],[0,0,0],[0,0,0]],“fx”:88,“sx”:109,“ix”:110,“pal”:0,“sel”:true,“rev”:false,“mi”:false},{“id”:2,“start”:12,“stop”:24,“len”:12,“grp”:1,“spc”:0,“on”:true,“bri”:91,“col”:[[255,160,0],[0,0,0],[0,0,0]],“fx”:88,“sx”:109,“ix”:111,“pal”:0,“sel”:false,“rev”:false,“mi”:false},{“id”:3,“start”:24,“stop”:36,“len”:12,“grp”:1,“spc”:0,“on”:true,“bri”:255,“col”:[[255,160,0],[0,0,0],[0,0,0]],“fx”:88,“sx”:114,“ix”:119,“pal”:0,“sel”:false,“rev”:false,“mi”:false}]}

And the second one is the Breeze Palette, the output is:

{“on”:true,“bri”:100,“transition”:7,“ps”:-1,“pss”:49152,“pl”:-1,“ccnf”:{“min”:1,“max”:5,“time”:12},“nl”:{“on”:false,“dur”:15,“fade”:true,“mode”:2,“tbri”:180},“udpn”:{“send”:false,“recv”:true},“lor”:0,“mainseg”:1,“seg”:[{“id”:1,“start”:0,“stop”:36,“len”:36,“grp”:1,“spc”:0,“on”:true,“bri”:255,“col”:[[255,224,160],[0,0,0],[0,0,0]],“fx”:65,“sx”:0,“ix”:113,“pal”:15,“sel”:true,“rev”:false,“mi”:false}]}

As you can see, there is only one segment, 36 LEDs long.
But when I switch from “Candle mode” to the “Breeze mode”, only one of three rings is updated, and the output becomes the following:

{“on”:true,“bri”:100,“transition”:7,“ps”:-1,“pss”:49152,“pl”:-1,“ccnf”:{“min”:1,“max”:5,“time”:12},“nl”:{“on”:false,“dur”:15,“fade”:true,“mode”:2,“tbri”:180},“udpn”:{“send”:false,“recv”:true},“lor”:0,“mainseg”:1,“seg”:[{“id”:1,“start”:0,“stop”:36,“len”:36,“grp”:1,“spc”:0,“on”:true,“bri”:255,“col”:[[255,224,160],[0,0,0],[0,0,0]],“fx”:65,“sx”:0,“ix”:113,“pal”:15,“sel”:true,“rev”:false,“mi”:false},{“id”:2,“start”:12,“stop”:24,“len”:12,“grp”:1,“spc”:0,“on”:true,“bri”:91,“col”:[[255,160,0],[0,0,0],[0,0,0]],“fx”:88,“sx”:109,“ix”:111,“pal”:0,“sel”:false,“rev”:false,“mi”:false},{“id”:3,“start”:24,“stop”:36,“len”:12,“grp”:1,“spc”:0,“on”:true,“bri”:255,“col”:[[255,160,0],[0,0,0],[0,0,0]],“fx”:88,“sx”:114,“ix”:119,“pal”:0,“sel”:false,“rev”:false,“mi”:false}]}

So there are segments “overlapping”, and I didnt get the reason… :frowning:

Kind regards,

Clubsport

If you create a segment, you have to get rid of it or use it. Someone very recently posted about how to delete a segment. Set the stop lower than the start. Set all the starts to 1 and stops to 0 gets rid of all segments except segment 1. After that, you can generate another segment setup. Otherwise, I think it just confuses WLED if segments are not the same across API calls.

That totally did the trick for me, THANK YOU !!! :star_struck:
I’d add that on the json wiki page, because it’s completely missing that you have to do this step between.

Kind regards,

Clubsport

I finally got it working… My home automation mixed up the outputs. :face_with_hand_over_mouth:

Last question (hopefully :crazy_face: ) :

When I was in “Breeze” and want to switch to “Candle”, I have to switch it off between both commands by /win&T=0 . Otherwise, “Candle” will only flash shortly and directly go back to “Breeze”.
The other way, from “Candle” to “Breeze”, i got really strong flashing and strobe light from all LEDs. :rofl:

Attached are my commands for :

Candle:

{“on”:true,“bri”:,“transition”:7,“ps”:-1,“pss”:49152,“pl”:-1,“ccnf”:{“min”:1,“max”:5,“time”:12},“nl”:{“on”:false,“dur”:15,“fade”:true,“mode”:2,“tbri”:120},“udpn”:{“send”:false,“recv”:true},“lor”:0,“mainseg”:1,“seg”:[{“id”:1,“start”:0,“stop”:12,“len”:12,“grp”:1,“spc”:0,“on”:true,“bri”:255,“col”:[[255,160,0],[0,0,0],[0,0,0]],“fx”:88,“sx”:109,“ix”:110,“pal”:0,“sel”:true,“rev”:false,“mi”:false},{“id”:2,“start”:12,“stop”:24,“len”:12,“grp”:1,“spc”:0,“on”:true,“bri”:255,“col”:[[255,160,0],[0,0,0],[0,0,0]],“fx”:88,“sx”:109,“ix”:111,“pal”:0,“sel”:false,“rev”:false,“mi”:false},{“id”:3,“start”:24,“stop”:36,“len”:12,“grp”:1,“spc”:0,“on”:true,“bri”:255,“col”:[[255,160,0],[0,0,0],[0,0,0]],“fx”:88,“sx”:114,“ix”:119,“pal”:0,“sel”:false,“rev”:false,“mi”:false}]}

Breeze:

{“on”:true,“bri”:,“transition”:7,“ps”:-1,“pss”:49152,“pl”:-1,“ccnf”:{“min”:1,“max”:5,“time”:12},“nl”:{“on”:false,“dur”:15,“fade”:true,“mode”:2,“tbri”:120},“udpn”:{“send”:false,“recv”:true},“lor”:0,“mainseg”:1,“seg”:[{“id”:2,“start”:1,“stop”:0},{“id”:3,“start”:1,“stop”:0},{“id”:1,“start”:0,“stop”:36,“len”:36,“grp”:1,“spc”:0,“on”:true,“bri”:255,“col”:[[255,160,0],[0,0,0],[0,0,0]],“fx”:65,“sx”:10,“ix”:110,“pal”:15,“sel”:true,“rev”:false,“mi”:false}]}

Kind regards,

Clubsport

May I ask someone to test both commands if you ran into the same issue please?

Regards,

Clubsport

:roll_eyes: :pensive:

I’m unsure if you fixed it, but what I’m doing with my setup is sending a “clear segment” payload before sending my real command. it’s basically a json with all 16 segment of length 0 except the first one which have my 300 led, this erase all other segments. Then, on my next payload, I set the segment as I need it

{
"on":true,
"transition":5,
"ps":-1,
"pss":0,
"pl":-1,
"mainseg":0,
"seg":
[
    {
        "id":0,
        "start":0,
        "stop":300,
    },
    {
        "id":1,
        "start":0,
        "stop":0,
    },
    {
        "id":2,
        "start":0,
        "stop":0,
    },
    {
        "id":3,
        "start":0,
        "stop":0,
    },
    {
        "id":4,
        "start":0,
        "stop":0,
    },
    {
        "id":5,
        "start":0,
        "stop":0,
    },
    {
        "id":6,
        "start":0,
        "stop":0,
    },
    {
        "id":7,
        "start":0,
        "stop":0,
    },
    {
        "id":8,
        "start":0,
        "stop":0,
    },
    {
        "id":9,
        "start":0,
        "stop":0,
    },
    {
        "id":10,
        "start":0,
        "stop":0,
    },
    {
        "id":11,
        "start":0,
        "stop":0,
    },
    {
        "id":12,
        "start":0,
        "stop":0,
    },
    {
        "id":13,
        "start":0,
        "stop":0,
    },
    {
        "id":14,
        "start":0,
        "stop":0,
    },
    {
        "id":15,
        "start":0,
        "stop":0,
    }
]
}

I will give that also a try, even if it’s totally unclear to me why i have to deal with segments I’ve never touched with a line of code before… :roll_eyes:

EDIT:

Didn’t help either.

What I also recognized, when I’m in “Breeze”, and try to switch to “Candle”, the Candle effect only shows up for a split second and goes back to “Breeze”.
But when I then switch everything off with http-command “/win&T=0” , the LEDs will dimm down for the duration of the “transition time” with the “Candle” effect!!!

Can’t believe thats because I made a mistake in the json string…

The reason for segment is because you want to mirror the effect on 3 “strip”. If you do just 1 segment, it will have start 0 and end the last led of the last candle. From what I see, each candle have 12 leg, thos you would have 1 segment from 0 to 36.

Doing so, the effect would then go from led 0 to 36. I’m unsure of the candle effect, but I guess it doesn’t do what you want.

Thus, seperating each candle in segments, like you did, allow to send 3 time the same animation to each segment, or each candle.

Now, the problem is, if you check in WLED interface, when you switch from Candle to Breeze, the other 2 segments are still there, but unchecked. Problem is, in WLED, even if you uncheck the segment, overlapping LED won’T work.

Thus, what happen is.
Send candle animation
Segment 1: 0-12
Segment 2: 12-24
Segment 3: 24-36
all enabled with animations

Send Breeze
Segment 1: 0-36 - breeze animation
Segment 2: 12-24 - candle animation disabled
Segment 3: 24-36 - candle animation disabled

Because of the 2 disabled segment, it “win” over the overlapping and doesn’t show anything. Thus, you need to clear the segment.

The code I gave you reset many things also, like brightness and all to a default value I set. You can tweak to whatever you need. just keep the segment start and stop for each segment, but put “36” as a stop on the 1rst segment

I am deleting the segments, like huggy-d1 told me to do in a previous post:

If you create a segment, you have to get rid of it or use it. Someone very recently posted about how to delete a segment. Set the stop lower than the start. Set all the starts to 1 and stops to 0 gets rid of all segments except segment 1. After that, you can generate another segment setup. Otherwise, I think it just confuses WLED if segments are not the same across API calls.

As you can see in my code, I am deleting the unused segments.

Sorry to say that, the work @Aircoookie put in WLED is really awesome, but using the json-API is just pain in the a** … :roll_eyes:

I’m sorry that you think the JSON API is inconvenient to use… It clearly states in the docs that

If stop is set to a lower or equal value than start (setting to 0 is recommended), the segment is invalidated and deleted.

You won’t have to “touch” segments you didn’t create. So if you only ever have one segment sending {"stop":0} on the others is not required. However, if you have an automation that first sets multiple segments (like your Candle setup) and then want to set a single segment only, you need to explicitely delete segments 1 and 2, because WLED has no way of knowing if you only want to modify the first preset with your payload (and keep the others).

Maybe I can add a command that does the deletion implicitly if the payload sets less segments than there are currently. The WLED UI is really probably the only client using the API to modify segments without touching the other ones. Presets or external automations typically update the entire segment config - and I agree that always having to add {"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0} to every API call to ensure unwanted stray segments are deleted isn’t the most convenient or intuitive style.

Maybe you jabe a udp problem. Disable the receive broadcast feature, I had similar problem.

@aircookie

I think it’s also misunderstanding. I had a hard time with segment at first too. I though I could create overlapping segment that could overwrite other. My idea at first was to create different segment that I could use with different preset. Thus, I wasn’t deleting segment and ended with a 1 led animation. I have a 5m string that I split in 3 for an animation that revert to 1 animation for the whole strip thus I had 4 segment at first. Once I understood, I switch my code and now, for precaution, I clear all 16 segment. But yes, having a json value like clearseg:true in the payload would be awesome, I was looking for it since there’s a clear segment in the uit.

Hey guys,

first of all - thank you all for your responses! :nerd_face:

@nodiaque: Due to the fact I’m planning an integration in Loxone, I think i have to stay with udp-connectivity. But for tests, I will give it a try today evening. :+1:

@Aircoookie:
Yes, I think a “delete all segments” command would be very very helpful!!! :kissing_heart:
Maybe I’m the only one, but I try to centralize and automate as much as possible in my home - so the WLED web UI is perfect for me to set everything up like it looks nice, but everything else (when I found my settings I like) I use Loxone.

To your comment:
I don’t see where the requirements of the commands I’m using are mismatching with what I have to do.
I posted both code examples above.
All I would kindly ask is someone to “test” the behaviour - if you get the same results, there is something wrong with my json-string (also, if I can’t see what exactly…!!!) , if you don’t get the same results, then I have to search for the misbehaviour in Loxone.

But at the moment, I clearly can’t see the reason why it’s not working with a directly switch between the modes, but switching Master Brightness to 0 between is doing the trick. :face_with_raised_eyebrow:

Kind regards,

Clubbi

PS: @Aircoookie : When I see correctly you are also native German? Maybe a phone call can clear things up faster :wink: :v:

PS2: If the new version 0.11.x is able to store presets in more than just one slot, that is also totally fine for me and hopefully will work :star_struck:
Then I will set everything up on the WLED UI, and call just the presets from Loxone (much more less complicated all in all!) :+1:

250 Presets available in 0.11.x :smiley:
With the transition time is configured for anything other than 0, it may seem unpredictable what the LEDs will do when transitioning between JSON API calls.

Try the transition at 0. Is there a reason why “BRI:” is sent? Send a brightness value of “keep current brightness”? Can you omit it completely and still have a valid JSON request?

1 Like

As far as I know, there’s no mandatory data in the json request, some depencies depending on what you want. Like I sent only Enable:false to turn them off. I myself set the brightness because I want a default settings for some animation and can’t really on someone played with the brightness before, or another segment was configured before so since I’m setting a new segment, I need to put the brightness in it. But, you can remove it from segment and main query if you don’t need

I don’t know about luxone, I won’t be able to help on that. I myself have only 1 WLED and for unknown reason, the UDP receive function was triggering and crippling my effects. Since I turn it off, it work. There’s also a json param you can put per segment which say this segment can’t be changed from udp, that’s how I found out it was udp before turning it out. I’ll have to investigate my own network to find what’s doing that though