Average of Energy Consumption

Hey,
I am trying to get an entity, that gives me the daily average of energy consumption of the past week.

I searched a lot and found many articles, but not one helped me especially in this case

I have an entity for power consumption and need to build and entity, that gives me the value of power consumption exactly 7 days ago from now (no defined time)

So I could calculate the difference between the value of 7 days ago and the actual to get the consumption of the last 7 days at total.

I hope I described the problem correctly.

Thanks and best regards

EDIT: my previous answer here did not fit, because I realized you might mean something else. First, make sure we’re on the same page on power vs energy. They are different things, but you use both words as if they mean the same.

Are we talking kWh values, or kW? kWh makes more sense, but is a bit harder. That is because the day value is only fully known the day after. So you want to average one kWh usage value per day, seven days, always counting from yesterday?

You also ask for the day value 7 days ago (I assume the same weekday as today) - that is something different. Also note that day is part of the average, because the average cannot make use of consumption for today.

Can I ask what you mean to accomplish by comparing these values? There may be easier ways to reach the goal.

Hey Erwin_D,
thanks for the quick reply.

I mean the consumption in kWh, sorry.
I want to get the daily average of the consumed energy in kWh for the last 7 days. My idea was the following:

I have an entity that gives me the power consumed (kWh) in total.

  • Get the value of power consumed (kWh) from last week (or from now minus 7 days)
  • Get the value of power consumed (kWh) now
  • Devide the difference of values above by 7

If you know a better solution for that, I would be happy :wink:

Hey there,
for everyone who needs it, I was able to get my value I needed:

sensor:
- platform: statistics
unique_id: haus_ov_verbrauch_7d
entity_id: sensor.haus_ov_energie
name: “Energie Haus oV letzte 7 Tage”
state_characteristic: change
max_age:
days: 7

sensor.haus_ov_energie (in kWh) is an integral sensor, taken from the Watt going to the house.