Switch value_template by attributes xy_color (rgb stripe)

Hi to all,
I have a switch:

 - platform: template
   switches:
     my_scene_switch:
       friendly_name: "Bright Color"
       value_template: "{{ is_state('light.fibaro_system_fgrgbwm441_rgbw_controller_level_8', 'on') }}"
     turn_on:
       service: scene.turn_on
       data:
         entity_id: scene.kitchen_led_bright
     turn_off:
       service: scene.turn_on
       data:
         entity_id: scene.kitchen_strip_off

That’s work well, but now I want switch to be on, when attribute of rgb stripe xy_color is 0.293,0.389

Trying this:

value_template: "{{ is_state_attr('light.fibaro_system_fgrgbwm441_rgbw_controller_level_8', 'xy_color', '0.293,0.389') }}"

and this:

value_template: "{{ light.fibaro_system_fgrgbwm441_rgbw_controller_level_8.attributes.xy_color', '[0.293,0.389]' }}"

both are incorrect.

What do you get when you put the following in the template editor:

{{ state_attr('light.fibaro_system_fgrgbwm441_rgbw_controller_level_8', 'xy_color') }}
{{ states.light.fibaro_system_fgrgbwm441_rgbw_controller_level_8.attributes.yx_color }}
{{ state_attr('light.fibaro_system_fgrgbwm441_rgbw_controller_level_8', 'xy_color') is string }}
{{ states.light.fibaro_system_fgrgbwm441_rgbw_controller_level_8.attributes.yx_color is string }}
  1. 0.293,0.389
  2. nothing
  3. true
  4. false

the idea is show switch turned on only when specific color is bright.

Oops, sorry, typo. Could you try it again, but with this:

{{ state_attr('light.fibaro_system_fgrgbwm441_rgbw_controller_level_8', 'xy_color') }}
{{ states.light.fibaro_system_fgrgbwm441_rgbw_controller_level_8.attributes.yx_color }}
{{ state_attr('light.fibaro_system_fgrgbwm441_rgbw_controller_level_8', 'xy_color') is string }}
{{ states.light.fibaro_system_fgrgbwm441_rgbw_controller_level_8.attributes.xy_color is string }}

Even so, given what you got for 1 & 3 should mean that your first template (value_template: "{{ is_state_attr('light.fibaro_system_fgrgbwm441_rgbw_controller_level_8', 'xy_color', '0.293,0.389') }}") should have worked.

So, get worked this:

value_template: "{{ is_state_attr('light.fibaro_system_fgrgbwm441_rgbw_controller_level_8', 'hs_color', (120.0, 100.0) ) }}"

But the same scene with same color return different hs_color value.

xy_color in my case is the same, for different colors(scenes)

rgb_color is always “true”

FYI, hs_color, xy_color and rgb_color are all just different representations of the same thing - color. E.g, if you pass the light.turn_on service xy_color or rgb_color, it will convert them to hs_color before calling the corresponding platform function that actually turns on the light. Even color_name will get converted to hs_color.

Now, how various light platform code will represent the current color of an entity is a different story. In theory it could use an hs_color attribute, an xy_color attribute, or an rgb_color attribute, and any of those should properly represent the color of the light. In theory it could even use more than one, as long as they all have equivalent values - i.e., equivalent in the different representations. But I’ve seen cases where platform code does not seem to do this properly. So “your mileage may vary.”

BTW, rgb_color should never be ‘true’. It should be a tuple with three values. (Unless you meant your template using rgb_color always returns true.)