Noob: How to create a sensor that sums up statistical values

Hello folks,

I’m new to HA and would like to learn how to program virtual sensors (I’m not sure I use the right word here) based on different statistical values of other sensors. In particular, to start with and start to learn, I’d like to summ the total rain of the last three days and use this value to feed a virtual sensor.

Now, I’ve learned that using the statistic card on the dashboard I can create a card that’l show me eg. total rain of one day, week or months in the past. Something like this:

type: statistic
entity: sensor.gw1100a_v2_2_3_total_rain
period:
  calendar:
    period: day
    offset: -1
stat_type: change

I’ve also learned, that if I put this eg. in the template editor it returns a total rain of all times back, so I am looking how to restrict this value:

{{ 
states('sensor.gw1100a_v2_2_3_total_rain')
}}

So, how am I to retrieve the data for day/week/month period with offset -1, -2 and -3 (like in the code of the card) and then them up and feed this value into a new template sensor (I think this is how this is called, when put into configuration.yaml).

Thx for any help with this topic and also for pointing me into direction of some noob “HA programming in the nutshell” guide.

Cheers,
zavjah