Quel type de carte pour capteur température + humidité?

bonjour , merci btncrd pour votre aide , voici le code.

type: custom:button-card
entity: sensor.plant_sensor_cb67_temperature
size: 5%
icon: mdi:sofa
show_state: false
show_name: false
label: Salon
show_label: true
styles:
  card:
    - position: relative
  grid:
    - grid-template-areas: " \"i i\" \"l l\" \"temp temp\" \"hum hum\" \"update heure\" \"apex apex\" \"graph graph\""
    - grid-template-columns: 50% 50%
    - margin-top: 2%
    - padding-bottom: 0%
  label:
    - font-size: 11px
    - font-style: italic
    - opacity: 75%
  icon:
    - opacity: 75%
  custom_fields:
    temp:
      - font-size: 26px
    hum:
      - font-size: 13px
      - font-style: italic
    link:
      - position: absolute
      - left: 15%
      - top: 5%
    battery:
      - position: absolute
      - left: 80%
      - top: 5%
    update:
      - justify-self: middle
      - align-self: middle
      - font-style: italic
      - font-size: 12px
      - opacity: 60%
      - margin-top: 10%
    heure:
      - justify-self: middle
      - align-self: middle
      - font-style: italic
      - font-size: 12px
      - opacity: 60%
      - margin-top: 10%
    apex:
      - position: absolute
      - top: "-2%"
      - left: "-15%"
      - width: 100%
      - height: 100%
      - "--ha-card-border-width": 0
      - "--ha-card-background": transparent
    graph:
      - margin-top: 0%
      - "--ha-card-border-width": 0
      - "--ha-card-background": transparent
custom_fields:
  temp: >
    [[[ var temp = states['sensor.plant_sensor_cb67_temperature' ].state; return
    `<ha-icon
      icon="mdi:thermometer"
      style="width: 18px; height: 18px; color: #7dc8ff ">
      </ha-icon>` + temp + '°'; ]]]
  hum: >
    [[[ var hum = states['sensor.plant_sensor_cb67_humidite' ].state;     return
    `<ha-icon
      icon="mdi:water"
      style="width: 15px; height: 15px; color: #7dc8ff ">
      </ha-icon>` + hum + '%'; ]]]
  update: |
    [[[
      return `<ha-icon icon="mdi:progress-clock" style="width: 20px; height: 20px;"></ha-icon>` + 
      ' Dernière M.A.J.';
    ]]]
  apex:
    card:
      type: custom:apexcharts-card
      chart_type: radialBar
      series:
        - entity: sensor.plant_sensor_cb67_temperature
          max: 40
          color: "#00FF00"
          show:
            legend_value: false
        - entity: sensor.plant_sensor_cb67_humidite
          max: 100
          color: "#FEFEFE"
          show:
            legend_value: false
      apex_config:
        plotOptions:
          radialBar:
            offsetY: 0
            hollow:
              size: 70%
            dataLabels:
              name:
                show: false
              value:
                show: false
            track:
              dropShadow:
                enabled: true
                top: 3
                left: 0
                blur: 4
                opacity: 0.25
              strokeWidth: 75%
              margin: 3
        fill:
          type: gradient
          gradient:
            type: vertical
            gradientToColors:
              - "#E73E01"
              - "#0F9DE8"
            stops:
              - 0
              - 100
        legend:
          show: false
        chart:
          height: 100%
  graph:
    card:
      type: custom:mini-graph-card
      name: Salon
      hours_to_show: 24
      points_per_hour: 1
      hour24: true
      line_width: 2
      decimals: 1
      entities:
        - entity: sensor.plant_sensor_cb67_temperature
          name: Temp.
          color: "#ffc04c"
        - entity: sensor.plant_sensor_cb67_humidite
          color: "#2a75cf"
          name: Humidité
          show_line: true
          show_points: true
          show_legend: true
          y_axis: secondary
      show:
        fill: true
        graph: line
        icon: false
        name: false
        state: false
        labels: false
        extrema: true
        average: true
        icon_adaptive_color: false
        labels_secondary: false
      align_icon: right
      align_state: left

Bonjour @droid

Pour régler ton problème tu dois changer les 2 valeurs suivantes :

  • Champs ligne 53 : “top: 0%” (au lieu de -2%) (Styles > Custom_fields > Apex > top) pour le positionnement vertical
  • Champs ligne 54 : “left: 0%” (au lieu de -15%) (Styles > Custom_fields > Apex > left) pour le positionnement horizontal

Cela devrait résoudre ton problème et recentrer la jauge.

...
    apex:
      - position: absolute
      - top: 0%    ### Tu peux jouer sur cette valeur pour descendre la jauge
      - left: 0%
