Secondary Info (last_updated) inside mini-graph-card

Hello

I am trying to render the "secondary_info: last_updated " inside the mini-graph-card.
Currently it looks like this:
image

I was able to add the last update row with the following:

type: custom:mini-graph-card
entities:
  - entity: sensor.shelly_h_t_754b21_temperature
    name: Temperature
hours_to_show: 12
points_per_hour: 2
color_thresholds:
  - value: 18
    color: '#8fce00'
  - value: 19
    color: '#f39c12'
  - value: 20
    color: '#d35400'
  - value: 21
    color: '#c0392b'
style: |
  ha-card .states.flex::after {
    color: #F2F2F2;
    content: "Last update: {{ relative_time(states.sensor.shelly_h_t_754b21_temperature.last_updated) }} ago";
    white-space: pre;
    background-color: rgba(50,50,50,0);
    padding: 5px 5px 5px 5px;
    border-radius: 5px;
  }

As you can see, i used the last_updated state of the sensor. The problem now is, that the UI does not live update this information the way the secondary_info attribute does. Is there a way to do render this secondary_info directly inside the graph card? Or any other way to update this value live?

Thanks

I guess this code was taken from here.
But in your case you do not need to specify “white-space: pre”.

Try to compare values of “last-changed” with a simple card:

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: sensor.cleargrass_1_co2
        name: Temperature
        secondary_info: last-changed
  - type: custom:mini-graph-card
    entities:
      - entity: sensor.cleargrass_1_co2
        name: Temperature
    hours_to_show: 1
    points_per_hour: 120
    style: |
      ha-card .states.flex::after {
        content: "Last update: {{ relative_time(states.sensor.cleargrass_1_co2.last_updated) }} ago";
      }

изображение
You should specify the “points_per_hour” value accordingly to the real scan_interval for this sensor.

1 Like