Home Assistant and nice statistics graphs

One of the things that bothered me in for more than a year was the following: I couldn’t figure out why some entities/sensors can draw nice longterm statistics graphs like this (with average, max, min values):

home assistant statistics chart of outside temperature

and some show only bulky history charts (10 days of data) like this:

home assistant history chart of heat pump power

Today I learned I have to add state_class: measurement to my template sensor definition in configuration.yaml.

screenshot of home assistant sensor definition

That’s it! After I added this line (which I took from some example), and restarted HA, the sensor started showing statistics charts.

Disclaimer: I’m an amateur who is tinkering with Home Assistant only now and then since 2021. I have some background in programming – Basic, Java, C, C++, Perl, Python. I was a full-time programmer for approx. 7 years in 00’s. Yes, I read the official Home Assistant docs several times and I just couldn’t figure it out. I don’t know why I couldn’t figure out such a simple thing. Maybe I already dumbed down, or is it age-related or the docs are not so explanatory…


Posted

in

, , , ,

by

Comments

2 responses to “Home Assistant and nice statistics graphs”

  1. Jernej Virag :androidHead: Avatar

    @tomi Yeah, also remember that adding that state_class actually causes HASS to keep data around for longer.

    1. Tomi the Slav and 1024 others Avatar

      @jernej @tomi I swear I tried out all combinations of device_class and state_class until today with no success 🙂 I had pure luck today.

Leave a Reply

Your email address will not be published. Required fields are marked *