Customise light icon

Hi,

I have Shelly 1 that controls a light. I have used the Shelly integration to configure it. I want to configure different icons for off and on state. Can I add it in configuration.yaml?

I tried the below snippet and neither icon_template nor color_template are having any effect. The friendly_name and icon works though.

homeassistant:
  
  customize:
    light.study:
      friendly_name: test_light
#      icon: mdi:rss-box
      templates:
        icon_color: >
          if (state.attributes.brightness < 150) return 'blue';
          return 'red';
      
        icon_template: >
          {% if states('light.study') == 'on' %}
            'mdi:rss';
          {% else %}
            'mdi:rss-off';

Regards,
AK

Customization doesn’t support templating. That’s why only the two options that worked were the ones where you didn’t use a template.

The only way to use templating there is if you are using Custom UI.

How can I change icon based upon the state then?

Basically you’re asking how to make this Shelly light entity’s icon appear a certain way in any standard card it’s used in. As far as I know know, that’s not possible because you can’t template a light entity’s icon (unless it’s a Template Light) and the majority of standard cards don’t support templating.

Templating an icon is supported by several custom cards (for example, Custom Button Card).

I have templated the icon in custom button card and that works great. The only thing is that it has to be repeated at every place I used. Some times I don’t use a custom button card in a certain way I look at the light entities.

For other cards you can user this:

But again, you have to do it for all cards.

I am already using custom button cards. That is working for me. If I need to change, I’ll explore your suggestion.

Thanks.

I was addressing this statement:

Got it. Thanks!