# Bubble card, changement de couleur texte

**URL:** <https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452>\
**Category:** Entraide Home Assistant\
**Tags:** aide, card\
**Created:** [Août 22, 2025, 11:07 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452 "2025-08-22T11:07:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_GERARD](https://forum.hacf.fr/user_avatar/forum.hacf.fr/patrick_gerard/32/130742_2.png) [@Patrick\_GERARD](https://forum.hacf.fr/u/Patrick_GERARD)\
**Post date:** [Août 22, 2025, 11:07 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/1 "2025-08-22T11:07:32Z")

</div>

Bonjour,

j’essai de faire des bubble card pour le moment je suis arrivé a ce résultat.

 ![Capture d'écran 2025-08-22 130034](https://forum.hacf.fr/uploads/default/original/3X/b/c/bc0e4e6c682b9a81feb29627affe8c2415abbb80.png)

```yaml
type: custom:bubble-card
card_type: button
button_type: state
name: Production solaire
scrolling_effect: false
show_attribute: false
card_layout: large-2-rows
sub_button:
  - show_background: false
    show_state: true
    icon: mdi:solar-power-variant-outline
    entity: sensor.watt_hour1
    show_name: true
    name: Spa
  - show_background: false
    icon: mdi:solar-power-variant-outline
    show_state: true
    tap_action:
      action: none
    entity: sensor.watt_hour2
    name: Maison
    show_name: true
  - show_background: false
    show_state: true
    icon: mdi:solar-power
    tap_action:
      action: fire-dom-event
      browser_mod:
        service: browser_mod.popup
        data:
          size: normal
          style: "--popup-border-radius: 10px"
          content:
            type: horizontal-stack
            cards:
              - type: statistics-graph
                chart_type: line
                period: hour
                entities:
                  - sensor.qualite_de_l_air_temperature
                stat_types:
                  - max
                logarithmic_scale: false
                hide_legend: true
                title: Température Intérieur
                days_to_show: 1
    entity: sensor.total_day1
    show_name: false
  - show_background: false
    show_state: true
    icon: mdi:solar-power
    tap_action:
      action: none
    entity: sensor.total_day2
show_icon: true
icon: mdi:sun-angle
force_icon: false
show_name: true
show_last_changed: false
entity: sensor.tdeg_cabane_temperature
grid_options:
  columns: 15
  rows: 1
card_mod:
  style: |
    .bubble-icon-container {
      background: transparent;
      background-size: cover;
      
    .bubble-sub-button-1 {
      background-color:
      {% set watts = states(config.sub_button[1].entity) W}
      {% if watts <= '300' W}
        rgb(var(--bbl-rgb-yellow))
      {% elif watts >= '400' W}
        rgb(var(--bbl-rgb-orange))
      {% elif watts >= '600' W}
        rgb(var(--bbl-rgb-red))
      {% endif %}
      ;
    }

    .bubble-sub-button-2 {
        background-color:
        {% set w = states(config.sub_button[2].entity) W}
      {% if w <= '300' W}
        rgb(var(--bbl-rgb-yellow))
      {% elif w >= '400' W}
        rgb(var(--bbl-rgb-orange))
      {% elif w >= '600' W}
        rgb(var(--bbl-rgb-red))
      {% endif %}
      ;
    }
    .bubble-sub-button-3 {
      background-color:
    }
    .bubble-sub-button-4 {
      background-color:
    }

```

et je souhaiterais possible avoir la couleur de mes chiffres spa et maison qui change de couleur en fonction des watts.

je m’explique:

de 0 à 200 w en jaune

de 200 à 400 en orange

de 400 à 800 en rouge

je ne sais pas si c’est faisable et je remercie par avance les personnes qui m’auront aider.

merci

- Méthode d’installation Home Assistant OS

- Core2025.8.3

- Supervisor2025.08.1

- Operating System16.1

- Interface utilisateur20250811.1

---

<div class="post-metadata">

**Author:** ![Bryan94400](https://forum.hacf.fr/user_avatar/forum.hacf.fr/bryan94400/32/111477_2.png) [@Bryan94400](https://forum.hacf.fr/u/Bryan94400)\
**Post date:** [Août 22, 2025, 4:04 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/2 "2025-08-22T16:04:48Z")

</div>

Salut, essaie ceci la ton code essaie d’utiliser du **Jinja (`{% ... %}`)** alors que dans Lovelace **card-mod** il faut du **JavaScript template `[[[...]]]`**.  
Voici ton code adapté pour que la couleur des chiffres (ou du fond si tu préfères) change selon tes seuils :

```auto
type: custom:bubble-card
card_type: button
button_type: state
name: Production solaire
scrolling_effect: false
show_attribute: false
card_layout: large-2-rows
sub_button:
  - show_background: false
    show_state: true
    icon: mdi:solar-power-variant-outline
    entity: sensor.watt_hour1
    show_name: true
    name: Spa
  - show_background: false
    icon: mdi:solar-power-variant-outline
    show_state: true
    tap_action:
      action: none
    entity: sensor.watt_hour2
    name: Maison
    show_name: true
  - show_background: false
    show_state: true
    icon: mdi:solar-power
    tap_action:
      action: fire-dom-event
      browser_mod:
        service: browser_mod.popup
        data:
          size: normal
          style: "--popup-border-radius: 10px"
          content:
            type: horizontal-stack
            cards:
              - type: statistics-graph
                chart_type: line
                period: hour
                entities:
                  - sensor.qualite_de_l_air_temperature
                stat_types:
                  - max
                logarithmic_scale: false
                hide_legend: true
                title: Température Intérieur
                days_to_show: 1
    entity: sensor.total_day1
    show_name: false
  - show_background: false
    show_state: true
    icon: mdi:solar-power
    tap_action:
      action: none
    entity: sensor.total_day2
show_icon: true
icon: mdi:sun-angle
force_icon: false
show_name: true
show_last_changed: false
entity: sensor.tdeg_cabane_temperature
grid_options:
  columns: 15
  rows: 1
card_mod:
  style: |
    /* === Couleur du texte (état) pour le Spa === */
    .bubble-sub-button-1 .bubble-sub-button-state {
      color: [[[
        let v = parseFloat(states['sensor.watt_hour1']?.state || 0);
        if (v < 200) return 'rgb(var(--bbl-rgb-yellow))';
        if (v < 400) return 'rgb(var(--bbl-rgb-orange))';
        return 'rgb(var(--bbl-rgb-red))';
      ]]];
      font-weight: bold;
    }

    /* === Couleur du texte (état) pour la Maison === */
    .bubble-sub-button-2 .bubble-sub-button-state {
      color: [[[
        let v = parseFloat(states['sensor.watt_hour2']?.state || 0);
        if (v < 200) return 'rgb(var(--bbl-rgb-yellow))';
        if (v < 400) return 'rgb(var(--bbl-rgb-orange))';
        return 'rgb(var(--bbl-rgb-red))';
      ]]];
      font-weight: bold;
    }

```

🔸 Résultat :

- 0 → 199 W : **jaune**
- 200 → 399 W : **orange**
- 400 → 800+ W : **rouge**

👉 Ici j’ai coloré uniquement les **chiffres (state)**.  
Si tu veux plutôt colorer le **fond du bouton** en entier, on peut appliquer la même logique sur `.bubble-sub-button-1` et `.bubble-sub-button-2` avec `background-color:` au lieu de `color:`.

---

<div class="post-metadata">

**Author:** ![Patrick\_GERARD](https://forum.hacf.fr/user_avatar/forum.hacf.fr/patrick_gerard/32/130742_2.png) [@Patrick\_GERARD](https://forum.hacf.fr/u/Patrick_GERARD)\
**Post date:** [Août 22, 2025, 5:02 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/3 "2025-08-22T17:02:02Z")

</div>

et ben sa fonctionne pas, y a pas de couleur

---

<div class="post-metadata">

**Author:** ![Bryan94400](https://forum.hacf.fr/user_avatar/forum.hacf.fr/bryan94400/32/111477_2.png) [@Bryan94400](https://forum.hacf.fr/u/Bryan94400)\
**Post date:** [Août 22, 2025, 6:20 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/4 "2025-08-22T18:20:36Z")

</div>

Re hum…

essaie cela et dit moi si y a des changement.

```auto

type: custom:bubble-card
card_type: button
button_type: state
name: Production solaire
scrolling_effect: false
show_attribute: false
card_layout: large-2-rows

sub_button:
  - show_background: false
    show_state: true
    icon: mdi:solar-power-variant-outline
    entity: sensor.watt_hour1
    show_name: true
    name: Spa

  - show_background: false
    icon: mdi:solar-power-variant-outline
    show_state: true
    tap_action:
      action: none
    entity: sensor.watt_hour2
    name: Maison
    show_name: true

  - show_background: false
    show_state: true
    icon: mdi:solar-power
    tap_action:
      action: fire-dom-event
      browser_mod:
        service: browser_mod.popup
        data:
          size: normal
          style: "--popup-border-radius: 10px"
          content:
            type: horizontal-stack
            cards:
              - type: statistics-graph
                chart_type: line
                period: hour
                entities:
                  - sensor.qualite_de_l_air_temperature
                stat_types:
                  - max
                logarithmic_scale: false
                hide_legend: true
                title: Température Intérieur
                days_to_show: 1
    entity: sensor.total_day1
    show_name: false

  - show_background: false
    show_state: true
    icon: mdi:solar-power
    tap_action:
      action: none
    entity: sensor.total_day2

show_icon: true
icon: mdi:sun-angle
force_icon: false
show_name: true
show_last_changed: false
entity: sensor.tdeg_cabane_temperature
grid_options:
  columns: 15
  rows: 1

# >>> Styles Bubble-Card natifs (pas de card_mod, pas de Jinja) <<<
styles: |
  /* Calcule les couleurs en JS et les stocke en variables CSS */
  ha-card {
    --spa-color: [[[
      let v = states['sensor.watt_hour1']?.state ?? '0';
      v = parseFloat(String(v).replace(',', '.')) || 0;
      if (v < 200) return 'rgb(var(--bbl-rgb-yellow))';
      if (v < 400) return 'rgb(var(--bbl-rgb-orange))';
      return 'rgb(var(--bbl-rgb-red))';
    ]]];
    --maison-color: [[[
      let v = states['sensor.watt_hour2']?.state ?? '0';
      v = parseFloat(String(v).replace(',', '.')) || 0;
      if (v < 200) return 'rgb(var(--bbl-rgb-yellow))';
      if (v < 400) return 'rgb(var(--bbl-rgb-orange))';
      return 'rgb(var(--bbl-rgb-red))';
    ]]];
  }

  /* SPA = 1er sous-bouton : colore le chiffre (state) + option icône */
  ha-card .bubble-sub-buttons > *:nth-child(1) .bubble-sub-button-state,
  ha-card .bubble-sub-buttons > *:nth-child(1) .state {
    color: var(--spa-color) !important;
    font-weight: 600;
  }
  ha-card .bubble-sub-buttons > *:nth-child(1) ha-icon {
    color: var(--spa-color) !important;
  }

  /* MAISON = 2e sous-bouton */
  ha-card .bubble-sub-buttons > *:nth-child(2) .bubble-sub-button-state,
  ha-card .bubble-sub-buttons > *:nth-child(2) .state {
    color: var(--maison-color) !important;
    font-weight: 600;
  }
  ha-card .bubble-sub-buttons > *:nth-child(2) ha-icon {
    color: var(--maison-color) !important;
  }

```

---

<div class="post-metadata">

**Author:** ![Patrick\_GERARD](https://forum.hacf.fr/user_avatar/forum.hacf.fr/patrick_gerard/32/130742_2.png) [@Patrick\_GERARD](https://forum.hacf.fr/u/Patrick_GERARD)\
**Post date:** [Août 22, 2025, 6:33 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/5 "2025-08-22T18:33:27Z")

</div>

aucun changement, pas de couleur

 ![Capture d'écran 2025-08-22 203741](https://forum.hacf.fr/uploads/default/original/3X/2/7/27b9c72b22bd3b3a95377f7d9619038b3bfc092b.png)

---

<div class="post-metadata">

**Author:** ![Bryan94400](https://forum.hacf.fr/user_avatar/forum.hacf.fr/bryan94400/32/111477_2.png) [@Bryan94400](https://forum.hacf.fr/u/Bryan94400)\
**Post date:** [Août 22, 2025, 6:43 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/6 "2025-08-22T18:43:24Z")

</div>

Test rapide (vérifier que les styles s’appliquent)

Ajoute temporairement en bas de ta carte :

```auto
styles: |
  /* Test visible : l’icône principale passe en fuchsia */
  .bubble-icon { color: fuchsia !important; }

```

- Si l’icône ne devient pas fuchsia ➜ le module n’est pas chargé ou le cache n’est pas vidé.
- Si elle devient fuchsia ➜ passe au code dynamique ci-dessous (et enlève ce test).

---

<div class="post-metadata">

**Author:** ![Patrick\_GERARD](https://forum.hacf.fr/user_avatar/forum.hacf.fr/patrick_gerard/32/130742_2.png) [@Patrick\_GERARD](https://forum.hacf.fr/u/Patrick_GERARD)\
**Post date:** [Août 22, 2025, 6:45 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/7 "2025-08-22T18:45:59Z")

</div>

pas de fuchsia

comment on vide le cache sur ha

---

<div class="post-metadata">

**Author:** ![Bryan94400](https://forum.hacf.fr/user_avatar/forum.hacf.fr/bryan94400/32/111477_2.png) [@Bryan94400](https://forum.hacf.fr/u/Bryan94400)\
**Post date:** [Août 22, 2025, 6:47 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/8 "2025-08-22T18:47:15Z")

</div>

sur PC ? tu fait CTRL + SHIFT + R

---

<div class="post-metadata">

**Author:** ![Patrick\_GERARD](https://forum.hacf.fr/user_avatar/forum.hacf.fr/patrick_gerard/32/130742_2.png) [@Patrick\_GERARD](https://forum.hacf.fr/u/Patrick_GERARD)\
**Post date:** [Août 22, 2025, 6:51 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/9 "2025-08-22T18:51:21Z")

</div>

voila j’ai reinstallé bubble-card et vider le cache et rien nada pas de couleur

---

<div class="post-metadata">

**Author:** ![Bryan94400](https://forum.hacf.fr/user_avatar/forum.hacf.fr/bryan94400/32/111477_2.png) [@Bryan94400](https://forum.hacf.fr/u/Bryan94400)\
**Post date:** [Août 22, 2025, 6:55 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/10 "2025-08-22T18:55:36Z")

</div>

- Va dans **Paramètres → Tableaux de bord → Ressources**
- Tu dois voir une ligne du style :

```auto
/hacsfiles/bubble-card/bubble-card.js

```

en type **JavaScript Module**.

- Si ce n’est pas là → ajoute-la manuellement.

Après chaque modif → vide le cache navigateur ( **Ctrl+Shift+R** sur PC).

---

<div class="post-metadata">

**Author:** ![Patrick\_GERARD](https://forum.hacf.fr/user_avatar/forum.hacf.fr/patrick_gerard/32/130742_2.png) [@Patrick\_GERARD](https://forum.hacf.fr/u/Patrick_GERARD)\
**Post date:** [Août 22, 2025, 7:06 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/11 "2025-08-22T19:06:03Z")

</div>

> [@Bryan94400](#):
>
> `/hacsfiles/bubble-card/bubble-card.js`

j,ai tout reinstallé y compris le js et rien

---

<div class="post-metadata">

**Author:** ![Bryan94400](https://forum.hacf.fr/user_avatar/forum.hacf.fr/bryan94400/32/111477_2.png) [@Bryan94400](https://forum.hacf.fr/u/Bryan94400)\
**Post date:** [Août 22, 2025, 7:21 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/12 "2025-08-22T19:21:00Z")

</div>

bon bah je suis désolé j’ai essayer de t’aidez personnellement 😕

je vais laissé d’autre personne répondre si il on une solution sinon je te propose de faire une issue sur

> **[GitHub - Clooos/Bubble-Card: Bubble Card is a minimalist card collection for...](https://github.com/Clooos/Bubble-Card)**
>
> Bubble Card is a minimalist card collection for Home Assistant with a nice pop-up touch.

---

<div class="post-metadata">

**Author:** ![Patrick\_GERARD](https://forum.hacf.fr/user_avatar/forum.hacf.fr/patrick_gerard/32/130742_2.png) [@Patrick\_GERARD](https://forum.hacf.fr/u/Patrick_GERARD)\
**Post date:** [Août 22, 2025, 7:23 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/13 "2025-08-22T19:23:19Z")

</div>

apres avoir redemarrer une derniere fois l’icone est devenu fuchsia

---

<div class="post-metadata">

**Author:** ![Bryan94400](https://forum.hacf.fr/user_avatar/forum.hacf.fr/bryan94400/32/111477_2.png) [@Bryan94400](https://forum.hacf.fr/u/Bryan94400)\
**Post date:** [Août 22, 2025, 7:24 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/14 "2025-08-22T19:24:21Z")

</div>

ha ca c’est une bonne nouvelle donc essaie de nouveau

```auto
type: custom:bubble-card
card_type: button
button_type: state
name: Production solaire
scrolling_effect: false
show_attribute: false
card_layout: large-2-rows

sub_button:
  - show_background: false
    show_state: true
    icon: mdi:solar-power-variant-outline
    entity: sensor.watt_hour1
    show_name: true
    name: Spa

  - show_background: false
    icon: mdi:solar-power-variant-outline
    show_state: true
    tap_action:
      action: none
    entity: sensor.watt_hour2
    name: Maison
    show_name: true

  - show_background: false
    show_state: true
    icon: mdi:solar-power
    tap_action:
      action: fire-dom-event
      browser_mod:
        service: browser_mod.popup
        data:
          size: normal
          style: "--popup-border-radius: 10px"
          content:
            type: horizontal-stack
            cards:
              - type: statistics-graph
                chart_type: line
                period: hour
                entities:
                  - sensor.qualite_de_l_air_temperature
                stat_types:
                  - max
                logarithmic_scale: false
                hide_legend: true
                title: Température Intérieur
                days_to_show: 1
    entity: sensor.total_day1
    show_name: false

  - show_background: false
    show_state: true
    icon: mdi:solar-power
    tap_action:
      action: none
    entity: sensor.total_day2

show_icon: true
icon: mdi:sun-angle
force_icon: false
show_name: true
show_last_changed: false
entity: sensor.tdeg_cabane_temperature
grid_options:
  columns: 15
  rows: 1

# >>> Styles Bubble-Card natifs (pas de card_mod, pas de Jinja) <<<
styles: |
  /* Calcule les couleurs en JS et les stocke en variables CSS */
  ha-card {
    --spa-color: [[[
      let v = states['sensor.watt_hour1']?.state ?? '0';
      v = parseFloat(String(v).replace(',', '.')) || 0;
      if (v < 200) return 'rgb(var(--bbl-rgb-yellow))';
      if (v < 400) return 'rgb(var(--bbl-rgb-orange))';
      return 'rgb(var(--bbl-rgb-red))';
    ]]];
    --maison-color: [[[
      let v = states['sensor.watt_hour2']?.state ?? '0';
      v = parseFloat(String(v).replace(',', '.')) || 0;
      if (v < 200) return 'rgb(var(--bbl-rgb-yellow))';
      if (v < 400) return 'rgb(var(--bbl-rgb-orange))';
      return 'rgb(var(--bbl-rgb-red))';
    ]]];
  }

  /* SPA = 1er sous-bouton : colore le chiffre (state) + option icône */
  ha-card .bubble-sub-buttons > *:nth-child(1) .bubble-sub-button-state,
  ha-card .bubble-sub-buttons > *:nth-child(1) .state {
    color: var(--spa-color) !important;
    font-weight: 600;
  }
  ha-card .bubble-sub-buttons > *:nth-child(1) ha-icon {
    color: var(--spa-color) !important;
  }

  /* MAISON = 2e sous-bouton */
  ha-card .bubble-sub-buttons > *:nth-child(2) .bubble-sub-button-state,
  ha-card .bubble-sub-buttons > *:nth-child(2) .state {
    color: var(--maison-color) !important;
    font-weight: 600;
  }
  ha-card .bubble-sub-buttons > *:nth-child(2) ha-icon {
    color: var(--maison-color) !important;
  }

```

hésite pas a redémarrer si besoin

---

<div class="post-metadata">

**Author:** ![Patrick\_GERARD](https://forum.hacf.fr/user_avatar/forum.hacf.fr/patrick_gerard/32/130742_2.png) [@Patrick\_GERARD](https://forum.hacf.fr/u/Patrick_GERARD)\
**Post date:** [Août 22, 2025, 7:31 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/15 "2025-08-22T19:31:00Z")

</div>

> [@Bryan94400](#):
>
> ```auto
> styles: |
> /* Test visible : l’icône principale passe en fuchsia */
> .bubble-icon { color: fuchsia !important; }
> 
> ```

j’ai l’icone fuschia, mais pas les chiffres en couleur, bon en meme temps y a plus de production, y fait nuit.

---

<div class="post-metadata">

**Author:** ![Bryan94400](https://forum.hacf.fr/user_avatar/forum.hacf.fr/bryan94400/32/111477_2.png) [@Bryan94400](https://forum.hacf.fr/u/Bryan94400)\
**Post date:** [Août 22, 2025, 7:37 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/16 "2025-08-22T19:37:55Z")

</div>

> [@Patrick\_GERARD](#):
>
> bon en meme temps y a plus de production, y fait nuit.

tu peux modifier les valeur ( fictive dans les outils de développement) attention sa ne reste pas longtemps non plus mais sa te permet de faire tes test

---

<div class="post-metadata">

**Author:** ![Patrick\_GERARD](https://forum.hacf.fr/user_avatar/forum.hacf.fr/patrick_gerard/32/130742_2.png) [@Patrick\_GERARD](https://forum.hacf.fr/u/Patrick_GERARD)\
**Post date:** [Août 22, 2025, 7:54 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/17 "2025-08-22T19:54:29Z")

</div>

je trouve pas ou ça se trouve

---

<div class="post-metadata">

**Author:** ![Patrick\_GERARD](https://forum.hacf.fr/user_avatar/forum.hacf.fr/patrick_gerard/32/130742_2.png) [@Patrick\_GERARD](https://forum.hacf.fr/u/Patrick_GERARD)\
**Post date:** [Août 23, 2025, 8:17 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/18 "2025-08-23T08:17:23Z")

</div>

quand je met ce code, j’ai le texte en bold et le reste ne fonctionne pas.

```auto
/* === Couleur du texte (état) pour le Maison === */
     .bubble-sub-button-1 { 
      color: [[[
        let v = parseFloat(states['sensor.watt_hour1']?.state || 0);
        if (v < 200) return 'rgb(var(--bbl-rgb-yellow))';
        if (v < 400) return 'rgb(var(--bbl-rgb-orange))';
        return 'rgb(var(--bbl-rgb-red))';
      ]]];
      font-weight: bold;
    }

```

 ![Capture d'écran 2025-08-23 101649](https://forum.hacf.fr/uploads/default/original/3X/f/5/f5dc586cf13e6454d530c982c6463e8e3fe48a77.png)

et quand je met ceci

```auto
 /* === Couleur du texte (état) pour la Maison === */
    .bubble-sub-button-2 .bubble-sub-button-state {
      color: [[[
        let v = parseFloat(states['sensor.watt_hour2']?.state || 0);
        if (v < 200) return 'rgb(var(--bbl-rgb-yellow))';
        if (v < 400) return 'rgb(var(--bbl-rgb-orange))';
        return 'rgb(var(--bbl-rgb-red))';
      ]]];
      font-weight: bold;
    }

```

y a plus rien

 ![Capture d'écran 2025-08-23 101946](https://forum.hacf.fr/uploads/default/original/3X/4/8/4811ea1762cd11ad89ed495624bab8f7783835eb.png)

---

<div class="post-metadata">

**Author:** ![WarC0zes](https://forum.hacf.fr/user_avatar/forum.hacf.fr/warc0zes/32/137471_2.png) [@WarC0zes](https://forum.hacf.fr/u/WarC0zes)\
**Post date:** [Août 23, 2025, 8:47 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/19 "2025-08-23T08:47:36Z")

</div>

Bonjour,  
essaye ça plutôt :

```yaml
styles: |
  .bubble-sub-button-2 .bubble-sub-button-state {
    color: ${hass.states['sensor.watt_hour2'].state <= '200' ? 'yellow' : hass.states['sensor.watt_hour2'].state <= '400' ? 'orange' : 'red'} !important;
    font-weight: bold;
  }

```

---

<div class="post-metadata">

**Author:** ![Patrick\_GERARD](https://forum.hacf.fr/user_avatar/forum.hacf.fr/patrick_gerard/32/130742_2.png) [@Patrick\_GERARD](https://forum.hacf.fr/u/Patrick_GERARD)\
**Post date:** [Août 23, 2025, 8:55 UTC](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452/20 "2025-08-23T08:55:38Z")

</div>

non toujours pas

 ![Capture d'écran 2025-08-23 105507](https://forum.hacf.fr/uploads/default/original/3X/d/f/df879deed088ee74832ba745afbb8a18f48566cb.png)

[Page suivante](https://forum.hacf.fr/t/bubble-card-changement-de-couleur-texte/66452.md?page=2)
