Apexcharts card - weekly sum on daily resetting sensor (PV Sigen)

Hi.

I have a sensor to indicate the energy delivered by solar panels. This sensor resets daily, but not always on an exact time I noticed. To plot my daily production in a graph I use func: max because the statistics database otherwise sometimes reports 0 at the end of a day.

  • entity: sensor.sigen_plant_daily_pv_energy
    name: Productie PV
    statistics:
    type: state
    period: hour
    group_by:
    duration: 1d
    func: max

Now I want to do the same for weekly production. So I want to make a sum of every weekday’s max. Any ideas?

A similar question: I could do the same for energy stored and consumed in a battery. I would like to plot the difference between both. So calculate the diff of the max per day