Energy consumption price based on spot price

Hi.

This is probably a newbie question. But my energy price is based on a spot price and changes every hour. I found an integration that provides this info in a form of a sensor. That works fine with the built-in energy dashboard where I just selected the sensor with the current price.

But I want to display the overall daily/weekly/monthly/yearly consumption also in the form of a numeric value. I track the daily/weekly/monthly/yearly energy consumption via a custom utility.

# Selfiehome energy
energy_house_usage_daily:
  unique_id: energy_house_usage_daily
  source: sensor.selfiehome_energy_spent
  cycle: daily  
      
energy_house_usage_monthly:
  unique_id: energy_house_usage_monthly
  source: sensor.selfiehome_energy_spent
  cycle: monthly 

energy_house_usage_weekly:
  unique_id: energy_house_usage_weekly
  source: sensor.selfiehome_energy_spent
  cycle: weekly  
      
energy_house_usage_yearly:
  unique_id: energy_house_usage_yearly
  source: sensor.selfiehome_energy_spent
  cycle: yearly

How can I calculate also the price? I have sensors for power consumption and also energy consumption (total, daily, weekly, monthly, yearly). Because I cannot simply multiply the ie daily energy usage with the price sensor because the price changes every hour. So I guess I would need something that takes hourly comsumption, mutiplies it with the price sensor and stores it somewhere and take the sum value for a day, week, monthl and year. But I am probably completely off and thinking about it wrong a too complicated.

See my postings in this topic.

First this

Links is to my last post where I updated my sensor so it actually works when you start from scratch