Aggregate a Current Sensor data for per day and per month, and then reset for the next month

Hi All
I have a current transducer measuring my incoming mains power. It can measure in W and Total (continuous) Kwh.
My goal is a Lovelace Bar Graph Card to map each total for each day of the week and show the weekly total.
And then to also have a daily bar graph with the monthly total displayed

I have no idea where to start collecting data, aggregating it, and displaying it.

Anyone able to point me in the right direction would be greatly appreciated…

To start, create two utility meters for your total energy sensor. One with a daily cycle, one with a monthly cycle.

To graph these you can use Apex Charts:

Screenshot 2022-10-02 at 03-41-36 Overview – Home Assistant

type: custom:apexcharts-card
apex_config:
  chart:
    height: 140%
  dataLabels:
    background:
      enabled: false
    style:
      colors:
        - var(--primary-text-color)
graph_span: 1w
span:
  end: day
header:
  show: true
  title: Daily Energy (Offpeak)
experimental:
  color_threshold: true
yaxis:
  - id: left
    min: ~0
    apex_config:
      forceNiceScale: true
series:
  - entity: sensor.energy_hot_water_daily_offpeak
    type: column
    yaxis_id: left
    float_precision: 2
    show:
      datalabels: true
    group_by:
      func: last
      duration: 1d
    color_threshold:
      - color: '#e45e65'
        value: 3.5
      - color: '#e0b400'
        value: 3
      - color: '#0da035'
        value: 2.5
      - color: '#039BE5'
        value: 0

There’s also the mini-graph card that does the same thing but has a simpler style:

Screenshot 2022-10-02 at 03-42-28 Overview – Home Assistant

aggregate_func: last
color_thresholds:
  - color: '#e45e65'
    value: 0
  - color: '#039BE5'
    value: 12
  - color: '#e0b400'
    value: 18
  - color: '#0da035'
    value: 24
color_thresholds_transition: hard
entities:
  - sensor.energy_inverter_daily
group_by: date
hour24: true
hours_to_show: 168
name: Daily Energy
show:
  extrema: true
  fill: fade
  graph: bar
  labels: false
smoothing: false
lower_bound: 0
type: custom:mini-graph-card
2 Likes

Looks to be working perfectly, thank you! Was not aware of the utility meter helper.

Just one thing, should I be using the W input (which is just the current Current at that sample), will it totalise?
Or I have another feed on the sensor that reports kWh, should I rather use that?

Or is my sensor meant to have a totaliser (absolute - incremental) feed?

Or am I over thinking this, lol.

Only use the kWh (energy) sensor. The one that always increases.

Thanks so much, really appreciate it.

Thanks again.