HELP with Light template for RGBW strip

Hi all,

I’ve tried to setup a light template to best manage a light rgbw strip with a zigbee controller.

This is what I’ve done so far:

- platform: template

    lights:

      led_cucina_test:

        friendly_name: "LED Cucina"

        level_template: > 

            {% if is_state('light.striscia_led_cucina_rgb' , 'on') %}

              {{ state_attr('light.striscia_led_cucina_rgb', 'brightness')|int }}

            {% elif is_state('light.striscia_led_cucina_bianco' , 'on') %}

              {{ state_attr('light.striscia_led_cucina_bianco', 'brightness')|int }}

            {% else %}

              0

            {% endif %}

        value_template: >

            {% if is_state('light.striscia_led_cucina_rgb' , 'on') %}

              {{ states('light.striscia_led_cucina_rgb') }}

            {% elif is_state('light.striscia_led_cucina_bianco' , 'on') %}

              {{ states('light.striscia_led_cucina_bianco') }}

            {% else %}

              off

            {% endif %}

        white_value_template : "{{states('light.striscia_led_cucina_bianco') | int}}"

        color_template: "{{states('light.striscia_led_cucina_rgb') | int}}"

        turn_on:

          - service: light.turn_on

            data:

              entity_id: light.striscia_led_cucina_bianco

              brightness: 255

        turn_off:

            - service: light.turn_off

              entity_id: light.striscia_led_cucina_bianco

            - service: light.turn_off

              entity_id: light.striscia_led_cucina_rgb

        set_level:

          service: light.turn_on

          data_template: 

            entity_id: >

              {% if is_state('light.striscia_led_cucina_rgb' , 'on') %}

                light.striscia_led_cucina_rgb

              {% elif is_state('light.striscia_led_cucina_bianco' , 'on') %}

                light.striscia_led_cucina_bianco

              {% else %}

                0

              {% endif %}

            brightness: "{{ brightness }}"

        set_white_value:

          - service: light.turn_on

            data_template:

              entity_id: light.striscia_led_cucina_bianco

              white_value: "{{ white_value }}"

        set_color:

          - service: light.turn_on

            data_template:

              entity_id: light.striscia_led_cucina_rgb

              rgb_color: "{{ rgb_color }}"

When I try to simply turn it on I see an error message

“Fallita chiamata a servizio light/turn_on . ‘int’ object is not iterable”

Of course light.striscia_led_cucina_bianco involved in the turn on call is working as expected.

Any hint?

Lights can only be off, on, or unavailable.

Great!

After that I still can’t handle how to set color o brightness.

It seems that there are error too. I was wondering why I cannot find any good example on the net.

I’m confused about your situation here. Do you have two separate light entities that control one strip?

No I have a RGBW Strip controlled by a device that exposes 2 entities. One for white and the other for RGB

For example I cannot undestand why this doesn’t work:

    set_color:
      - service: light.turn_on
        data_template:
          entity_id: light.striscia_led_cucina_rgb
          hs_color: "{{ hs_color }}"

It’s well documented that the only things expsoed are h and s in color. Try hs_color: {{[h, s]}}.

No changes:

2021-01-02 20:41:51 ERROR (MainThread) [homeassistant.helpers.script.led_cucina] LED Cucina: Error executing script. Invalid data for call_service at pos 1: None for dictionary value @ data[‘hs_color’]

2021-01-02 20:41:51 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139724710657808] None for dictionary value @ data[‘hs_color’]

What about if you quote it?

Sorry forgot to mention.

In my yaml I already quoted it:

      - service: light.turn_on
        data_template:
          entity_id: light.striscia_led_cucina_rgb
          hs_color: "{{[h, s]}}"

And you still get the same error?

Yes same message

If you remove quotes, same error? Also as of recent releases just use data not data_template.

yes same result with or without quotes :frowning:

I’m still struggling with this. Maybe something is changed in how templates are managed.

Still need support :frowning:

Some other people have had a similar problem. Try searching around on the forums.

I noticed that seems that something is broken and I found also issues on github but seems that this integration is not loved.

ok, let’s change approach.

I tried also to create a template light only for 1 light changing brightness .

light:
  - platform: template
    lights:
      led_cucina:
        friendly_name: "LED Cucina"
        level_template: "{{ state_attr('light.dimmable_light_10', 'brightness')|int }}"
        value_template: "{{ states('light.dimmable_light_10') }}"
        white_value_template: "{{ state_attr('light.dimmable_light_10', 'brightness')|int }}"
        turn_on:
          service: light.turn_on
          entity_id: light.dimmable_light_10
        turn_off:
          service: light.turn_off
          entity_id: light.dimmable_light_10
        set_level:
          service: light.turn_on
          entity_id: light.dimmable_light_10
          data:
            brightness: "{{ brightness }}"
        set_white_value:
          service: light.turn_on
          entity_id: light.dimmable_light_10
          data:
            white_value: "{{ brightness }}"

in logs i see error for set white color. It asks me hue value but in docs I read for white_value

Integer between 0 and 255 for how bright a dedicated white LED should be.

Why I see this?

What is the exact error?

[140569912628128] /lights/10/state parameter, hue, not available