[SOLVED] - How to get the daily figures out of the power meter sensor that are needed for a simple weekly chart day by day?

I have for every plug daily + weekly + monthly power meter sensors created.

I had thought that I could easily get a chart for a month with the daily consumption (Wh) of my IT plug and TV / Media plug from such sensor.

But I get sawtooth style pattern with the daily consumption growing from 0 to peak Wh which represents the consumption of that day.

but that sawtooth pattern looks horrible. I just want to see the one figure daily consumption just a second before midnight.
How can I achieve that ?
Deleting all the data points before 22:59 except the latest one of the day?

I have searched a lot but nothing seems to fit.

I am looking for a simple card with a few more features than the history chart.

thx for your support

2 Likes

I will check it out and let you know. Had a busy and long day just too tired to have a deeper look.

But thanks a lot for your reply.

It definitely does what you want. See this example too: https://community.home-assistant.io/t/daily-power-usage-using/315381/2

1 Like

I have not implemented it yet, just read about your comment and could recognice that the magic happens here

group_by: date
aggregate_func: max

Group by date will put all the data of 1 day into a stack / pile and search for the max, which then will be displayed. The job is done in the fronted and the sensors stay untouched.

What would the criteria be for group by hour, week, and month cause here it says date and not day which would not made me ask?
Cause after day week and month will be the next and in the beginning hour will be intereresting too at least for us.
thx.

You can group by day (date), hour, or interval. See here for more: https://github.com/kalkih/mini-graph-card#options

I would not recommend attempting to display anything longer than a week of grouped days as the amount of data your Lovelace frontend has to load quickly becomes large and may slow down the browser.

1 Like

I marked Troon’s post as the solution as he was the first to recommend this card.

1 Like

THANKS; I will try it in the evening just 2 am and too late or early to play around and create a mess. I am not in a hurry and I am convinced I will get it over the weekend. Looks beautiful on the github readme.

Do you know how that “interval” section should work ?

I have daily, weekly, monthly sensors and the only option date does not fit .
I just wanted a graph that showed me the weekly consumption over the past few weeks but that is not working by group = date cause I can see a growing figure over 7 days that then will be resetted and I did not want to see that daily, but for the whole week.

I hope you have an example cause I had been searching for intervall and could not find such an example.

thx

Honestly I’ve never used it. I only have a weeks worth of data stored in my Home Assistant database. I use InfluxDB and Grafana for long term stuff.

1 Like

apexcharts-card is similar to mini-graph but is more flexible, specifically regarding group_by interval

Random example of mine:

    - type: 'custom:apexcharts-card'
      apex_config:
        chart:
          height: 400px
      graph_span: 7d
      series:
        - entity: sensor.plug_xiaomi_1_meter_hourly
          type: column
          group_by:
            duration: 1h
            func: max
1 Like

Thanks,
i have apex already running and will give it a try now and let you know.

I tried to adopt it and replaced your sensor with mine but I got an error

Not sure what has been going wrong cause I simply replaced the sensor name and mad the spacing fit as your code seems to come out of a vertical stack or so, but I did not change anything else.
any ideas ?

Your code is misaligned. It should look like mine.

1 Like

Yes,
I finally killed it when I had pushed a command to align that went the wrong way.

I got what I wanted even though it seems to be a power monster cause it takes a lot of time or data to gather those data together, but at least a first chance to get an impression before I guess I have to move to influx and grafana for such tasks.

Here is the screenshot of that sensor for past 10 days or so and the last 2 weeks or the data that i have of these past 2 weeks.

Works like a charme and easy to play with like 1h or 24h or 2d and 10d or just 1w.

And of cause I like the scale / grid to get an understanding what those figures are without plotting a number on top of each bar.

thanks cause it helped me a lot to get an easy overview.

type: vertical-stack
cards:

  • type: ‘custom:apexcharts-card’
    apex_config:
    chart:
    height: 400px
    graph_span: 10d
    series:
    • entity: sensor.kwh_0_2_daily
      type: column
      group_by:
      duration: 1d
      func: max
  • type: ‘custom:apexcharts-card’
    apex_config:
    chart:
    height: 400px
    graph_span: 2w
    series:
    • entity: sensor.kwh_0_3_weekly
      type: column
      group_by:
      duration: 1w
      func: max

A Statistics graph set to bar chart would do this