Changer la couleur des icones via card-mod sur carte picture-glance

Bonjour,

Mon problème

J’essaie de changer la couleur des icônes sur une carte picture-glance avec card-mod
L’idéal serait de modifier la couleur en fonction du statut de l’entité concernée
Merci pour votre aide

camera_view: auto
type: picture-glance
entities:
  - entity: switch.camera_salon_camera_shutter
    icon: mdi:window-shutter-settings
  - entity: switch.camera_salon_stream
    icon: mdi:play-pause
camera_image: camera.camera_salon_snapshot
title: Salon

Ma configuration


Texte à remplacer par votre configuration

Comment récupérer ma configuration :
Dans votre HA, Menu latéral Paramètres > Système > Corrections puis les trois petits points en haut a droite > Informations Système puis une fois en bas Copier


Bonjour ,
un exemple:

card_mod:
  style:
    .box div:nth-child(3):
      div:nth-child(1):
        ha-icon-button ha-state-icon:
          $:
            ha-icon:
              $: |
                ha-svg-icon {
                {% if states('switch.camera_salon_camera_shutter') == 'on' %}
                 color: green;
                {% else %}
                 color: red;
                {% endif %}                  
                }
      div:nth-child(2):
        ha-icon-button ha-state-icon:
          $:
            ha-icon:
              $: |
                ha-svg-icon {
                {% if states('switch.camera_salon_stream') == 'on' %}
                 color: green;
                {% else %}
                 color: red;
                {% endif %}  
                }

Merci pour ta réponse
J’ai ajouté le code en dessous de la ligne icon: de l’entité concernée
Pas de message d’erreur mais l’icône reste blanche

Ça ce met au même niveau que type: picture-glance.

camera_view: auto
type: picture-glance
entities:
  - entity: switch.camera_salon_camera_shutter
    icon: mdi:window-shutter-settings
  - entity: switch.camera_salon_stream
    icon: mdi:play-pause
camera_image: camera.camera_salon_snapshot
title: Salon
card_mod:
  style:
    .box div:nth-child(3):
      div:nth-child(1):
        ha-icon-button ha-state-icon:
          $:
            ha-icon:
              $: |
                ha-svg-icon {
                {% if states('switch.camera_salon_camera_shutter') == 'on' %}
                 color: green;
                {% else %}
                 color: red;
                {% endif %}                  
                }
      div:nth-child(2):
        ha-icon-button ha-state-icon:
          $:
            ha-icon:
              $: |
                ha-svg-icon {
                {% if states('switch.camera_salon_stream') == 'on' %}
                 color: green;
                {% else %}
                 color: red;
                {% endif %}  
                }

Super
Merci beaucoup !

Ce sujet a été automatiquement fermé après 2 jours. Aucune réponse n’est permise dorénavant.