Calculting Energy for 1h based on energy entity

Hi, i am struggling trying to understand how i can calcultae the energy kWh used during a period of time. I have some entities accumulating energy and i would like to make a difference between the current value and the value minus 1 hour or 1 day, in order to keep these hourly or daily values and be able to graph them for example.
Can someone give some examples to do that or some links to some examples ?
Thanks in advance.

But i found the creation of entities for public services, water, electricity etc… and apparently i can get the value each hour or day etc… So, maybe its a way to get that… Let’s see