Pilight rest

I would like to control my pilight lights with the rest API instead of the pilight plugin.

The rest call to control pilight is:
https://x.x.x.x:xx/control?device=device_name&state=on
https://x.x.x.x:xx/control?device=device_name&state=off

I’m struggling with the components ‘template light’ https://home-assistant.io/components/light.template/ and RESTfull command https://home-assistant.io/components/rest_command/ for some couple of days but can’t make the correct configuration.

I would like to have a light switch in my frontend and if the state of this light is switched it should make the rest call with the correct state.

Can someone help me how to config this.

I would try

switch:
  platform: command_line
    switches:
      mylight:
        command_on: 'curl -k "https://x.x.x.x:xx/control?device=device_name&state=on"'
        command_off: 'curl -k "https://x.x.x.x:xx/control?device=device_name&state=off"'

Thanks, finally I solved it this way

rest_command:
  pilight:
    url: 'http://x.x.x.x:5001/control?device={{ device }}&state={{ state }}&values[dimlevel]={{ dimlevel }}'
    
light:
  - platform: template
    lights:
      staande_lamp:
        friendly_name: "Staande lamp"
        turn_on:
          service: rest_command.pilight
          data_template:
            device: staande_lamp
            state: "on"
        turn_off:
          service: rest_command.pilight
          data_template:
            device: staande_lamp
            state: "off"
        set_level:
          service: rest_command.pilight
          data_template:
            device: staande_lamp
            state: "on"
            dimlevel: "{{ states.light.staande_lamp.attributes.brightness | int / 17 }}"
      koplamp:
        friendly_name: "Koplamp"
        turn_on:
          service: rest_command.pilight
          data_template:
            device: koplamp
            state: "on"
        turn_off:
          service: rest_command.pilight
          data_template:
            device: koplamp
            state: "off"

If I use the group switch 2 rest calls are fired simultaneously and pilight does not switch the lights. I i switch them separately it works great. Is it possible to use some kind of delay so that pilight can handle it without problems?