Use hs-color for mqtt-light template

Hi there.

I am relatively new to homeassistant. I am currently moving my entire setup from FHEM to homeassistant and I am already quite satisfied. Only with the integration of my RGBWW-LED-controllers I have a problem. There is no „ready-to-sie“ integration because they are “diy controllers”. They can be controlled either via HTTP-REST or via mqtt. MQTT works so far, but unfortunately I need a custom JSON schema and can only set the color via hsv-model and the template schema doesn’t offer this option. Is there a specific reason for the limitation? Currently I use the sliders for white-value and color-temp to set hue and saturation, but a real colorpicker is much more comfortable.

Another option would be to convert rgbw to hsv, but for this I still lack too much scripting knowhow in ha

This is my current config:


  - platform: mqtt
    schema: template
    name: "RGBWW-Stripe"
    effect_list:
      - blink
      - pause
      - stop
      - continue
      - skip
    state_topic: "rgbww/rgb_stripe2/color"
    brightness_template: "{{ (value_json['hsv']['v'] / 100 * 255) | int }}"
    color_temp_template: "{{ (value_json['hsv']['s'] | int)  + 1 }}"
    white_value_template: "{{ (value_json['hsv']['h'] / 360 * 255) | int}}"
    command_topic: "rgbww/rgb_stripe2/cmd"
    command_on_template: >
      {"jsonrpc":"2.0","method":"color","params":{"hsv":{
      {%- if color_temp is defined -%}
      "s":{{ color_temp - 1 }},
      {%- else -%}
      "s":"+0",
      {%- endif -%}
      {%- if white_value is defined -%}
      "h": {{ white_value / 255 * 360 }}
      {%- else -%}
      "h":"+0"
      {%- endif -%}
      {%- if brightness is defined -%}
      ,"v":{{ (brightness / 255 * 100) | int }}
      {%- else -%}
      ,"v": 100
      {%- endif -%}
      },"d":"1","q":"single"
      {%- if transition is defined -%}
      ,"t":{{ transition * 1000 }}
      {%- else -%}
      ,"t":1000
      {%- endif -%}
      ,"cmd":"fade"}}
    command_off_template: >
      {"jsonrpc":"2.0","method":"color","params":{"hsv":{"h":"+0","s":"+0","v":0},"d":"1","q":"single"
      {%- if transition is defined -%}
      ,"t":{{ transition * 1000 }}
      {%- else -%}
      ,"t":1000
      {%- endif -%}
      ,"cmd":"fade"}}
    min_mireds: 1
    max_mireds: 101
    state_template: >
      {%- if value_json['hsv']['v'] == 0 -%}
      off
      {%- else -%}
      on
      {%- endif -%}

Hi!

I am trying the same thing.
Did you ever find a solution?
Best regards and thanks in advance,
Otto

Try this…