Creating reports from an entity’s history

The other day I noticed Bandit is getting a little tubby. I might not have noticed had I not just watched him swallow his dinner in 2 bites. But I did, so I wanted to see how his weight has changed over the year. We have a LitterRobot which automatically cleans the litter. It also measures the cat’s weight. The LR has an app that has reports. Long story short, the app sucks.

However a LitterRobot integration exists, so HA to the rescue. From this integration I have sensor.bandit_weight. This value gets updated every time he enters the unit, so maybe 2-5 times a day. Maybe more if he’s been on the catnip. I got the robot at mid-March, so that’s how far the data goes back.

So I go to the sensor’s History page and I see his weight in a chart. I assume I can customize this “report” and also assume there is a YAML equivalent. Just to test these, I changed the date range from 5/1/25-5/15/24. I then clicked the 3 dots and did a “Add current view as card”. I went to the view in question and the chart the card showed me was completely different from what I used to create the card’s YAML and. The card’s YAML:

title: History
type: history-graph
hours_to_show: 355
entities:
  - sensor.bandit_weight

So it seems when saving a view, it doesn’t take a date range. My initial assumptions were wrong. I don’t know why my date range got butchered into hours_to_show. Is this because of the way sensor data is stored?

  • On a slight tangent, please forgive me, but someone here is likely to know the answer. HomeAssistant is like other applications in the way they sometimes displays data, especially for dates. They use “a day ago” “a few minutes ago”, “last week”, etc. WHY?!?

Regardless the “add current view” function is flawed. What is added to the dashboard is not what the current view was.

So what am I asking for? I’m not even sure anymore. I want to be able to use the sensor history to generate reports. Like show the average weight per week. Over a specific time period. Maybe I’m asking too much for HA. Exporting to Excel should give me most of this.

Another thing I want to do is look for trends. I want to be notified if something is not normal. Each weight record is considered a “visit”. I want to be informed if the number of visits per day deviates from the norm. Maybe there’s a HACS gadget that does higher math.

I just don’t want to reinvent the wheel.

The cards used in dashboards have their own unique settings specific to the card you are using. Those settings have absolutely nothing to do with how HA stores data. For a history graph card, those settings are defined here. If you don’t want a card that shows X number of previous hours of data, then use a different card. There are many other cards you can choose from, both built into HA as well as custom ones that can be downloaded.

And about how HA stores data: you will want to become familiar with the states table and the statistics table in the recorder database. HA will store the history of every state change of every entity for 10 days if you use the default settings (recorder docs). That is the states table in the database. For certain entities which are configured appropriately, hourly statistics will be calculated and retained indefinitely. That is the statistics table in the database. I strongly advise reading this article on the statistics that HA stores.

When you view a history graph that shows data older than 10 days (or whatever you have purge_keep_days set to), the older data is pulled from the statistics table and is shown in a lighter color and will not have any finer resolution than hourly updates. For your cat’s weight sensor (which probably only updates a few times a day anyway) you probably won’t notice the difference. But for (for example) a temperature sensor that changes every few minutes, you will notice a difference in the history graph when the data suddenly gets “smoother” as it gets older.

Don’t confuse how certain cards on a dashboard display dates with how HA handles and stores dates. Again, different cards show things differently. If you have an entity with a device_class set to timestamp then some cards will show a human-friendly relative time like your examples, but other cards will display the state as-is (e.g. 2025-07-02T00:03:17+00:00) and some others will show it in some other friendly date format. You get to choose based on what card you use and what settings you choose for that card.