How to Sum Daily Energy Costs for Current and Previous Months

Hello everyone, I’m trying to figure out how to sum my daily energy costs into monthly totals using Home Assistant. I currently have my smart meter set up with the Octopus Energy integration, which provides daily cost data. However, I want to aggregate this data to get monthly totals for both the current and previous months.

I’ve tried using the utility meter integration, but I’m not entirely sure if it’s the right approach. Here’s what I’ve attempted so far:

yaml
utility_meter:
daily_energy:
source: sensor.octopus_energy_electricity_previous_accumulative_cost
name: Daily Electricity Cost
cycle: daily
monthly_energy:
source: sensor.octopus_energy_electricity_previous_accumulative_cost
name: Monthly Electricity Cost
cycle: monthly

This setup seems to track daily costs, but I’m not seeing the monthly totals I expected. I’ve also looked into using the history_stats integration for heating usage, but it requires a state value, which I don’t have for my energy costs.

Has anyone successfully set up something similar? Any advice or alternative methods would be greatly appreciated! I’d love to get this working to better track my energy spending over time. Thanks in advance for your help!