...

Bonjour, @Sabjul33,

Tu as plusieurs options pour les mettre côte à côte :

  • Rajouter et adapter les options “grid" comme précisé par @Chris6729 :
section_mode: true
grid_options:
  columns: 4
  rows: 5

Dans la mesure où tu as des 3 sections, chacune doit faire 12 “columns” de large si je ne dis pas de bêtises donc si tu veux 3 cartes côte à côte : 12/3 = 4 columns (ou 12/2 = 6 columns pour 2 cartes côte à côte… etc.). Tu peux vérifier le nombre de colonnes par section dans l’onglet “Mise en page” quand tu crées une carte native de Home Assistant

  • 2ème solution tu contournes le problème en créant une carte de type “pile horizontale” et de là tu ajoutes autant de cartes que souhaité. Pas testé mais logiquement ça doit fonctionner

bonjour. il y avait déjà ces valeurs, c’est moi qui les ait modifier pour palier au décalage.

Bonjour,

Je regarde ça et je posterai un code pour l’affichage en mode section dès que possible.

EDIT : j’avais pas vu ta réponse @Integra, désolé :wink:

1 « J'aime »

@btncrd @Integra Merci je regarde ça, mais il me semble avoir tenter la pile horizontale.

Bonsoir,

Une version qui fonctionne avec le mode section avec ajout du changement de couleurs automatique en fonction du thème (clair ou sombre) :

J’ai fiabilisé les “if then else” en bornant les expressions (>= à valeur basse et < à valeur haute) et j’ai uniformisé les unités.

Code de la première carte (mode compact) :

type: custom:button-card
section_mode: true
grid_options:
  rows: 2
  columns: 6
