Statistics graph card not showing template sensor

Apologies if this has already been flagged, I searched and couldn’t see a report.

I am trying to get a template sensor to display in the statistics graph. It’s an average of 4 other temp sensors.

I’ve tried both of the following sensor configs and neither work with the statistics card, they don’t show in the Lovelace list and if added manually to the yaml, just don’t display. They both work with the graph and entity cards though.

The sensor code matches the home-assistant documentation like so:

template:
  - sensor:
      - name: "Average temperature"
        unit_of_measurement: "°C"
        state: >
          {% set bedroom = states('sensor.bedroom_temp') | float %}
          {% set kitchen = states('sensor.kitchen_temp') | float %}

          {{ ((bedroom + kitchen) / 2) | round(1, default=0) }}

And I tried a min_max like so:

sensor:
  - platform: min_max
    name: minmax_temp
    type: mean
    entity_ids:
      - sensor.ble_temperature_kitchen
      - sensor.ble_temperature_lounge

The card looks like (Note lounge and kitchen work, average and monmax do not)

- chart_type: line
        period: hour
        days_to_show: 2
        type: statistics-graph
        entities:
          - sensor.ble_temperature_kitchen
          - sensor.ble_temperature_lounge
          - sensor.average_temperature
          - sensor.minmax_temp

Anyone able to see why?

You need to add a state_class for long term statistics to be calculated.

template:
  - sensor:
      - name: "Average temperature"
        unit_of_measurement: "°C"
        state_class: measurement
        state: >
          {% set bedroom = states('sensor.bedroom_temp') | float %}
          {% set kitchen = states('sensor.kitchen_temp') | float %}

          {{ ((bedroom + kitchen) / 2) | round(1, default=0) }}

If using the min max integration you will have to use customize to add it.

1 Like