How do the math to calculate how much I spend on energy

Hello,
I configured the Utility Meter reflecting my energy contract creating entities for a daily, monthly and bimonthly cost.

utility_meter:
  daily_energy:
    name: "Energia giornaliera"
    source: sensor.total_energy
    tariffs:
      - F1
      - F2
      - F3
  montly_energy:
    name: "Energia Bimestrale"
    source: sensor.total_energy
    cycle: monthly
    tariffs:
      - F1
      - F2
      - F3
  bimontly_energy:
    name: "Energia Bimestrale"
    source: sensor.total_energy
    cycle: bimonthly
    tariffs:
      - F1
      - F2
      - F3

Then I created the automation which assigns the right tariff based on time of the day.
Now I would like to track the cost I pay per day/month. If I understand well I have to use a template to do the math creating new entities. Right?
But when I should do the math? Maybe I need to use offset or cron to have a known and exact time when my entities reset themselves and them at midnight (or a second before) do the math…

Sorry but I’m a little bit confused and I would need some suggestions.

Thanks