Using hs_color for icon_color in template

I have a cheapie zigbee light strip for my tv backlight, and would like for it’s icon_color to dynamically change in a template card as the light strip changes color every 6 seconds. This is possible somehow, as if I create an entity card for this item, that icon changes colors dynamically.

the lightstrip returns an HS Color in the format (hhh,hhh, sss.sss)

 state_attr('light.lightstrip_tv_level_light_color_on_off','hs_color')

Is it possible to template this to use hs_color for icon_color? It looks like there was an old syntax where we said “return rgb (rr,gg,bb)” or some such but now we have the enumerated color list.

Was trying something similar, to color the icon of a mushroom chip template card with the color of the light, and found a solution that worked for mine:

icon_color: '{{ state_attr("light.thislightsname", "rgb_color") }}'

Seems that template cards can render rgb_color’s, or friendly names (“Red”, “Blue”, etc), but not hs_color. Check your light-strip has rgb_color in Developer tools, and see if this works.

1 Like