Create a Template Sensor plus History Stats sensor. Add Utility Meter sensors for long-term fata (daily/weekly/monthly/yearly).