Changing Icon color, (when icon changes)

Good day Everyone,

I’ve been searching if some one had done this before, and it does look like it, but I can get it work.
I change an icon based on what app is running on my TV, but I would like to change the color with it, but can’t get it to work.
Below is my template currently working, not sure how to proceed to add the Icon color aswell

‘’’

  • platform: template
    sensors:
    tv_state:
    friendly_name: TV State
    value_template: >-
    {{ states(‘sensor.tv_state_app’) }}
    icon_template: >-
    {% if is_state(‘sensor.tv_state’,‘netflix’) %}
    {{ ‘mdi:netflix’ }}
    {% elif is_state(‘sensor.tv_state’,‘plex’) %}
    {{ ‘mdi:plex’ }}
    {% elif is_state(‘sensor.tv_state’,‘youtube’) %}
    {{ ‘mdi:youtube’ }}
    {% elif is_state(‘sensor.tv_state’,‘amazon’) %}
    {{ ‘mdi:emoticon-devil-outline’ }}
    {% elif is_state(‘sensor.tv_state’,‘bbciplayer’) %}
    {{ ‘mdi:alpha-b-circle-outline’ }}
    {% else %}
    {{ ‘mdi:television-classic-off’ }}
    {% endif %}
    ‘’’
    When I add a new temple it would only use one,either color or the icon,

‘’’
value_template: >-
{{ states(‘sensor.tv_state_app’) }}
icon_color: >-
{% if is_state(‘sensor.tv_state’,‘netflix’) %}
‘red’
{% elif is_state(‘sensor.tv_state’,‘plex’) %}
‘yellow’
{% elif is_state(‘sensor.tv_state’,‘youtube’) %}
‘red’
{% elif is_state(‘sensor.tv_state’,‘amazon’) %}
‘blue’
{% else %}
‘grey’
{% endif %}
‘’’
any guidance would be great.

  1. Always place a code into triple “`” - otherwise sometimes impossible to even understand the code.
  2. If you need to display a customized color for some entity in some places (i.e. one or several cards) - then use “card-mod”. Check examples on the path “dedicated card-mod thread in Share your projects-> 1st post → link at the bottom”.

@Ildar_Gabdullin - Ill give that a shot, thanks. ill re-attempt to past my code :grinning:
I used Mushroom config as well so not sure if this would work for that too, the sensor data is an easy way to get it from the start, but it’s now got me stuck. Let me see if the card-mod works for what I need.

- platform: template
  sensors:
    tv_state:
      friendly_name: TV State
      value_template: >-
        {{ states('sensor.tv_state_app') }}
      icon_template:  >-
        {% if is_state('sensor.tv_state','netflix') %}
          {{ 'mdi:netflix' }}
        {% elif is_state('sensor.tv_state','plex') %}
          {{ 'mdi:plex' }}
        {% elif is_state('sensor.tv_state','youtube') %}
          {{ 'mdi:youtube' }}
        {% elif is_state('sensor.tv_state','amazon') %}
          {{ 'mdi:emoticon-devil-outline' }}
        {% elif is_state('sensor.tv_state','bbciplayer') %}
          {{ 'mdi:alpha-b-circle-outline' }}
        {% else %}
          {{ 'mdi:television-classic-off' }}
        {% endif %}