Help creating a light template to combine a CW and WW led strip into single light entity

Help creating a light template to combine a CW and WW led strip into single light entity.

I have an LED mirror that I have wired in a Shelly Plus RGBW to control the warm white and cool white strip through output 1 & 2, but I cant seem to find online or even vibe code a template to combine the entities and have a CCT slider so that I can just export the single entity into Apple Home, alternatively if the slider is a problem i am happy with a dropdown for the different mode presets like 2700 4500 6500

Have you considered doing it on-device instead of combining the entities in HA? I've never done it with a Shelly Plus RGBW, but I pretty sure you could flash it with ESPHome and use the CWWW platform to handle mixing the two outputs.

That's because it's a PITA... here's a rough (and untested) sketch:

CWWW via Template
template:
  - light:
      - name: CWWW via Template
        variables:
          cold_light: light.cold_example
          cold_light_color_temperature: 2500
          warm_light: light.warm_example
          warm_light_color_temperature: 6500
        state: "{{ is_state(cold_light, 'on') or is_state(warm_light, 'on') }}"
        turn_on:
          action: light.turn_on 
          target:
            entity_id: "{{[cold_light, warm_light]}}" 
        turn_off:
          action: light.turn_off
          target:
            entity_id: "{{[cold_light, warm_light]}}"
        set_level:
          action: light.turn_on 
          target:
            entity_id: "{{[cold_light, warm_light]}}"
          data:
            brightness: "{{ brightness }}"
        set_temperature:
        - action: light.turn_on 
          target:
            entity_id: "{{warm_light]}}"
          data:
            brightness_pct: |
              {{(remap(color_temp_kelvin,warm_light_color_temperature,cold_light_color_temperature,100, 0))|int}}
        - action: light.turn_on 
          target:
            entity_id: "{{cold_light}}"
          data:
            brightness_pct: |
              {% set warm_brightness = (remap(color_temp_kelvin, warm_light_color_temperature,cold_light_color_temperature,100, 0))|int %}
              {{ 100 - warm_brightness }}

Prior to the (relatively recent) addition of the remap function, it would have been a lot more annoying to do that kind of regression in Jinja.

I think it could be improved by switching to a trigger-based approach... if you try it, post your results.

this was an insanely huge help...it go me and old mate claude on the right pathway...and here we have the finished result after 8 different iterations

if you see a better way to do this please share but:

Pre-requisite...set up a helper to track the colour temp state (without it the brightness slider ignored the colour temp and just brought both channels up and down together) with a min value of 153 and max of 500

then created this template:
a bit of info for anyone else trying my Shelly Plus RGBWW was set to Light mode so 4 individual channels and Channel 0 is my Cool White (CW) channel and Channel 1 is my Warm White (WW) channel

## LED Mirrors CCT Templates for Shelly Plus RGBWW ###

#Laundry Mirror
- light:
    - name: Laundry Mirror
      unique_id: laundry_mirror_cct
      state: "{{ is_state('light.srgbw_laundrymirror_light_cw', 'on') or is_state('light.srgbw_laundrymirror_light_ww', 'on') }}"
      turn_on:
        action: light.turn_on
        target:
          entity_id:
            - light.srgbw_laundrymirror_light_cw
            - light.srgbw_laundrymirror_light_ww
      turn_off:
        action: light.turn_off
        target:
          entity_id:
            - light.srgbw_laundrymirror_light_cw
            - light.srgbw_laundrymirror_light_ww
      set_level:
        - action: light.turn_on
          target:
            entity_id: light.srgbw_laundrymirror_light_ww
          data:
            brightness_pct: "{{ [[1, ((remap(states('input_number.laundry_mirror_cct_state') | float(270), 153, 370, 0, 100) | int) * (brightness / 255)) | int] | max, 100] | min }}"
        - action: light.turn_on
          target:
            entity_id: light.srgbw_laundrymirror_light_cw
          data:
            brightness_pct: "{{ [[1, ((remap(states('input_number.laundry_mirror_cct_state') | float(270), 153, 370, 100, 0) | int) * (brightness / 255)) | int] | max, 100] | min }}"
      set_temperature:
        - action: input_number.set_value
          target:
            entity_id: input_number.laundry_mirror_cct_state
          data:
            value: "{{ color_temp }}"
        - action: light.turn_on
          target:
            entity_id: light.srgbw_laundrymirror_light_ww
          data:
            brightness_pct: "{{ [[1, (remap(color_temp, 153, 370, 0, 100)) | int] | max, 100] | min }}"
        - action: light.turn_on
          target:
            entity_id: light.srgbw_laundrymirror_light_cw
          data:
            brightness_pct: "{{ [[1, (remap(color_temp, 153, 370, 100, 0)) | int] | max, 100] | min }}"