Energy consumption for past period (last hour, last day, last week, last month) as entity

Hi,

Three months ago I started with HA and I’m glad to say that it’s a great tool for my smart home. Now I started with my new dashboard and wanted to create some cards with some energy consumption values in it.

That worked well till I got to energy consumption values from the past. I wanted to get values from the last hour, last day, last week and so on.

I have used the statistic-card to get those values in a card, but I wanted to have them as an entity to put them as a secondary_info in an entity-card (YAML). How does that work?

What I tried yet:

  • sensors in configuration.yaml with history_stats; but they just can do → count, ratio, time
  • helpers just work for daily, weekly, … consumptions. I used all of them for my cards and one for the total consumption as base.

I’m searching now for two weeks and cannot find the right solution. I can’t believe that there is no one for this „little“ problem.

Maybe someone can help me out with a hint or a link?

Thank you!

Hi,

You have to create your sensors and set it in apex-chart. This work for me.
My Data are shown for today, yesterday (complete week), month and year. In my configuration are three ways. Grid consumption, Mini - PV and energy in and out from my batteries.
Read this:

Apex-chart code:

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: Stromverbrauch Täglich
experimental:
color_threshold: true
yaxis:

  • id: left
    min: ~0
    apex_config:
    forceNiceScale: true
    series:
  • entity: sensor.hausstrom_taegl
    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

Screenshot:

Greetings :blush:

Thank very much! I tried it and it looks good.

But I want some entities to put them in the secondary_info in a card.

Something like this:

Maybe there is a way!

how about this:

type: vertical-stack
cards:
  - chart_type: bar
    period: day
    days_to_show: 30
    type: statistics-graph
    entities:
      - sensor.i_meter_mb_import_energy
    stat_types:
      - change
    title: daily
    hide_legend: true
  - chart_type: bar
    period: month
    days_to_show: 180
    type: statistics-graph
    entities:
      - sensor.i_meter_mb_import_energy
    stat_types:
      - change
    title: monthly
    hide_legend: true
title: Energy

actual effect:

Thank you!