REST Command on the fly

Is it possible to create and run a REST command on the fly in an automation or script?
I can’t find anything looking through the docs or doing a search, but perhaps someone knows how?

Basically I want to use the WLED HTTP API to set the light colours, and have to do it this way as HA doesn’t support setting 3 colours.
Also I want the colours to be dynamic, rather than needing to make and maintain 60+ presets.

As far as I can see the templating only works on the payload, which the WLED API doesn’t support, its all got to be in the URL as it doesn’t use query strings correctly (i.e. its missing the ‘?’).

Thanks for any assistance available.

You can run many things with a shell command and you can pass parameters to it. In this case, you’d use curl.

Yup that looks like it should be possible as it will accept parameters on the go, so can build out the command in the script.

I have the same situation with a Shelly. Here as an example:

rest_command:
  shelly_brightness:
    url: "http://{{ ip }}/light/0?brightness={{ brightness }}"

Then you call it like this:

service: rest_command.shelly_brightness
data:
  ip: 192.168.178.74
  brightness: 50

That looked like it would work, tried this:

wled_boardgame:
  url: 'http://192.168.10.200/win&T=1&A=200&FX=60&SX=128&IX=128&R={{ R1 }}&G={{ G1 }}&B={{ B1 }}&R2={{ R2 }}&G2={{ G2 }}&B2={{ B2 }}&R3={{ R3 }}&G3={{ G3 }}&B3={{ B3 }}'
  method: post

service: rest_command.wled_boardgame
data:
  R1: 61
  G1: 98
  B1: 132
  R2: 118
  G2: 169
  B2: 197
  R3: 115
  G3: 60
  B3: 55

Voila! It works (HA needed a restart)!