Rest command POST not working

Hello
I created a led matrix board that I want to use from HA, I want to use a rest command however I seem to be unsuccesful in calling it from HA
When I try to approach the Wled through its IP and by using Fiddler it is succesful, so I might be missing something obvious in HA

I have added to configuration.yaml

rest_command: !include rests.yaml

And then in the rests.yaml the following code:

wled_text:
    url: http://192.168.2.18/json/state
    method: POST
    payload: '{ "on": true, "bri": "{{brightness}}", "seg":{"id":0, "col":{{color}} , "fx":122, "n":"{{text}}" }}'

When I try to execute a Yaml in developer tools

action: rest_command.wled_text
data: 
  text: "test me"

It returns

content:
  error: 9
status: 400

In Fiddler the payload looks like the following
{ “on”: true, “bri”: “{128}”, “seg”:{“id”:0, “col”:[[0,255,200]], “fx”:122, “n”:“I Love Home Assistant” }}

Now I cannot see what HA is sending out or how it forms the actual POST before it sends it to the target host, this might be able to tell me where the issue is. Anyone know if this is possible from HA or do I need to start a sniffer on my HA Raspberry Pi to capture it?

Any ideas which formatting I might be overlooking or what I can investigate further?

Aren’t you supposed to send the brightness and color also?

1 Like

@Hellis81 makes a good point.

Also set the correct content type, just in case:

content_type: 'application/json'

I had tried it with brightness before and I thought I had run that without the color as one of my tests to remove it from the rest command since it is not a mandatory variable, however I must have not restarted properly.
I got it working after fiddling with that code.
Thanks for the extra pair of eyes

content_type was not mandatory either for it to work, however would be more neat to specify it

Hey! :wave:
If you’re running into trouble formatting rest_command payloads for WLED — you’re definitely not alone. JSON escaping, quoting, and templating in configuration.yaml can be super tricky and frustrating to debug.

If you’re open to another approach, I created a custom integration that avoids all of this entirely. It’s called WLED Live View Proxy and it lets you send raw JSON commands directly to your WLED device over WebSocket — no escaping, no quoting issues, no YAML tricks.

Here’s the same command you tried, but as a service call:

action: wled_liveviewproxy.send_command
data:
  targets:
    entity_id: light.wled_matrix
  command: {"on":true,"bri":128,"seg":{"id":0,"col":[[0,255,200]],"fx":122,"n":"I Love Home Assistant"}}

No need for configuration.yaml or REST setup — just a clean, direct API call. You can use it in scripts and automations too.

More info and examples here:
:link: WLED Live View Proxy for Home Assistant

Hope it helps!