I have several WLED controllers that I want to sync to the same color and effect.
The way I am doing it now is send a JSON command to one instance, and that in turn sends a sync message to all others.
But to avoid some (unreliable) wifi hops, I would like to send the sync broadcast directly from python.
When I listen to the UDP packages, they do not conform to the protocol stated on the website as they are >1000 bytes long. But I can’t figure out how to decode the package either.
So my questions:
can I send the UDP sync packets directly from Python? (I am sure I can..)
can I send JSON directly over UDP (to get better control then the regular sync packets)
A couple of things that might save you some reverse-engineering:
The >1000-byte packets you’re capturing are almost certainly realtime pixel data, not the state sync. WLED has two different UDP families here: the Sync/Notifier (mirrors on/brightness/colour/effect between instances — a small binary packet) and the realtime protocols (WARLS/DRGB/DNRGB, per-LED colour — that’s what balloons past 1000 bytes with many LEDs). So decoding the big packets won’t give you the “same colour + effect” behaviour — those are pixels, not state.
For your actual goal (all controllers the same colour + effect), the simplest and most reliable path is to skip UDP entirely and POST the JSON state to each device over HTTP, straight from Python:
python
import requests
ips = ["192.168.1.50", "192.168.1.51", "192.168.1.52"]
state = {"on": True, "bri": 200, "seg": [{"col": [[255, 0, 0]], "fx": 8}]}
for ip in ips:
requests.post(f"http://{ip}/json/state", json=state, timeout=2)
```
That talks to each controller directly (no wifi hop through a "master"), it's TCP so it's reliable, and you get full control of colour + effect + anything else in the JSON API. It's basically what the sync feature does internally, minus the relay.
On your specific questions:
- *Send UDP sync from Python?* Yes, but it's the compact binary **Notifier** packet (byte 0 = protocol, then bri/colour/fx…), not the big packets you saw — and it's version-dependent, so more brittle than the HTTP route above.
- *JSON over UDP?* Not natively — JSON is the HTTP API. WLED's UDP only carries the Notifier + the realtime pixel protocols; it doesn't parse JSON off a UDP socket.
If you later want per-pixel control (not just state), that's when UDP realtime (DDP on 4048, or DNRGB on 21324) is the right tool — happy to go into that too if it helps.