# Energy total of the last 365 days

I am not really interested in the energy consumption of the last day, week or month. It changes to much during the year and during the day.

What I really want to see is what happend the last 365 days. Or the moving average of that time. Is it going up or down is usefull information for me.

Is there any way to extract that information, to calculate it or to show it?

1 Like

Hi Dolleman,

Did you get this running? I was googling for exactly the same question and come to your message. Did you solve it?

Regards,

Bert

Energy Dashboard â€“ Calendar Icon â€“ This Year

You can then easily switch between years too.

Iâ€™m afraid that is not the solution.
This year gives you the energy used from januari 1st. And is increasing every day.
What I want is energy used the last 365 days.
That number should be constant from day to day.

You can download the data via the 3 dots menu now too, if you donâ€™t like how it displays it.

I think you are missing the idea, brooksben11 We want (correct me if Iâ€™m wrong, Dolleman) the an entity or counter on our dashboard that gives the usage in the last 365 days. So every day, the oldest day drops out the window, and a new day (yesterday) comes in. So is there a way to do e.g. the calculation â€śElectricity meter value of March 20th 2024 - Electricity meter value of March 20th 2023â€ť and display it in a card? And tomorrow it should show â€śElectricity meter value of March 21st 2024 - Electricity meter value of March 21st 2023â€ť, etc.

Regards,

Bert

Thereâ€™s not really any way to extract long term statistics into entities.

You could do this if you had the full years worth of data in your recorder, then you could create a statistics sensor that would give you the change over the last 365 days, but assuming youâ€™re keeping a reasonable purge window (~10 days), thereâ€™s no way to get an entity to show the change over the last 365 days, if that information is only in LTS.

Actually I guess a statistics card could show this on the frontend from LTS, but it canâ€™t be added to an entity.

That is correct @brjhaverkamp.
This number is a constant if your energy consumption stays the same.
If the number drops, you are saving energy, if it is rising you are using more.
The reason that I want this is that Iâ€™m not really interested in the absolute consumption. I want to know if the things I do are posive or negative.

Hi Dolleman,
Good news. It took a while, but I finally got it working! First of all, I needed to migrate my historical data from Domoticz to Home Assistant. No use trying calculating the past 365 days usage if you only have a month of data :-).
I got it working with a sql entity.
I currently have this in my configuration.yaml:

``````sql:
- name: electricity delivered 1 usage past year
query: >
SELECT
(SELECT statistics.state FROM "statistics"
ORDER BY created_ts DESC
LIMIT 1)-
(SELECT statistics.state FROM "statistics"