Long Term Statistics Missing / Not Working

I have seen a few posts on this but even with offered solutions I can’t get my head around what’s missing.
I want to use the Statistics Graph Card but I always end with “No statistics found” instead of a chart.

Here is my sensor config:

- platform: mqtt
  name: "Master Bedroom Temperature"
  state_topic: "zigbee2mqtt/master_bedroom_hygro"
  value_template: "{{ value_json['temperature'] }}"
  unit_of_measurement: 'ºC'
  device_class: temperature
  state_class: "measurement"
  # last_reset_topic: "zigbee2mqtt/master_bedroom_hygro"
  # last_reset_value_template: '1970-01-01T00:00:00+00:00'

(I’ve tried with and without commenting the last 2 lines)

Here is my lovelace card:


  - type: statistics-graph
    title: 'Temperature'
    days_to_show: 30
    entities:
      - entity: sensor.master_bedroom_temperature

What am I missing pls?

Try changing this

to:

unit_of_measurement: '°C'

Thanks Tom. I’ve made the change and nothing is changing for now. I’ll wait a couple of hours in case that’s what it takes for the data to be stored for long term statistics to show up.
Do I actually need the botton 2 commented out lines to be commented or not ?

These are the attributes of a temperature sensor I just tested as working with the statistics graph:

state_class: measurement
unit_of_measurement: °C
friendly_name: Comms Cupboard Temperature
icon: mdi:thermometer
device_class: temperature

So no, they should not be required.

Thanks. I’m still not getting anything.
Are you using an MQTT sensor or other?
Is there a limitation in the number of long term stats sensors?
I have it working well with my current consumption sensor, but for some reason I can’t see to be able to add any MQTT sensors to the statistics chart.
I’ve also tried to create a template sensor to basically clone the MQTT one to no avail

That one was an ESPHome sensor. I just tried an mqtt sensor (from zigbee2mqtt) it worked too.

Here are its attributes:

state_class: measurement
battery: 91
contact: true
linkquality: 39
temperature: 9
voltage: 2985
unit_of_measurement: °C
friendly_name: Lane Gate temperature
device_class: temperature

Not that I know of.

Try adding a friendly_name attribute. It’s the only thing I can see that is different.

this is not supported for a Template sensor nor for an MQTT sensor:
Invalid config for [sensor.mqtt]: [friendly_name] is an invalid option for [sensor.mqtt]
So I’m at loss now now as I can’t understand why it’s not working.
I might try and rewrite everything again in case there’s another wonky formatting issue somewhere, I’m thinking dos2unix style issues, would not be the first time. At least you’ve confirmed it should work :+1:

Add it using customize. All entities support adding it that way.

Thanks. There is something that’s not right and I just can’t puyt my finger on it. Thanks for your help anyway

Hi there,
I seem to have the same issue, i am using mqtt to register some sensors running on esp32 devices.
I added state_class and set to “measurement” which made my sensors appear in the new card, but i also never get anything else than no statistics found.
This is the config that i can see for e.g one of my temp sensors:

device:
  name: mista-buttons
  manufacturer: tobias stanzel
  identifiers: mista-buttons-01
  model: mista-buttons-01
unique_id: temp_sensor_mista-buttons
state_topic: homeassistant/sensor/mista-buttons/temp_sensor_mista-buttons/state
name: Temp Sensor Buttons
unit_of_measurement: °C
state_class: measurement
last_reset_topic: homeassistant/sensor/mista-buttons/temp_sensor_mista-buttons/state
last_reset_value_template: '1970-01-01T00:00:00+00:00'
platform: mqtt

Just a guess but might it be because I register the sensors via an mqtt topic and not via the config file?

Ok too fast, after postig this the card started to show some data :wink: