Statistics-Graph and utility_meter sensors

I have a bunch of sensors created by the utility_meter integration showing the daily/weekly/monthly usage of energy etc.

When i try to plot these on a statistics-graph card, the lines only appear if I plot them as a sum, but then the plot is for the constantly increasing use of energy, i.e. the same as the sensor from which the ultility_meter is derived, instead of the actual content of the sensor.

Is this working as designed? If so, what is the recommended method to plot the e.g. monthly energy use from my electricity utility meter which resets every month?

1 Like

Yes. The utility meter has state_class: total_increasing.

Energy dashboard. You don’t need to use any utility meters for that.

Thanks, but that’s my issue: I would like to create a personal version of the energy dashboard – essentially have something like the history of energy use for each class of devices in my home.

I have created template sensors summing the energy use of various device categories e.g. all the kitchen appliances. I would like to now have a bar chart showing the historical use of energy in the kitchen, and make a corresponding pie chart splitting the template sensor into the constituent devices (fridge, over, cooktop, etc).

I assumed that something like this was the goal of the statistics-graph card.

I’d use ApexCharts card - A highly customizable graph card for that.
This looks interesting, too: Anyone using the Sankey Chart Card? I haven’t yet tried it myself though. Also I don’t know whether it supports long-term statistics.

A bit of a tangent to your post here Statistics-Graph and utility_meter sensors but I’m playing on the same playground as you, in my case with a series of PoE ports.
I also created the group to sum up the usage of all ports, and I too am trying to plot the daily/weekly/monthly use of each port plus the of the sum of them all.

I even created a template to generate the integration and the utility_meters (here: Easily create monthly, weekly and monthly meters for multiple instant power sensors) and am trying to find a way to plot something like:

  • A graph for the last 7 days
  • A graph for the last X weeks
  • A graph for the last X months

I’ve tried a bunch of stuff but got nowhere.

Did you get anywhere ?

I noticed recently that the statistics graph can plot „change” which seems to do what is necessary: difference in the state between moments of time.

Personally I wanted up writing sql sensors for each of my energy meters which take the state from 30 days ago from the statistics database and subtract it from the current state and I plot these as pie charts for average energy use.

1 Like

would you mind sharing your solution / code here ?
I want simply to save the utility meter state at the end of month and then present monthly volumes on the chart

Hi

So I am not sure when this started working, but it seems it does in 2023.7 (probably I set it up in .5):
My chart is specified as this:

chart_type: bar
period: month
type: statistics-graph
entities:
  - sensor.cooking_coffee_consumed_yearly
stat_types:
  - change
days_to_show: 365
title: Coffee Consumed

In particular note the change stat_type. The sensor itself is a utility meter based on a counter which is increased using some automations. It is configured as:

cooking_coffee_consumed_yearly:
  source: counter.cooking_coffee_consumed
  name: "Cooking Coffee Consumed yearly"
  unique_id: "iutjrehoinwveyvweotow457tuthu"
  cycle: yearly

And the final result looks like


Hope this helps!

1 Like

I’ve written up in more detail how I track energy use using SQL sensors and accumulator templates here: