Template Light for RGBW LED interfacing over Modbus

Hello all,
actually I‘m struggling since few days with controlling RGBW LEDs.
First of all I’d like to describe shortly my LED setup in my house:
All RGBW LEDs are controlled by a DMX Controller which is connected to a WAGO PLC.
The PLC interfaces by Modbus with a Raspberry PI on which HA is running.
So my relevant Modbus/Light configuration looks as follows:

# PLC Modbus 
modbus:
  - name: Wago
    type: tcp
    host: 10.0.0.100
    port: 502

switch:
  # ______Modbus Switches_________
  # ******************************
  platform: modbus
  scan_interval: 1
  coils:
    # * LED Relays *
    - name: mb_wz_led_relay
      hub: Wago
      slave: 1
      coil: 12405

sensor:
  - platform: modbus
    scan_interval: 1
    registers:
       # * LED RGBW Values *
     - name: mb_wz_led_r_value  
       hub: Wago
       slave: 1
       register: 13398
       register_type: holding
       data_type: uint     
     - name: mb_wz_led_g_value 
       hub: Wago
       slave: 1
       register: 13399
       register_type: holding
       data_type: uint     
     - name: mb_wz_led_b_value 
       hub: Wago
       slave: 1
       register: 13400
       register_type: holding
       data_type: uint     
     - name: mb_wz_led_w_value 
       hub: Wago
       slave: 1
       register: 13401
       register_type: holding
       data_type: uint       
light:
  - platform: template
    lights:
      ###_______WOHNZIMMER AMBIENTE______###
      light_wz_led:
        friendly_name: "Wohnzimmer Ambiente LED"
        level_template: "{{ states.sensor.mb_wz_led_w_value.state|int }}"
        value_template: "{{ is_state('switch.mb_wz_led_relay',  'on') }}"
        color_template: "({{ states.sensor.mb_wz_led_r_value.state|int }}, {{ states.sensor.mb_wz_led_g_value.state|int }}, {{ states.mb_wz_led_b_value.state.state|int }})" 
        turn_on:
          - service: switch.turn_on
            entity_id: switch.mb_wz_led_relay
        turn_off:
          - service: switch.turn_off
            entity_id: switch.mb_wz_led_relay
        set_level:
          - service: modbus.write_register
            data_template:
              hub: Wago
              unit: 1
              address: 13401
              value: "{{ brightness }}"
        set_color:
          - service: modbus.write_register
            data_template:
              hub: Wago
              unit: 1
              address: 13398 
              value: "{{ h }}"  #here I need the red value instead of the h

          - service: modbus.write_register
            data_template:
              hub: Wago
              unit: 1
              address: 13399 
              value: "{{ s }}" #here I need the green value instead of the s
          - service: modbus.write_register
            data_template:
              hub: Wago
              unit: 1
              address: 13400 
              value: "{{ s }}"  #here I need the blue value instead of the s

So far I’m able to switch on/off the LEDs but not able to control the them with the right color. The main problem is that the template light provides the colors in HSB (hue, saturation, brightness) and I need them as RGB to write the values in the Modbus register.

I have to say that I’m quite new to HA and yaml (started just few days ago) and have no clue how I can solve this issue.

I found a the script to convert HSB to RGB (Using HSV / HSB to set colored lights) but no idea how I can include this in my configuration.yaml file.

It would be great when someone can tell me if I’m total wrong with the light template for this case or how I must adjust it to work.

Many thanks in advance for your help!