Utility Meter power graph

Apologies for my slow response rate. Hopefully I’ll be more attentive to the email notifiers going forward :slight_smile:

I would like to ask about this, the kWh is like that it consumes 3000W right now or that it consumed like 1500W during 1 hour when it was half of the time off (3000W appliance)?

Watt Hours (Wh) is a measurement of “momentary” power over time (aka energy consumed). A machine that draws 3000W (“momentary” power) over 1 hour has consumed 3000 Wh (=3kWh).
And as you point out, a 3000W machine that was turned on only 30 minutes in the last hour will have consumed 1500Wh during that time. Of course, some machines can also run on a fraction of the maximum power. Thus a 3000W machine running at 50% load (=1500W) for 1 hr will also have consumed 1500Wh. If it ran only 30 minutes at 50% it will have consumed 1500W x 0.5h = 750Wh.

The sensors provide me how much it draws “W” when it refreshes when I turn it off, then it shows 0W immediately.

The statistics that you posted earlier show that during the observed time period your machine drew power between 714W to 2366W at an average of ~2280W. Because the average is close to the max, and the standard deviation is low, I’d say that it probably ran at a more or less constant load most of the time with minor fluctuations. The 714W were probably measured at the beginning or end when the machine was ramping up and down.
Remember, Power (W) is only a momentary snapshot of the power draw. So if the machine continuously increased the power draw in the first few seconds of being turned on until it reached its full load, you might get some measurements of anything between 0 and 23xx W during that time.

You should be able to look at a graph over the sensor data in order to understand how the machine behaves.

Unfortunately, the refresh time is quite random, mostly it’s about 1 minute. Sometimes it refreshes once in a minute, like 6 refreshes every second and then 1 minute of pause.

It’s possible that the device adjusts its reporting interval based on how often (or how much) the power draw has changed. Which is good because it will provide higher accuracy but avoids generating heaps of data/messages when it’s not necessary (e.g. power machine sits idle).

The way you would calculate the energy consumption (Wh) is to look at every data point in your sequence, and calculate the Wh for the “time slot” between the current measurement, and the previous based on the timestamps:
Power (W) x (Timestamp - TimestampOfPreviousDataPoint) (h) = Wh.
E.g. 2310 W x (3s / 3600) h = 1.925 Wh.
(The time in the example is 3 seconds converted to hours.)

Then you add up the calculated Wh for all of your data points in the sequence, and you will have your (estimated) energy consumption over the entire time period.

I think that’s what the integration component (Integration - Riemann sum integral - Home Assistant) does for you!

Thank you a lot for helping me, here is what I have done.

sensor:

  - platform: integration
    source: sensor.sonoff_power
    name: nove
    
utility_meter:
  hourly_energy:
    source: sensor.nove
    cycle: hourly
  daily_energy:
    source: sensor.nove
    cycle: daily
  weekly_energy:
    source: sensor.nove
    cycle: weekly
  monthly_energy:
    source: sensor.nove
    cycle: monthly
  quarterly_energy:
    source: sensor.nove
    cycle: quarterly
  yearly_energy:
    source: sensor.nove
    cycle: yearly

When I started it, it jumped right to 350Wh and then it seemed to work ok. I calculate how much it should consume in a minute after a few minutes the integration matched my calculations.
The following morning I was surprised that it was not working as I thought it would be. You sen see it on the graph.

The “nove” is this integration:


When the load was applied at 5:00 it jumped from 3500kW fo 6500kW
I must be missing something right ?

thats weird jumps indeed, since you want kwh you should add unitprefix, right? Can you post the sensor code?

  - platform: integration
    source: sensor.sonoff_power
    name: nove
    unitprefix: k
    round: 2

doublecheck your numbers too, it seems a bit much

For what it’s worth…I get the same jumps in HA v0.105.5 whenever I restart HA. Same sensor config worked fine on 0.100 up to 0.103.2. But after I upgraded HA I can no longer trust the utility meter sensors :frowning:

It seems like it is adding the stored state value (taken from .storage/core.restore) with the incoming value (which will be the same as the stored state) resulting in these big jumps.

1 Like

I have this jumps also randomly when i restart HA. Today after the HA update from 105.5 to 106.4, it jumped from 1580 kWh to 7750 kWh instantly. I am using Aoetec ZWave Home Energy Monitor. I also use a Sonoff POW mqtt connection; which never does that…

