Summarized value of entity by day/week/month


I have a heatpump to heat a house and it gives me a summarized power consumption in kWh as you can see on graph below:

How can I make additional entities which will show me summarized energy consumption by last day / week / month (or customizable period of time if possible). I assume that statistics platform can be used for that but not sure how to use it. Also - about customizable period of time I assume that I could use two “date / time” helpers to indicate start and end date to be calculated by summarized entity.

OK - it was ultra simple and I’m stupid even asking this :wink:

sensor heatpump_energy_consumed_30d:
  - platform: statistics
    name: "Heatpump energy consumed last 30d"
    entity_id: sensor.recording_rcompressor
    state_characteristic: sum
      days: 30