Use sensor value as name

Hi,

Is it possible to show the value from a sensor as the card name?
I tried some things but can’t figure it out…

type: custom:mod-card
card_mod:
  style: |
    hui-grid-card {
      background: rgba(10,10,10,0.4);
      padding: 0px 10px 10px 10px;
      display: block;
      border-radius: 20px;
    }
card:
  type: grid
  square: false
  columns: 1
  title: Zonnepanelen
  cards:
    - type: grid
      columns: 2
      square: false
      cards:
        - type: custom:mini-graph-card
          entities:
            - entity: sensor.envoy_122244026326_inverter_482235037056
              name: '[[[ return "Some text: " + states["sensor.envoy_122244026326_inverter_482235037056"].state; ]]]'
          show:
            labels: false
            name: true
            icon: true
            points: false
          hours_to_show: 6
          points_per_hour: 5
          animate: true
          height: 150
          lower_bound: 0

Templating is only supported by a limited number of cards.

Card-Mod uses Jinja templating, not the JS-style templating you have shown, but as far as I can see the Mini Graph Card does not support templating at all. However, if you use Card Templater the templated name will work.

type: custom:mod-card
card_mod:
  style: |
    hui-grid-card {
      background: rgba(10,10,10,0.4);
      padding: 0px 10px 10px 10px;
      display: block;
      border-radius: 20px;
    }
card:
  type: grid
  square: false
  columns: 1
  title: Zonnepanelen
  cards:
    - type: grid
      columns: 2
      square: false
      cards:
        - type: 'custom:card-templater'
          card:
            type: custom:mini-graph-card
            entities:
              - entity: sensor.envoy_122244026326_inverter_482235037056
                name_template: >
                  Some text: {{states("sensor.envoy_122244026326_inverter_482235037056")}}
            show:
              labels: false
              name: true
              icon: true
              points: false
            hours_to_show: 6
            points_per_hour: 5
            animate: true
            height: 150
            lower_bound: 0

Instead of placing the whole graph card into some other card, you may easily add any templated value to any element of the many-graph-card (like a name) by card-mod.
изображение
Go to card-mod thread → 1st post → link at the bottom → mini-graph-card → smth like “how to add additional info”.

Also, I know nothing about card-templater, but a similar config-template-card causes redrawing of the whole card when a monitored entity is changed. Hope that the card-templater does not do it, but anyway I would not place the whole graph into it just to add some additional info on the card.

1 Like

Thanks for the replies, I’ve managed to fix this in the template sensor as that would be the only option for me.

energie_solar_achter5_total_info:
  friendly_name: "max. {{ ((states('sensor.paneel_achter_5_max') | float )) | round(0) }}"
  value_template: "{{ ((states('sensor.envoy_122244026326_inverter_482235037071') | float )) | round(0) }}"
  unit_of_measurement: "kWh"
  icon_template: mdi:lightning-bolt
1 Like