aspect_ratio: 1/1
custom_fields:
  apex:
    card:
      type: custom:apexcharts-card
      chart_type: radialBar
      series:
        - entity: sensor.perron_thermometre_temperature
          max: 40
          color: "#00FF00"
          show:
            legend_value: false
        - entity: sensor.perron_thermometre_humidity
          max: 100
          color: "#FEFEFE"
          show:
            legend_value: false
      apex_config:
        plotOptions:
          radialBar:
            offsetY: 0
            hollow:
              size: 70%
            dataLabels:
              name:
                show: false
              value:
                show: false
            track:
              dropShadow:
                enabled: true
                top: 3
                left: 0
                blur: 4
                opacity: 0.25
              strokeWidth: 75%
              margin: 3
        fill:
          type: gradient
          gradient:
            type: vertical
            gradientToColors:
              - "#E73E01"
              - "#0F9DE8"
            stops:
              - 0
              - 100
        legend:
          show: false
        chart:
          height: 120%
  room:
    card:
      type: custom:button-card
      icon: mdi:home-thermometer
      label: Perron
      show_label: true
      styles:
        card:
          - background: transparent
          - aspect-ratio: 2/1
          - width: 122px
          - border: none
          - border-radius: 0
          - transform: translate(-50%,-50%)
          - pointer-events: none
          - cursor: default
          - z-index: 0
        icon:
          - width: 23%
          - color: var(--primary-text-color)
          - opacity: 75%
          - padding-top: 5%
        label:
          - font-size: 0.8rem
          - font-style: italic
          - color: var(--primary-text-color)
          - opacity: 75%
          - padding-bottom: 8%
  temp:
    card:
      type: custom:button-card
      icon: mdi:thermometer
      show_state: true
      show_name: false
      state_display: |
        [[[
          return parseFloat(states['sensor.perron_thermometre_temperature'].state).toFixed(1) + '°';
        ]]]
      layout: icon_state
      numeric_precision: 1
      styles:
        card:
          - width: 122px
          - font-style: italic
          - border: none
          - border-radius: 0
          - background: transparent
        icon:
          - width: 50%
          - color: "#7dc8ff"
          - padding-left: 20%
        state:
          - color: var(--primary-text-color)
          - opacity: 75%
          - font-size: 1.4rem
          - padding-right: 20%
  hum:
    card:
      type: custom:button-card
      icon: mdi:water
      show_state: true
      show_name: false
      state_display: |
        [[[
          return parseFloat(states['sensor.perron_thermometre_humidity'].state).toFixed(1) + ' %';
        ]]]
      layout: icon_state
      numeric_precision: 1
      styles:
        card:
          - width: 122px
          - font-style: italic
          - border: none
          - border-radius: 0
          - background: transparent
        icon:
          - width: 40%
          - color: "#7dc8ff"
          - padding-left: 25%
        state:
          - color: var(--primary-text-color)
          - opacity: 75%
          - font-size: 1.1rem
          - padding-right: 25%
          - padding-top: 2%
  link_quality:
    card:
      type: custom:button-card
      show_name: false
      icon: >-
        [[[ var link =
        states['sensor.allee_du_garage_thermometre_linkquality'].state;
          if (link >= 170)
            return "mdi:signal-cellular-3"; 
          else if (link >= 85 && link < 170)
            return "mdi:signal-cellular-2";
          else if (link >= 1 && link < 85)
            return "mdi:signal-cellular-1";
          else
            return "mdi:signal-cellular-outline";
        ]]]
      styles:
        card:
          - border: none
          - border-radius: 0
          - background: transparent
          - width: 30px
        icon:
          - width: 90%
          - color: "#7dc8ff"
  battery:
    card:
      type: custom:button-card
      show_name: false
      show_label: true
      layout: icon_label
      icon: |-
        [[[
          var entity = states['sensor.perron_thermometre_battery'];
          if (!entity || entity.state === 'unavailable' || entity.state === 'unknown') 
            return 'mdi:battery-alert-variant-outline';
          var battery = parseInt(entity.state);
          if (isNaN(battery) || battery < 1)
            return 'mdi:battery-alert-variant-outline';
          else if (battery <= 10)
            return 'mdi:battery-10';
          else if (battery > 10 && battery <= 20)
            return 'mdi:battery-10';
          else if (battery > 20 && battery <= 70)
            return 'mdi:battery-50';
          else
            return 'mdi:battery';
        ]]]
      label: |
        [[[
          var entity = states['sensor.perron_thermometre_battery'];
          if (entity && entity.state !== 'unavailable' && entity.state !== 'unknown') {
            return entity.state + '%';
          }
          return '';
        ]]]
      styles:
        card:
          - border: none
          - background: transparent
          - aspect-ratio: 2/1
          - border-radius: 0
          - width: 50px
        icon:
          - color: |-
              [[[
                var entity = states['sensor.perron_thermometre_battery'];
                if (!entity || entity.state === 'unavailable' || entity.state === 'unknown') 
                  return 'lightgrey';
                var battery = parseInt(entity.state);
                if (isNaN(battery) || battery < 1)
                  return 'lightgrey';
                else if (battery <= 10)
                  return 'darkred';
                else if (battery > 10 && battery <= 20)
                  return 'red';
                else if (battery > 20 && battery <= 70)
                  return 'orange';
                else
                  return 'green';
              ]]]
          - width: 100%
          - margin-left: 10%
        label:
          - font-size: 0.9rem
          - color: |-
              [[[
                var entity = states['sensor.perron_thermometre_battery'];
                if (!entity || entity.state === 'unavailable' || entity.state === 'unknown') 
                  return 'lightgrey';
                var battery = parseInt(entity.state);
                if (isNaN(battery) || battery < 1)
                  return 'lightgrey';
                else if (battery <= 10)
                  return 'darkred';
                else if (battery > 10 && battery <= 20)
                  return 'red';
                else if (battery > 20 && battery <= 70)
                  return 'orange';
                else
                  return 'green';
              ]]]
          - padding-top: 6%
          - padding-right: 15%
styles:
  card:
    - background-color: var(--card-background-color, rgba(28,28,28,1.0))
    - box-shadow: |
        [[[
          return (variables.theme === 'dark')
            ? '0 4px 12px rgba(0,0,0,0.3)'
            : '0 2px 8px rgba(0,0,0,0.1)';
        ]]]
    - cursor: default
  custom_fields:
    apex:
      - position: absolute
      - display: flex
      - justify-content: center
      - align-items: center
      - top: 50%
      - left: 50%
      - transform: translate(-50%, -50%)
      - overflow: visible
      - "--ha-card-border-width": 0
      - "--ha-card-background": transparent
    room:
      - position: absolute
      - top: 30%
      - left: 50%
    temp:
      - position: absolute
      - top: 50%
      - left: 50%
      - transform: translate(-50%, -50%)
    hum:
      - position: absolute
      - top: 65%
      - left: 50%
      - transform: translate(-50%, -50%)
    link_quality:
      - position: absolute
      - left: 3%
      - top: 2%
    battery:
      - position: absolute
      - right: 1%
      - top: 2%
variables:
  theme: |
    [[[
      return (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches)
        ? 'dark' : 'light';
    ]]]

Code de la deuxième carte (mode étendu) :

type: custom:button-card
section_mode: true
grid_options:
  rows: 2
  columns: 6
