# Statistics vs utility_meter

I am very confused on how to measure power usage. I have a shelly meter for a plug, it has 2 sensors _power with “raw consuption” and “_energy” which i guess will always grow.

Now i have created a “statistics” sensor like this:

``````sensor:
- platform: statistics
name: My Plus Stats
entity_id: sensor.shellyplug_0_power
state_characteristic: mean
max_age:
days: 30
``````

This should show the average consumption over the last 30 days but it shows 50W which would mean 36KWH per month, however this contradicts _energy values which says 1.2KW in one week of usage.

Then i tried to add a utility_meter to see daily and monthly usage:

``````utility_meter:
monthly_energy_usage_plug0:
source: sensor.shellyplug_0_energy
cycle: monthly
``````

Then when i try to use “sensor.monthly_energy_usage_plug0” HA simply says that there is no sensor so i cant show that info.

What am i doing wrong?

simple utility meter should do the trick.

Find the shelly counter that always grows, so that calculation is already done on the hardware level. It can be either one you mentioned, but it varies from platform to platform how the consumption is counted.

Once you figure which counter you are dealing with, create a utility meter, use the above mentioned counter as input sensor, set monthly reset cycle, determine if you are using delta values or absolute values (most likely the absolute ones, since you said it’s always growing) and that should be it.

It will start showing results within few minutes.

This is the explanation for `mean` in the documentation:

The average value computed for all measurements. Be aware that this does not take into account uneven time intervals between measurements.

So assume you have the data for 30 days, and the power has been 100W for one minute in those 30 days. The rest of that period the switch was off, and power usage was 0W.
In that case your `mean` result would still be 50W, as that is the result of `(0 + 100) / 2`

Thanks, now its clear, so this is totally useless for this specific case

This is what i did but sensor.energy_daily_plug0 is not populated even after a while

``````# History meter
utility_meter:
energy_daily_plug0:
source: sensor.shellyplug_0_energy
cycle: daily
energy_montly_plug0:
source: sensor.shellyplug_0_energy
cycle: monthly
``````