Hey everyone,
I wanted to share a project I’ve been working on over the past days, because it turned into a surprisingly deep dive into YAML, JSON, Jinja, REST commands, and WLED’s internal logic.
If anyone else is trying to control multiple WLED segments, each with its own physical relay, this might save you a lot of time.
Goal
I needed to control several WLED segments independently:
-
Each segment has its own relay (to cut power physically)
-
Each segment needs its own brightness, transition, and on/off state
-
Everything controlled cleanly from Home Assistant
-
No full‑strip on/off — only per‑segment control
To the real beginner in HA’s scripting system and WLED’s processing I was (I’ve learned too many things in this journey to say that I’m still a beginner), that sounded simple… At the beginning
WLED’s configuration
First things first, what am I doing here ?
I’m currently renovating a house, and I decided that one of the bathrooms would be my “Home Assistant playground” — the place where I test all the advanced features, scripts, REST commands, and all the weird stuff HA lets you do.
The idea was simple: use an ESP32 to drive multiple LED strips so I could independently control the mirror lighting and the ambient lighting of the bathroom (with two push-buttons. One to toggle the strips, the second to manage brightness and color).
Of course, that meant dealing with multiple WLED segments, relays, transitions, brightness control, and all the fun (and pain) that comes with mixing YAML, JSON, Jinja, and HTTP.
This project quickly escalated from “let’s add some LEDs” to “let’s reverse‑engineer half of HA and WLED to make this work properly”.
The Problems I Hit (and why they were painful)
-
YAML (I never heard of it before installing HA on my RPi) converts booleans automatically
-
Jinja (exactly the same, and to me, this is a real piece of …) converts again
-
HA (which has a nice UI let me do too many bad things) filters values
-
JSON (that I quickly discovered it was the easiest part of my projet) must remain valid
-
WLED expects strict types
It’s a perfect storm, and for a first test, I wasn’t expecting so many troubles
-
WLED refuses to process `on` and `bri` in the same request
This one is undocumented (or I didn’t find this detail) but 100% reproducible:
{“on”: false, “bri”: 0}
WLED processes on first and ignores bri. There were 2 options at this time. The first was to send 2 requests with a small delay to the ON/OFF of a segment and set its brightness. The second was to deal with only the ON/OFF state (more simple) of a segment…
So you can’t turn off a segment and set brightness in a single request.
I’ve seen that people discussed about having my setup, which is one relay per segment because my strips work in different times. I didn’t want to use the multi relay usermod, just because of two things. It doesn’t look to work as I want it to (as I’ve read), and I thought it would be simpler to do it with HA (remember that I said I was a beginner)
I built a REST command to set the brightness of a specific segment, so I decided to add the “on” parameter. That sounded easy, just because I played with API commands in my WLED preset, so that should have been a copy/paste/adapt stuff. But you can’t call a REST command with a parameter that’s called “on”, juste because HA decides that’s a familiar thing to him and he decides to say “You are telling me the “on” state of a thing. OK, I’m not going to do anything in your command”. HA sends the “on”, but with no value and WLED doesn’t understand what’s happening.
As a workaround, your parameter has to not be called “on” but any other word that isn’t familiar to HA is fine (power for example)
“on”: {{ power | string | lower }}
Why I’m Sharing This
Because none of the issues mentioned are obvious (HA/WLED/jinja/JSON)
If you’re trying to build per‑segment WLED control, especially with physical relays, you’ll probably hit some same walls.
What’s still left to do in this project
Even though the core logic is finally working, there are still a few things on my roadmap before I can call this bathroom experiment “done.” First, I still need to turn all this into a proper Home Assistant blueprint, so I can reuse the logic cleanly and expose everything through the UI. Then comes the final hardware installation: mounting the ESP32, wiring the relays, securing the LED strips, and making the whole setup bathroom‑proof. I’m also considering rewriting the whole logic in Python (AppDaemon or a custom integration) just to compare maintainability and performance against YAML/Jinja. And once everything is stable, I want to package the code and documentation so it’s easy to share with the community — clean examples, a reproducible setup, and maybe even a GitHub repo so others can build on top of it.
If anyone is interested in this (before I finish this project), I’ll be happy to share !