aspect_ratio: 1/1.6
custom_fields:
  apex:
    card:
      type: custom:apexcharts-card
      chart_type: radialBar
      series:
        - entity: sensor.perron_thermometre_temperature
          max: 40
          color: "#00FF00"
          show:
            legend_value: false
        - entity: sensor.perron_thermometre_humidity
          max: 100
          color: "#FEFEFE"
          show:
            legend_value: false
      apex_config:
        plotOptions:
          radialBar:
            offsetY: 0
            hollow:
              size: 70%
            dataLabels:
              name:
                show: false
              value:
                show: false
            track:
              dropShadow:
                enabled: true
                top: 3
                left: 0
                blur: 4
                opacity: 0.25
              strokeWidth: 75%
              margin: 3
        fill:
          type: gradient
          gradient:
            type: vertical
            gradientToColors:
              - "#E73E01"
              - "#0F9DE8"
            stops:
              - 0
              - 100
        legend:
          show: false
        chart:
          height: 100%
  room:
    card:
      type: custom:button-card
      icon: mdi:home-thermometer
      label: Perron
      show_label: true
      styles:
        card:
          - background: transparent
          - aspect-ratio: 2/1
          - width: 122px
          - border: none
          - border-radius: 0
          - transform: translate(-50%,-50%)
          - pointer-events: none
          - cursor: default
          - z-index: 0
        icon:
          - width: 23%
          - color: var(--primary-text-color)
          - opacity: 75%
          - padding-top: 5%
        label:
          - font-size: 0.8rem
          - font-style: italic
          - color: var(--primary-text-color)
          - opacity: 75%
          - padding-bottom: 8%
  temp:
    card:
      type: custom:button-card
      icon: mdi:thermometer
      show_state: true
      show_name: false
      state_display: |
        [[[
          return parseFloat(states['sensor.perron_thermometre_temperature'].state).toFixed(1) + '°';
        ]]]
      layout: icon_state
      numeric_precision: 1
      styles:
        card:
          - width: 122px
          - font-style: italic
          - border: none
          - border-radius: 0
          - background: transparent
        icon:
          - width: 50%
          - color: "#7dc8ff"
          - padding-left: 20%
        state:
          - color: var(--primary-text-color)
          - opacity: 75%
          - font-size: 1.4rem
          - padding-right: 20%
  hum:
    card:
      type: custom:button-card
      icon: mdi:water
      show_state: true
      show_name: false
      state_display: |
        [[[
          return parseFloat(states['sensor.perron_thermometre_humidity'].state).toFixed(1) + ' %';
        ]]]
      layout: icon_state
      numeric_precision: 1
      styles:
        card:
          - width: 122px
          - font-style: italic
          - border: none
          - border-radius: 0
          - background: transparent
        icon:
          - width: 40%
          - color: "#7dc8ff"
          - padding-left: 25%
        state:
          - color: var(--primary-text-color)
          - opacity: 75%
          - font-size: 1.1rem
          - padding-right: 25%
          - padding-top: 2%
  link_quality:
    card:
      type: custom:button-card
      show_name: false
      icon: >-
        [[[ var link =
        states['sensor.allee_du_garage_thermometre_linkquality'].state;
          if (link >= 170)
            return "mdi:signal-cellular-3"; 
          else if (link >= 85 && link < 170)
            return "mdi:signal-cellular-2";
          else if (link >= 1 && link < 85)
            return "mdi:signal-cellular-1";
          else
            return "mdi:signal-cellular-outline";
        ]]]
      styles:
        card:
          - border: none
          - border-radius: 0
          - background: transparent
          - width: 30px
        icon:
          - width: 90%
          - color: "#7dc8ff"
  battery:
    card:
      type: custom:button-card
      show_name: false
      show_label: true
      layout: icon_label
      icon: |-
        [[[
          var entity = states['sensor.perron_thermometre_battery'];
          if (!entity || entity.state === 'unavailable' || entity.state === 'unknown') 
            return 'mdi:battery-alert-variant-outline';
          var battery = parseInt(entity.state);
          if (isNaN(battery) || battery < 1)
            return 'mdi:battery-alert-variant-outline';
          else if (battery <= 10)
            return 'mdi:battery-10';
          else if (battery > 10 && battery <= 20)
            return 'mdi:battery-10';
          else if (battery > 20 && battery <= 70)
            return 'mdi:battery-50';
          else
            return 'mdi:battery';
        ]]]
      label: |
        [[[
          var entity = states['sensor.perron_thermometre_battery'];
          if (entity && entity.state !== 'unavailable' && entity.state !== 'unknown') {
            return entity.state + '%';
          }
          return '';
        ]]]
      styles:
        card:
          - border: none
          - background: transparent
          - aspect-ratio: 2/1
          - border-radius: 0
          - width: 50px
        icon:
          - color: |-
              [[[
                var entity = states['sensor.perron_thermometre_battery'];
                if (!entity || entity.state === 'unavailable' || entity.state === 'unknown') 
                  return 'lightgrey';
                var battery = parseInt(entity.state);
                if (isNaN(battery) || battery < 1)
                  return 'lightgrey';
                else if (battery <= 10)
                  return 'darkred';
                else if (battery > 10 && battery <= 20)
                  return 'red';
                else if (battery > 20 && battery <= 70)
                  return 'orange';
                else
                  return 'green';
              ]]]
          - width: 100%
          - margin-left: 10%
        label:
          - font-size: 0.9rem
          - color: |-
              [[[
                var entity = states['sensor.perron_thermometre_battery'];
                if (!entity || entity.state === 'unavailable' || entity.state === 'unknown') 
                  return 'lightgrey';
                var battery = parseInt(entity.state);
                if (isNaN(battery) || battery < 1)
                  return 'lightgrey';
                else if (battery <= 10)
                  return 'darkred';
                else if (battery > 10 && battery <= 20)
                  return 'red';
                else if (battery > 20 && battery <= 70)
                  return 'orange';
                else
                  return 'green';
              ]]]
          - padding-top: 6%
          - padding-right: 15%
  update_text: |
    [[[ return 'Dernière M.A.J.'; ]]]
  update_time: >
    [[[ return
    helpers.relativeTime(states['sensor.allee_du_garage_thermometre_last_seen'].last_changed);
    ]]]
  graph:
    card:
      type: custom:mini-graph-card
      name: Parents
      hours_to_show: 24
      points_per_hour: 1
      hour24: true
      line_width: 3
      decimals: 1
      entities:
        - entity: sensor.perron_thermometre_temperature
          name: Temp.
          color: "#2a75cf"
          y_axis: secondary
        - entity: sensor.perron_thermometre_humidity
          color: "#ffc04c"
          name: Humidité
          y_axis: primary
      y_axis: secondary
      show:
        fill: true
        graph: line
        icon: false
        name: false
        state: false
        labels: false
        extrema: true
        average: true
        icon_adaptive_color: false
        labels_secondary: false
        align_icon: right
        align_state: left
      font_size: 82
      height: 170
