Setting color on a light template does not work

Hi,

I’m trying to use a light template to combine a shelly smart (switch.light_livingroom) switch and some ikea trädfri bulbs in the corresponding lamp within a light group (light.bulbs_spotlight_livingroom) to one light.

This is my code so far:

  - platform: template
    lights:
      livingroom_spots:
        friendly_name: "Wohnzimmer Deckenstrahler (unified)"
        level_template: "{{ state_attr('light.bulbs_spotlight_livingroom', 'brightness')|int }}"
        value_template: "{{ is_state('switch.light_livingroom', 'on') and is_state('light.bulbs_spotlight_livingroom', 'on')}}"
        #temperature_template: "{{states('input_number.temperature_input') | int}}"
        #color_template: "({{states('input_number.h_input') | int}}, {{states('input_number.s_input') | int}})"
        color_template: "{{ state_attr('light.bulbs_spotlight_livingroom', 'hs_color') | float}}"
        #effect_list_template: "{{ state_attr('light.bulbs_spotlight_livingroom', 'effect_list') }}"
        turn_on:
          - service: homeassistant.turn_on
            target:
              entity_id: switch.light_livingroom
          - service: light.turn_on
            target:
              entity_id: light.bulbs_spotlight_livingroom
        turn_off:
          service: light.turn_off
          target:
            entity_id: light.bulbs_spotlight_livingroom
        set_level:
          - service: homeassistant.turn_on
            target:
              entity_id: switch.light_livingroom        
          - service: light.turn_on
            target:
              entity_id: light.bulbs_spotlight_livingroom
            data_template:
              brightness: "{{ brightness }}"
        set_temperature:
          service: light.turn_on
          target:
            entity_id: light.bulbs_spotlight_livingroom
          data_template:
            color_temp: "{{ color_temp }}"
          data:
            value: "{{ color_temp }}"
            entity_id: input_number.temperature_input
        set_color:
          - service: light.turn_on
            data_template:
              hs_color:
                - "{{ h }}"
                - "{{ s }}"
              entity_id: light.bulbs_spotlight_livingroom
#        set_effect:
#          - service: light.turn_on
#            data_template:
#              entity_id:
#              - light.livingroom_bulb1
#              - light.livingroom_bulb2
#              - light.livingroom_bulb3
#              effect: "{{ effect }}"

I have also a light card in my lovelace dashboard to control the lamp. Switching on and off works perfectly in all combinations of switch and lamp, also setting the brightness works very good. But unfortunately setting the light fails, simply nothing happens.

I’ve took the code from the example from HA guide and modified, maybe I’ve overseen something or do not really understand it. Any idea what is wrong

Hey, nobody out there who has a solution on that? I thought this is somehow a common problem, having a smart switch and then some smart bulbs with color controls behind them. I’m just wondering…

See my working example here.

I’m afraid it is somehow related to the Trädfri bulbs I use, so that they somehow cannot process a turn on command combined with a set brightness. More worse than described above, the unified lamps are always turning on with the lowest brightness instead of remembering the brightness used the last time.

Sorry, I think I can’t help you with you original problem but I can’t help my self from point out that you are using this snippet for the color_template:

 color_template: "{{ state_attr('light.bulbs_spotlight_livingroom', 'hs_color') | float}}"

while in the HomeAssitant light-template docs it states:

color_template
template (optional, default: optimistic)
Defines a template to get the color of the light. Must render a tuple (hue, saturation)

Does this configuration still works for you?
you are feeding a float into color_template value