Utility Meter - Display Values from previous day

Hi.

I’m using utility meter to track daily and monthly electricity usage.

I’d like a way to display the last value from the previous day / month before the period was cycled so that, for example, I can see a quick comparison between today’s value and yesterday’s.

Is there a way of displaying each of these in an entity card as that is what I am using to show the current values?

Thank you

How about a daily graph like this?

Screenshot_2020-06-08 Overview - Home Assistant

It uses the custom mini-graph card.

aggregate_func: max
color_thresholds:
  - color: '#e45e65'
    value: 7
  - color: '#e0b400'
    value: 5
  - color: '#0da035'
    value: 3
  - color: '#039BE5'
    value: 0
color_thresholds_transition: hard
entities:
  - sensor.total_cost_today
group_by: date
hour24: true
hours_to_show: 168
name: Daily Energy Cost
show:
  fill: fade
  graph: bar
  labels: false
smoothing: false
type: 'custom:mini-graph-card'
4 Likes

That is perfect Tom.

Thank you

Your recorder must be set up to retain at least 7 days data. The default is 10, so if you have not changed it you’re good.

Hi

Do you have any idea how to represent the same but by month (means 12 bargraph which represent Spent by month). Thanks

Regards

Not exactly. Because some months have 31 days, some less and we can only define the number of hours to show. This will display 30 days.

hours_to_show: 720

You need to keep 30 days worth of data in the recorder setup.

Thanks for that quick answer.
If I put 720, I will get the 30 days as below, but what I need is 12 Bar (1 per month). I really don"t know how to do. I tried with InfluxDB+Grafana, but i’m stuck also

image

You can only group by interval, hour or date. Not month.

Also I would advise you to not use the mini graph card to display a years worth of data and to not store a years worth of data using the home assistant recorder.

Watch frenk’ s tutorial on setting up influxdb and Grafana for long term data storage:

I’m storing already in InfluxDB and also in MariaDB trying to find a way to have Monthly Barchart, but with both I didn"t succeed on how to do
I will look at your video in case it could gave me some Query idea on those DB to be able then to display the extracted data in BarChart (in Grafana for example)

Considering my long duration data storage present already in InfluxDB & MariaDB , do you have any idea on how to represent them in such Monthly Bar Graph ?

Hello I’m back on that topic
is someone find a way to represent its sensors values already stored in a DB (whatever if InfluxDB, MySQL or MaiaDB) into a BarChart ? (I’m open to use Grafana if required, but even with Grafan, I didn"t find any splution to GROUP by MOnth).
My need is just to represent by Power Consumption data per month into a BarChart

P.S : Searching on the web I found that TimeScaleDB allow to have Group by Month fetaure. Is this perhaps the solution ? Is one of you ever try this ?

Thanks

I use Postgresql for my recorder database, there it is very easy to do the kind of grouping I think you want. I googled similar for SQLite with is the build in database for HA’s recorder and it looks like it is straight forward to do the same in the native DB, one example from StackOverFlow:

select SUM(transaction) as Price, 
       strftime("%m-%Y", transDate) as 'month-year' 
       from transaction group by strftime("%m-%Y", transDate);

You could then use the HA SQL sensor to create a sensor value for the prior month:

But this would be one month per sensor, not what you want I think.

So if, as it sounds like you are willing to do, you need to visualize your data outside of HA. Yes Grafini/Influx, Timescale are solutions. But they require a fairly heavy learning curve.

I would recommend using the iPython/Jupyter package that the Home Assistant folks setup awhile ago. I use Juypter, which is basically python and great data visualization. Yes, you have to do some Jupyter and matplotlib learning. But this is much more similar to the core HA stuff. And there is a very large body of knowledgeable folks with a google search for help and ideas:

Home Assistant Data Science Portal

some bar chart example helpers:



https://towardsdatascience.com/building-bar-charts-using-matplotlib-c7cf6db3e728

I think if you take a little time to learn basic Jupyter, Pandas and Matplotlib, you will be able to do a lot with your HA data quickly.

FYI, so I use Postgresql running beside my HA system, each in Docker containers. Then I have another container with is a prebuild Jupyter datascience stack running parallel to these two. HA writes its data to the Postgresql database just like it does with the native Recorder database. Then I can query the Postgresql database with from the Jupyter container with no concern about being in the HA space. It’s solid. This is very similar to the stock HA Data Science Portal, except by using docker, I keep my HA, database and data science stuff isolated from each other. Make for less chances of messing up between them. Here is the link to the Jupyter data science docker stack, it is very functional:

https://jupyter-docker-stacks.readthedocs.io/en/latest/

Start simple with the HA Data Science stuff I referenced above.

Good hunting!

Thnaks a lot @dproffer for that very detailed answer.
I will have a look on this but seems I will have to learn and invetsigate a lot to build this…
Let’s try. I’ll keep you informed if I succeed.

I am pretty much pleased with your good work. You put really very helpful information!