# Un petit exemple d'affichage avec personnalisation de l'alerte météo

**URL:** <https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046>\
**Category:** Interface / Lovelace / Thème / Custom Card\
**Tags:** interface-lovelace\
**Created:** [Janvier 16, 2025, 7:31 UTC](https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046 "2025-01-16T07:31:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![corto](https://forum.hacf.fr/letter_avatar_proxy/v4/letter/c/2bfe46/32.png) [@corto](https://forum.hacf.fr/u/corto)\
**Post date:** [Janvier 16, 2025, 7:31 UTC](https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046/1 "2025-01-16T07:31:20Z")

</div>

Bonjour,

![image](https://forum.hacf.fr/uploads/default/original/3X/f/f/ff5caf88a028e98f5b13eefa92e9a0bfffcd3d0b.png)

on appréciera ou pas mes gouts en matière de couleur mais j'ai réalisé (avec beaucoup d'aide et autant de lectures) un badge d'affichage de l'état de l'alerte météo : suivant l'état changement de la couleur de l'icone, changement du texte et de sa couleur et changement de l'arrière-plan.  
avec card-mod, le code (ça fonctionne alors je partage) :

```auto
type: custom:mushroom-chips-card
chips:
  - type: template
    entity: sensor.33_weather_alert
    icon: mdi:weather-cloudy-alert
    content: |-
      {% set entity = 'sensor.33_weather_alert' %}
          {% if is_state(entity,'Vert') %}
            pas d'alerte
          {% elif is_state(entity,'Jaune') %}
            alerte météo
          {% elif is_state(entity,'Orange') %}
            Risque météo !         
          {% else %}
          Indisponible
          {% endif %}
    icon_color: |-
      {% if is_state(entity, 'Vert') %}
        green
      {% elif is_state(entity, 'Jaune') %}  
        yellow
      {% elif is_state(entity, 'Orange') %}  
        orange
      {% else %} 
        red
      {% endif %}
    card_mod:
      style: |
        ha-card {
           
          {% set entity = 'sensor.33_weather_alert' %}
          {% if is_state(entity,'Vert') %}
            --text-color: green;
          {% elif is_state(entity,'Jaune') %}
            --text-color: yellow;
          {% elif is_state(entity,'Orange') %}
            --text-color: orange;            
          {% else %}
            --text-color: red;
          {% endif %} 
          {% if is_state(entity,'Vert') %}
            --chip-background: white;
          {% elif is_state(entity,'Jaune') %}
            --chip-background: rgba(189, 189, 189, 0.5);
          {% elif is_state(entity,'Orange') %}
            --chip-background: rgba(256, 100, 55, 0.4);            
          {% else %}
            --chip-background: orange;
          {% endif %} 
        }
view_layout:
  position: main
alignment: start

```

---

<div class="post-metadata">

**Author:** ![Anthony86](https://forum.hacf.fr/letter_avatar_proxy/v4/letter/a/c0e974/32.png) [@Anthony86](https://forum.hacf.fr/u/Anthony86)\
**Post date:** [Janvier 16, 2025, 2:55 UTC](https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046/2 "2025-01-16T14:55:27Z")

</div>

bonjour

sympa, je presume qu il faut juste changer le sensor33 par le numero de departement??

genre pour moi sensor86

merci

---

<div class="post-metadata">

**Author:** ![corto](https://forum.hacf.fr/letter_avatar_proxy/v4/letter/c/2bfe46/32.png) [@corto](https://forum.hacf.fr/u/corto)\
**Post date:** [Janvier 16, 2025, 3:08 UTC](https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046/3 "2025-01-16T15:08:56Z")

</div>

tout à fait, j’eus dû le préciser

---

<div class="post-metadata">

**Author:** ![Anthony86](https://forum.hacf.fr/letter_avatar_proxy/v4/letter/a/c0e974/32.png) [@Anthony86](https://forum.hacf.fr/u/Anthony86)\
**Post date:** [Janvier 16, 2025, 3:18 UTC](https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046/4 "2025-01-16T15:18:27Z")

</div>

pas grave, j'ai teste mais j'ai cette erreur

 ![2025-01-16 16_17_44-Maison – Home Assistant — Mozilla Firefox](https://forum.hacf.fr/uploads/default/original/3X/f/b/fba89f5eb9d52465fba69aa8a3931d1c87151f0f.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:** [Janvier 16, 2025, 3:21 UTC](https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046/5 "2025-01-16T15:21:43Z")

</div>

c’est un message d’avertissement, comme tu utilise card-mod dans le code, tu ne peux pas utiliser le mode UI pour editer la carte. C’est quand YAML.  
Rien de grave, c’est normal.

---

<div class="post-metadata">

**Author:** ![Anthony86](https://forum.hacf.fr/letter_avatar_proxy/v4/letter/a/c0e974/32.png) [@Anthony86](https://forum.hacf.fr/u/Anthony86)\
**Post date:** [Janvier 16, 2025, 3:27 UTC](https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046/6 "2025-01-16T15:27:41Z")

</div>

ok merci du coup ça me marque indisponible et quand je clic dessus je n’ai rien

je pense que c’est normal??

---

<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:** [Janvier 16, 2025, 3:32 UTC](https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046/7 "2025-01-16T15:32:34Z")

</div>

tu n'as pas changé toutes les entités `sensor.33_weather_alert`dans le code. il y en a trois à changer

 ![image](https://forum.hacf.fr/uploads/default/original/3X/9/8/981457529430eed96aea706ee9fabc93a8f95bb8.png)

---

<div class="post-metadata">

**Author:** ![hacfbox](https://forum.hacf.fr/user_avatar/forum.hacf.fr/hacfbox/32/136404_2.png) [@hacfbox](https://forum.hacf.fr/u/hacfbox)\
**Post date:** [Janvier 16, 2025, 3:33 UTC](https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046/8 "2025-01-16T15:33:52Z")

</div>

J'ai fait pareil avec une BubleCard

 ![IMG_20250116_163305](https://forum.hacf.fr/uploads/default/original/3X/4/5/45a82d6535195f71236265693ef8a4a28206d6a9.jpeg)

```auto
type: custom:bubble-card
card_type: separator
name: Alarme
icon: mdi:shield-home
card_layout: normal
rows: 1
styles: |-
  .bubble-line {
    background: var(--primary-text-color);
    opacity: 0.1;
  }
  ha-card {
    border-radius: 0px !important;
    padding-top: 20px !important;
    padding-bottom: 80px !important;
    bottom: 0 !important;
     color: ${ hass.states['sensor.69_weather_alert'].state === 'Vert'
        ? 'green'
        : hass.states['sensor.69_weather_alert'].state === 'Jaune'
          ? 'yellow'
          : hass.states['sensor.69_weather_alert'].state === 'Rouge'
            ? 'red'
            : 'orange'
      } !important;
  }
  .bubble-sub-button > ha-icon {
      color: ${ hass.states['sensor.69_weather_alert'].state === 'Vert'
        ? 'green'
        : hass.states['sensor.69_weather_alert'].state === 'Jaune'
          ? 'yellow'
          : hass.states['sensor.69_weather_alert'].state === 'Rouge'
            ? 'red'
            : 'orange'
      } !important;
    }
    .bubble-sub-button-name-container{
      color: ${ hass.states['sensor.69_weather_alert'].state === 'Vert'
        ? 'green'
        : hass.states['sensor.69_weather_alert'].state === 'Jaune'
          ? 'yellow'
          : hass.states['sensor.69_weather_alert'].state === 'Rouge'
            ? 'red'
            : 'orange'
      } !important;
    }
sub_button:
  - entity: sensor.text_vigilance
    show_last_changed: false
    show_state: true
    show_background: false
    show_attribute: false
    name: ""
    show_name: false
    show_icon: true
    icon: mdi:cloud-alert-outline
    hold_action:
      action: more-info
    tap_action:
      action: navigate
      navigation_path: /dashboard-home/meteo

```

---

<div class="post-metadata">

**Author:** ![Anthony86](https://forum.hacf.fr/letter_avatar_proxy/v4/letter/a/c0e974/32.png) [@Anthony86](https://forum.hacf.fr/u/Anthony86)\
**Post date:** [Janvier 16, 2025, 3:37 UTC](https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046/9 "2025-01-16T15:37:01Z")

</div>

oui j'ai bien changer les 3

 ![2025-01-16 16_36_15-Maison – Home Assistant — Mozilla Firefox](https://forum.hacf.fr/uploads/default/original/3X/c/e/ce1824b1bfe96f00701adbb12c601c0c584b7a73.png)

---

<div class="post-metadata">

**Author:** ![Anthony86](https://forum.hacf.fr/letter_avatar_proxy/v4/letter/a/c0e974/32.png) [@Anthony86](https://forum.hacf.fr/u/Anthony86)\
**Post date:** [Janvier 16, 2025, 3:40 UTC](https://forum.hacf.fr/t/un-petit-exemple-daffichage-avec-personnalisation-de-lalerte-meteo/56046/10 "2025-01-16T15:40:03Z")

</div>

j’ai trouver c’est les 3 sensor86… y avait ajouter des mots en trop

encore merci

ça fonctionne
