Turn off via UDP?

I know that usually the websockets or REST api are used to turn on/off the WLED. But can I use an UDP packet to turn off the WLED as well? Perhaps sending a brightness of 0?

You can send any API command using (properly formatted) UDP packet/message.

Really? How do I do this? Cause in the documentation I can’t find anything about turning if on/off. I can see brightness/color/effect etc. But not on/off

Look into udp.cpp in source. Then you are welcome to update the docs.

Ahh thank you! I found what you are talking about. I’ll try to figure out how to use it in my code:

  // API over UDP
  udpIn[packetSize] = '\0';

  if (udpIn[0] >= 'A' && udpIn[0] <= 'Z') { //HTTP API
    String apireq = "win&";
    apireq += (char*)udpIn;
    handleSet(nullptr, apireq);
  } else if (udpIn[0] == '{') { //JSON API
    DynamicJsonDocument jsonBuffer(2048);
    DeserializationError error = deserializeJson(jsonBuffer, udpIn);
    JsonObject root = jsonBuffer.as<JsonObject>();
    if (!error && !root.isNull()) deserializeState(root);
  }

Quick question here, if I use the UDP packet to send JSON does it have a performance hit compared to real-time color changes?

I use UDP now for changing the colors in real-time, but once the packets stop… the color returns to the original set color. If I use the JSON API this should change the color ‘more permanently’ right? Can I do this a the same speed that I do the real-time changes?

send: "live":true and WLED will remain in realtime mode

Still. What you are trying to achieve should be done in a different way IMO.

Please enlighten me. Cause I was using websockets. Then I switched to UDP WARLS which is made for real-time light changing right? What do you think I should be using?

I only use the JSON over UDP for turning on the WLED strip. And I’ll add “live”: true to that request

If you want to control individual LEDs use standard protocol like E131 or ArtNet or DDP.
Possibly using off-the shelf software (OSS or not).

If you want to learn then delve into the (WLED) code.

Alright, I’ll do that! Thanks