Little more detail required on segments and individual LED control using JSON

Sorry - I wanted to do some more experimentation to rule out obvious problems before posting here - so had a weird double post, apologies!

Hi I am trying to create a controller program that could do with some control over individual LEDs within segments using JSON. I am using C# to create a program to do some advanced control of WLED to support a fully interactive games table. [I will post details in Projects & source once I get closer to completion!]. Also note, I am relatively new to this type of programming so my questions may be a little naïve.

I would like to use the JSON API for individual LED control to manage player info bars so I don’t need to create my own branch; easier for maintainability and easy adoption by others.

Normally to use JSON I construct a data class and use C# functionality to serialise/deserialise between the two. However I am finding it hard to work out the data class for individual LED control so just manage that manually; it works but I am having difficulty targeting a segment id as the documentation here is a little lacking in that area. It could do with an extended sample JSON example.

These work fine:


It just targets the first segment - i.e. 0. However when I try to target other segments I cannot work out how to insert the id into the JSON request. These targeting segment 1 seem to either create exceptions:


Or provides a good OK response but does nothing at all:


So obviously I am not “getting” how segments can be targeted properly. Hopefully a quick example can help me. Thanks!

If one of those ARE meant to work (e.g.: the last one, which does seem almost sensible) then perhaps I am missing something else; eg: a pre-requisite to establish the segment under normal use first. Or I cannot target an individual segment, I always have to provide a list of all segment data sequentially. Any help would be useful. Thanks in advance!

If you want to set both segment, do this:

{"seg": [{"i":[10,20,[255,0,0],50,60,[0,128,0],110,120,[0,0,255]]},

If you only want to set the second segment, do this:

{"seg": [{}, {"i":[10,20,[255,0,0],50,60,[0,128,0],110,120,[0,0,255]]}]}

Many thanks, Artacus. That should sort me out nicely. I thought you could directly address a segment with an id… that was where I went wrong. Should be easy enough to work around!

Thanks again!