I am using this sonoff-ewelink-component
It gives me the sensor, without any code in config.

Do you have it flasher with tasmota ? I need these connected to ewelink to be able to access them from outside of my wifi because my internet provider does not provide any type of public IP so I cant use duckdns etc.

How do you browse the internet without an IP Address?
What happens when you go to https://www.whatismyip.com/

I have a private IP its really common in EU and I know that for others it may seem like weird but it’s like that unfortunately.

This shows the same IP my 50 neighbors have.

That’s the new scam ISPs use for some time, using shared IP numbers. I give it to IPv4 numbers are exhausted, so the ISP shares one IP with multiple clients. That basically means, you can almost never access your network from outside with port forwarding.

Most of the ISPs offer dedicated IP adresses for a small monthly fee. That’s how i solved it.

I experience the same behavour. The energy values of the Utility Meter jump after a HA restart. The increase corresponds with the value on the incoming sensor (Shelly 2.5). I am using HA v0.106.5.
I just started using the Utility Meter so I cannot say if in older HA versions it was different.

I am using v106.4 now and it has been the same for a long time with the older HA versions.

Hi
Thanks, I’ve been using the utility meter with an Emporia Vue for 2 months now and have not seen that issue. My Hassio reboots nightly and I am running v106.4.

I’m still trying to figure out how to sync my utility’s billing cycle with a monthly utility meter. My billing starts on the 15th day of the month so I set the offset day to 15. Still testing, but after reviewing the code it looks like you 14 as the offset if you want the 15th. Anyone else’s two cents?

5310

What you are missing is the algorithm used for integration (default trapezoidal):

Check https://en.wikipedia.org/wiki/Riemann_sum too

I would try your setup with left or right methods.

Doesn’t look like your jumps are related to HA restarts as others have reported.
They are clearly related to when your device turns ON - unless your server restarts every time that happens due to power fluctuations at your home :wink:

I wonder if this could be an issue with data points: The initial jump in Wh appears larger based on the time it has been turned off prior to the event. On the chart it actually looks as if the increase is proportional to that off-time period.
This clearly a very wild guess but might be worth considering.

What might be happening here is that the integration component does not receive any additional data points after Power (Watt) drops to zero because there is no change in value - it remains at 0W.
Then, when the device turns on and Watt goes to 2300 Watt, it calculates an average for that entire time period since that first data point (when the device was turned off, 0 Watt), and the current data point (2300W). Adding a consumption of 1150W * x hours (where x is the time the device was turned off and power was at 0W).

This is, for example, an optimization that the MQTT sensor has enabled by default. (see MQTT Sensor - Home Assistant)

I can’t find any indication in the docs for the ewelink component that it is doing this though. is it possible that Home Assistant is doing this?

Anyway, a possible way around this might be to set the “method” of the integration component to use the “Left Rieman Sum”.

  - platform: integration
    source: sensor.sonoff_power
    name: nove
    method: left

see Integration - Riemann sum integral - Home Assistant

From Riemann sum - Wikipedia

image

2 Likes

You are genius, thank you!


Wow, look at that nice-looking graph.

The problem must be with the sensor not sending the “0” W consumption, the appliance connected to the sensor is boiler so it is either on or off, so when it was off it consumed 0 W and the sensor provided just 0 at the moment it turned off. If it was turned off for 6 hours, it told me that the sensor had 0W 6hours ago as the last state.
I also think it may be with the HA restarts, that the integration tries to do the same with the off-time of HA, right? So it can help others I hope.

Thank you so much!

Hey, guys try what mistaecko advised to me.
It can be the same, that the integration probably tries to calculate the consumption in the gap with no data from the sensor (when the HA is off/restarting).
Just add to your integration the “method: left” and see what will happen.

Thanks for the suggestion but I am not using the integration component. I get the consumed energy (kWh) directly from my sensor (Shelly 2.5) and the sensor stays always on.

Hi,

I am using HA 0.107.7 and facing the same issue. Has anyone been able to fix this?

I want to report that I use since a few weeks the Integration component to compute the total energy as input for the utility meter component (instead of kWh coming directly from my shelly) and this is working fine for me.