Daily, weekly and monthly data in Lovelace

Hi,

I’m having a good start with home assistant with lots of integrations and sensors. However I haven’t figured out what is to best way to display daily, weekly or monthly data on Lovelace. Currently I’m using mini-graph-card for 24-48 hour visualization of sensors.

I know that I could use Power BI or Grafana for visualizations but this time I would really like to have this on same dashboard on Lovelace.

I’m thinking for example following use cases:

  • Daily power consumption
  • Weekly runtime for TV and other appliances
  • Daily average outside temperature
  • Daily min and average for outgoing/incoming temp for floor heating
  • Daily heating energy

So far I have searched these forums a lot but haven’t seen any solutions so far. Usually people are asking for daily values for current and previous day, but I’m hoping to get something like 14 days of history to the same visualization.

2 Likes

You can only get this information if you store that much information. By default home assistant only stores 10 days. The more days you store, the slower history and logbook is (especially if you are on a pi).

You need to adjust your recorder to adjust the number of days.

https://www.home-assistant.io/components/recorder/\

You’ll probably want to change the default storage method to something better. By default home assistant uses an SQLite file to store it’s information. Personally, I use mariaDB and it improved performance.

But again, if you are running on a PI, no database will be fast. The more you store, the longer the lookups take. For example, when I was using a pi, 10 days of information took upwards of 30 seconds to display when going to the history tab. The more information you display in lovelace that uses history like graphs, the longer your display will take to load.

Thanks for the reply.

I’m running Hassio on Virtual Box with 4 cpus and also having external SQL Server for recorder. Currently I’m having something like 0,5 million lines on states table. I think that the performance is not the case here.

Anyway 14 days in daily values should be only 14 lines of data? Right? If that is not possible I’m ok aggregating those figures on the fly from detailed data but I’m still looking for the solution how to actually do it?

it will be 14 * number of data points per day. All sensors are different and poll at different rates. if you have something poll every second, that would be 1209600 lines of data. That’s probably worse case.

Anyways, to show data like that, use the custom mini-graph-card

I currently show a weeks worth of data and its pretty fast. The data on these sensors is polled every 3 minutes.

image

You are correct about the original data points. However by daily, weekly or monthly I’m talking about single value per day, week or month.

In your example, you are just showing original data for longer period. I trying to get some totals here by using aggregations. (on the fly or by using e.g. template sensor)

Something like in this example, where I’m showing daily consumption in kWh for tumble dryer:

image

1 Like

So you’d have to make those sensors and you’d need to adjust recorder to record longer than 2 weeks, which means you’ll record everything in the system longer than 2 weeks.

Unfortunately, you cannot record 1 item differently than others. It’s all or nothing.

It sounds like you should use Graphina and then use a IFrame card to display the info in HA.

So as a conclusion. There is now way to natively visualize such graph in Lovelace?

There is, but you have to store all the data that you want to display. Doing this through HA means you’ll store every entity for the duration you want to display. So if you want to display a years worth of data, you need to configure recorder to record a years worth of data.

Storing the data is not an issue. Do you have any examples how to display for example daily values?

well, that depends on what daily value you want.

Typically you’d use statistics or history statistics to create a new sensor that displays the info you care about. Then use that to display your data

I have the values ready. I just don’t know how to show only single value per day on Lovelace.

So you just want a bar on the screen? ALA this but vertical?
image

well anyways, lovelace is highly customizable. Anything you can dream up you can make. There isn’t a card that does exactly what you want but you could split your data up into 7 sensors and use either of these custom cards to make a ‘graph’.

Your other option is to make your own card that displays information in a bar graph format. I’m sure people would use it.

I had one example on my past messages for the requirement. Creating 7 sensors only to show past 7 days is not an option. I would rather go with Power BI.

Seems like I struck a nerve with you. Good luck.

old topic to resurrect, but I think OP might like mini-graph-card: https://github.com/kalkih/mini-graph-card
it has binning options to show for example 24 bars of 1 hour each, even if the source sensor updates every minute etc.

2 Likes

Did you get anywhere with this in the end? I would like to achieve something similar. Simple daily aggregations would be nice.

Hi,

One year and 30 million state records later I have got separate DW database where I load new records each night. Then I use Power BI to do some analysis out of that data.

I have only 5 days of data in main “operative” db for Home Assistant. With mini-graph-card (like tbrasser also mentioned) I can directly see daily aggregates for most values. For some cumulative sensors I’m using SQL sensor which is updated then by automation after each midnight. However those are also limited to 5 days on UI which I have on same db.

At the bottom line, my assumptions for HA was fundamentally wrong. It is not an analysis platform where you could compare current weeks electricity consumption to same week last year. Instead it is the engine which keeps collecting the data from sensors and keeps your house and automation running. For long term, high level analysis you need to find something else as supplement.

2 Likes

Stats and history is a bit messy in HA for me.
Default recorder settings includes 10 days of data. What puzzles me is why I can see 10 WEEKS of data in history.
I selected Jan 1st to Dec 31st. Graph shows me Nov 7th to Dec 31st.
Today is Jan 16th and Nov 7th is 10 weeks ago.
I have Influxdb installed and configured, but I doubt HA History is taking data from Influxdb instead of the (default) config from the recorder.
Anyone knows what’s happening here?