Hourly average energy consumption - not graph

Sorry for this nob question. I am looking into how (if possible) to make a sensor that as attributes has the average hourly energy consumption for the last rolling 5 - 14 days. I’m stuck at even retrieving the data from 2 hours ago.

I have a energy sensor summing the total energy consumption with an hourly utility meter. I could of course set up 24 trigger sensors I guess and then somehow adding them up over time, but that seams to be a bit “overkill”.

  - platform: integration
    source: sensor.power_house_load
    name: "Energy House Load"
    unique_id: energy_house_load
    round: 6
    unit_prefix: k
    unit_time: h
    method: left
  hourly_house_load_energy:
    source: sensor.energy_house_load
    name: "Hourly House Load (Energy)"
    cycle: hourly

I have been looking into the history stats, but can’t get my head around on how to get the data I would like. Appreciate any help and/or pointers.

maybe statistics is what you’re looking for?

Thanks Krivatri. Yes I was looking at these as well (and maybe more appropriate than than the history stats). But how do I define a statistics sensor for a certain hour?

I’m sorry, I have never used statistics before, so I have no idea unfortunately.