styles:
  card:
    - background-color: var(--card-background-color, rgba(28,28,28,1.0))
    - box-shadow: |
        [[[
          return (variables.theme === 'dark')
            ? '0 4px 12px rgba(0,0,0,0.3)'
            : '0 2px 8px rgba(0,0,0,0.1)';
        ]]]
    - cursor: default
  custom_fields:
    apex:
      - position: absolute
      - display: flex
      - justify-content: center
      - align-items: center
      - top: 25%
      - left: 50%
      - transform: translate(-50%, -50%)
      - overflow: visible
      - "--ha-card-border-width": 0
      - "--ha-card-background": transparent
    room:
      - position: absolute
      - top: 16%
      - left: 50%
    temp:
      - position: absolute
      - top: 26%
      - left: 50%
      - transform: translate(-50%, -50%)
    hum:
      - position: absolute
      - top: 33%
      - left: 50%
      - transform: translate(-50%, -50%)
    link_quality:
      - position: absolute
      - left: 3%
      - top: 2%
    battery:
      - position: absolute
      - right: 1%
      - top: 2%
    update_text:
      - position: absolute
      - top: 48%
      - left: 4%
      - color: var(--primary-text-color)
      - font-size: 0.85rem
      - font-style: italic
    update_time:
      - position: absolute
      - top: 48%
      - right: 4%
      - color: var(--primary-text-color)
      - font-size: 0.85rem
      - font-style: italic
    graph:
      - position: absolute
      - bottom: 0%
      - left: 0%
      - "--ha-card-border-width": 0
      - "--ha-card-background": transparent
      - "--primary-text-color": var(--primary-text-color)
variables:
  theme: |
    [[[
      return (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches)
        ? 'dark' : 'light';
    ]]]

@Sabjul33 peux-tu me dire si ça fonctionne pour toi ? Je suis en largeur 4 pour la section :

@btncrd

Je viens de mettre le code de la seconde carte c’est top, par contre concernant la taille :

j’ai 3 sections

avec le code j’avais la carte qui dépassait en hauteur.

J’ai modifié le code

grid_options:
  rows: 2
  columns: 6
aspect_ratio: 1/1.6

par

grid_options:
  rows: null
  columns: 5
aspect_ratio: 1/1.6

et là c’est bon.

Donc je pense que pour moi c’est ok.

Merci à toi…:flexed_biceps: