Difference between a sensor at two different times

Hello I have a sensor who give me my consuption in KWh but it’s a cumultative sensor.
[sensor.aeon_labs_zw095_home_energy_meter_gen5_energy_4]

How it’s possible to keep the value at midnight of this sensor - actual value of this same sensor now
idem for weekly monthly and yearly if possible ?

I think the utility meter integration is what you are looking for.

How about using derivative.

I use it to calulate the active power averaged over 1 minute, it should work for 24h as well.
You could then get a value at a fixed time every 24h.

- platform: derivative
  source: sensor.current_summation
  name: current_summation_derived
  round: 3
  unit_time: h
  unit: kW
  time_window: "00:01:00"