Alors, voici mon code qui fonctionne
type: custom:mushroom-chips-card
chips:
- type: template
entity: switch.clim_bureau
icon: mdi:air-conditioner
content: |
{% set entity = 'switch.clim_bureau' %}
{% if is_state(entity,'off') %}
Clim Bureau
coupée
{% elif is_state(entity,'on') %}
Clim Bureau
en service
{% else %}
Indisponible
{% endif %}
icon_color: |-
{% if is_state(entity, 'on') %}
light-blue
{% elif is_state(entity, 'off') %}
grey
{% else %}
red
{% endif %}
card_mod:
style: |
ha-card
{
white-space: pre;
{% set entity = 'switch.clim_bureau' %}
{% if is_state(entity,'on') %}
--text-color: rgba(0, 150, 200, 1);
{% elif is_state(entity,'off') %}
--text-color: blue-grey;
{% else %}
--text-color: red;
{% endif %}
{% if is_state(entity,'on') %}
--chip-background: rgba(225, 250, 240, 1);
{% elif is_state(entity,'off') %}
--chip-background: rgba(255, 255, 255, 1);
{% else %}
--chip-background: orange;
{% endif %}
}
tap_action:
action: perform-action
perform_action: switch.turn_on
target:
entity_id: switch.clim_bureau
view_layout:
position: main
ET celui qui ne fonctionne pas que l’ajout soit en commentaire ou non (en fait mis en commentaire il ‘compile’ en ne me permettant pas d’enregistrer ! je pensais que les lignes de commentaires n’étaient pas prises en compte ! si je décommente (et que j’indente) il le prend mais le résultat n’est pas bon.
type: custom:mushroom-chips-card
chips:
- type: template
entity: switch.clim_bureau
icon: mdi:air-conditioner
content: |
{% set entity = 'switch.clim_bureau' %}
{% if is_state(entity,'off') %}
Clim Bureau
coupée
{% elif is_state(entity,'on') %}
Clim Bureau
en service
# {% elif is_state('sensor.clim_bureau_puissance', > '2.0') %}
# Clim Bureau
# en fonction
{% else %}
Indisponible
{% endif %}
icon_color: |-
{% if is_state(entity, 'on') %}
light-blue
{% elif is_state(entity, 'off') %}
grey
{% else %}
red
{% endif %}
card_mod:
style: |
ha-card
{
white-space: pre;
{% set entity = 'switch.clim_bureau' %}
{% if is_state(entity,'on') %}
--text-color: rgba(0, 150, 200, 1);
{% elif is_state(entity,'off') %}
--text-color: blue-grey;
{% else %}
--text-color: red;
{% endif %}
{% if is_state(entity,'on') %}
--chip-background: rgba(225, 250, 240, 1);
{% elif is_state(entity,'off') %}
--chip-background: rgba(255, 255, 255, 1);
{% else %}
--chip-background: orange;
{% endif %}
}
tap_action:
action: perform-action
perform_action: switch.turn_on
target:
entity_id: switch.clim_bureau
view_layout:
position: main
ça fait 50 ans que je code depuis le Cobol et les assembleurs jusqu’au code des Arduino (pour lesquels je n’ai pas de soucis) mais là, avec le YAML j’en perds mon latin (qui lui remonte à 60 ans) 