I've fix the deprecation of RGBW light in `template.light`

TLDR: This HACS repo add RGB, RGBW and RGBWW functionality to the light.template components: https://github.com/Vaarlion/HACS_home-assistant_template.light

Hi all !
I don’t know if Configuration is the right spot, i hesitated between it and Developments, but I’m here to share a HACS repo with a fix for the template.light component.

I don’t know if you noticed, but [a couple month ago](https://github.com/home-assistant/core/pull/76923)(sorry, 2 link limit for new user), the white_value attribute was fully removed from template.light service
The issue was that unlike MQTT light, they where no other way to control the white value of a RGBW light, the set_color and color_template attribute would only work for HS value :frowning:

I’m not a dev, but i used template light with RGBW light so i started to look into it. After month of reading about async, test, and how HA is written, I’ve made something I’m very proud off.

This Pull request add set_hs, set_rgb, set_rgbw and set_rgbww script to managed all type off light, and template_hs, template_rgb, template_rgbw and template_rgbww template to get the data for those light :slight_smile:
No breaking change, but it would be “best” IMO to change your template from set_color to set_hs and template_color to template_hs for readability :wink:
I’ve also push the test coverage to 100% ! Really proud of that.

Sadly, since January i haven’t got any input on it. Release goes by, rebase are sometime hard to do, and the fix i need for my home instance are just copy pasted… not clean. I understand that the core dev have a lot on their plate, sadly the more it wait the more work it is to keep it mergable.

So i decided to bite the bullet and try to make a HACS repo for it ! Now anyone can easily run the fixed version to, and as soon as a release go by i rebase it and the update show up in HACS !

Just add this https://github.com/Vaarlion/HACS_home-assistant_template.light custom repository and install the “Vaarlion template bugfix” component.

I hope this is a short fix, even the doc isn’t correct since the deprecation, but at least i would have done everything i could :smiley:

Here is an example that merge 2 segments and the master control of wled with RGBW led into a single light

  - platform: template
        unique_id: 28208f257b54c44e50deb2d618d44710
        friendly_name: "Multi-segment Wled control"
        value_template: "{{ states('light.wled_master') }}"
        level_template: "{{ state_attr('light.wled_master', 'brightness')|d(0,true)|int }}"
        rgbw_template: (
          {{ (state_attr('light.wled_segment_0', 'rgbw_color')[0]|d(0) + state_attr('light.wled_segment_1', 'rgbw_color')[0]|d(0))/2 }},
          {{ (state_attr('light.wled_segment_0', 'rgbw_color')[1]|d(0) + state_attr('light.wled_segment_1', 'rgbw_color')[1]|d(0))/2 }},
          {{ (state_attr('light.wled_segment_0', 'rgbw_color')[2]|d(0) + state_attr('light.wled_segment_1', 'rgbw_color')[2]|d(0))/2 }},
          {{ (state_attr('light.wled_segment_0', 'rgbw_color')[3]|d(0) + state_attr('light.wled_segment_1', 'rgbw_color')[3]|d(0))/2 }}
        effect_list_template: "{{ state_attr('light.wled_segment_0', 'effect_list') }}"
        effect_template: "{{ state_attr('light.wled_segment_0', 'effect') if state_attr('light.wled_segment_0', 'effect') == state_attr('light.wled_segment_1', 'effect') else none }}"
        availability_template: "{{ not is_state('light.wled_master', 'unknown') }}"
          service: light.turn_on
          entity_id: light.wled_segment_0, light.wled_segment_1, light.wled_master
          service: light.turn_off
          entity_id: light.wled_master
          service: light.turn_on
          entity_id: light.wled_master
            brightness: "{{ brightness }}"
          service: light.turn_on
          entity_id: light.wled_segment_0, light.wled_segment_1
              - "{{ r }}"
              - "{{ g }}"
              - "{{ b }}"
              - "{{ w }}"
            effect: "Solid"
          service: light.turn_on
          entity_id: light.wled_segment_0, light.wled_segment_1
            effect: "{{ effect }}"

Please tell me if you used it ! it would make me so happy :smiley:


Moved to Custom integrations

Rebase for 2023.5.2v1 have been uploaded !

Have you been in touch with someone like Frank or Balloob? I really don’t understand why there’s still not even a reply since Jan.

I’ve been running into the same issue ever since they dropped the white_value on multiple instances and had to fiddle around with custom automations and number_values, but I’d like to unify it as it was possible before.

Thanks for your work so far, the code looks good to me!