Statistics Graph: Energy usage per hour in kwh in bar chart

I would like to have a statistics graph showing me how much energy was used during that hour in a bar chart. But whenever I add the card and point it towards a sensor outputting kwh, I can only show the summed value meaning I see it grow during the day.

For example; I have put the dryer power consumption (measured via a power plug) through the utility meter:

garage_dryer_energy_spent_hourly:
  source: sensor.garage_dryer_consumption
  cycle: hourly

When I check the state of this sensor:

state_class: total_increasing
source: sensor.garage_dryer_energy_spent
status: collecting
last_period: 0.48
meter_period: hourly
cron pattern: 0 * * * *
last_reset: 2022-06-30T06:00:00.166899+00:00
unit_of_measurement: kWh
device_class: energy
icon: mdi:flash
friendly_name: Garage Dryer Energy Spent Hourly

Basically I want the same type of graph of the energy dashboard, only for a specific device.

Since I can’t find a native solution I am now using ApexCharts to get what I want:

type: vertical-stack
cards:
  - type: entities
    title: Average Devices Hourly Consumption
    entities: []
  - type: custom:apexcharts-card
    stacked: true
    graph_span: 1d
    apex_config:
      legend:
        position: top
        fontSize: 14px
        itemMargin:
          horizontal: 10
          vertical: 5
    all_series_config:
      type: column
      unit: kWh
      float_precision: 2
      opacity: 0.7
      show:
        legend_value: false
      group_by:
        func: avg
        duration: 1h
        fill: zero
    series:
      - entity: sensor.garage_dryer_energy_spent_hourly
        name: Dryer
      - entity: sensor.garage_freezer_energy_spent_hourly
        name: Freezer
      - entity: sensor.garage_washing_machine_energy_spent_hourly
        name: Washing Machine
      - entity: sensor.kitchen_dishwasher_energy_spent_hourly
        name: Dishwasher

Still hoping this will be possible natively!

There seems to be a native solution! It’s currently not configurable via the UI, but it does exactly what I want. It’s the statistics card with stat_types state that does the trick:

chart_type: bar
title: Last 24 Hours
period: hour
days_to_show: 1
type: statistics-graph
entities:
  - sensor.garage_dryer_energy_spent_hourly
stat_types:
  - state

@TheNr1Guest how did you get it to show hourly use instead of summed value? I tried your code and also now you can select state as an option in the UI but I still get a summed value. Thank you!

@krkr Hmm, I have not upgraded to the latest version yet so I hope this is not something that changed. But the above code still works for me. Are you sure you are using a sensor reporting hourly values? So if you look at the sensor history, do you see it dip back to 0 every hour?

Thank you for your reply. Now, I believe it does not dip back to 0. At the same time, I have the same entity added to the Energy Dashboard and there I can see the energy use per hour.
Maybe it will help if I explain the use case. I am very happy with the Energy Dashboard. I recently started experimenting with adding not only a total energy use entity to it but rather showing the total enery split into several devices so something like heat pump energy consumption + fridge + freezer + other energy consumption - this adds up to the total energy consumption but shows it as a nice stacked graph. Since this setup required creation of new entities based on templates, I only have statistics for the past day. I like the option to compare energy use between days/weeks etc so I started wondering if I could re-create the total energy consumption graph and for this I need it to display an hourly use. Maybe I need another template where I state that the state of this entity resets every hour or so?
Either way, all of this is only a workaround. I would prefer to be able to add a nice stacked graph and keep the Energy Dashboard simple. I will try with the Apex card.

Hello!
I have a sensor that calculates the hourly exportation (positive) or importation (negative) amount of electricity to/from the grid, resetting every hour (Riemann integral).

I’d like to get the last value of this sensor before it resets in a bar chart, taking into account that I can have a value of 1.2 kWh at 12.30 but a value of 0.5 kWh at 12.59 (so I cannot use the max value).

Thanks!