Customize.yaml for changing color icon on Climate entity

Hi all,

I am sure I have a very simple error I am not able to see or it is just my little knowledge on the customization section. This is what I am trying:

climate.ground_floor_thermostat:
  templates:
    icon: >
      if (state === 'heat') return 'mdi:fire';
      if (state === 'cool') return 'mdi:snowflake';
      if (state === 'off') return 'mdi:sleep';
      return 'mdi:power-off';
    icon_color: >-
      if (hvac_action == 'cooling') return 'red';
      return 'green';

So, this changes the icon but also wanted to change the color depending on the status (Cooling, Heating or Idle), but I am not sure if I can use hvac_action.

The icon changes perfectly, but the color is not reflected.

Another question: I assume I can’t use Jinja here, right?

That is correct.

1 Like

I will reply myself with the solution, that is:

climate.ground_floor_thermostat:
  templates:
    icon: >
      if (state === 'heat') return 'mdi:fire';
      if (state === 'cool') return 'mdi:snowflake';
      if (state === 'off') return 'mdi:sleep';
      return 'mdi:power-off';
    icon_color: >-
      if (attributes.hvac_action === 'idle') return 'red';
      if (attributes.hvac_action === 'cooling') return 'green';