Energy usage is delayed or shifted in time in the graphs

As probably most of you have, too, my energy meter reports the energy used each hour. But it does so 10-15 seconds passed each hour. The energy used between 13:00 and 14:00 is sent to Home Assistant 14:00:10 and Home Assistant shows it as energy used between 14:00 and 15:00. Are there any good solutions to this? The main problem is that total energy cost gets wrong when the price is different each hour.

2 Likes

This should not matter. The statistics update at 12 minutes past every hour.

It does matter. The energy used is sent from the meter 10-15 seconds past each hour and it is that time which is used in the Home Assistant datalogger. There is a lot of threads here about this problem in Home Assistant.

The two images here show the problem. I had a peak in usage between 05:00 and 06:00 and the app from my grid company shows this correctly. The energy page in Home Assistant shows this peak as between 06:00 and 07:00. The price I paid for this hour is also correct in the grid company app, but HA used the price for the 06-07 hour which was not the same as between 05-06.


Edit: You can also see that HA is missing energy from the last hour between 23:00 and 0:00. That hour is shown on the next days graph.

1 Like

You could install another meter in series with the power company’s meter. One of your own that works well with home assistant.

The energy meter is owned and delivered by the grid company.

But does anyone else have solutions to this problem?

Home assistant can only deal with the data you provide. Bad data in → bad data out.

There is no bad data from the energy meter. It reports energy used in a time frame. And of course it has to wait until that time frame has ended before it can report the usage. The problem is that the logger in HA is not able to use this timeframe in any sensible way. It is a limitation of Home Assistant. The Home Assistant data logger does not accept anything but state changes without time frames. That is ok for sensor data, but for energy usage it is a big miss. All electrical energy meters report energy usage for a previous period and it is next to impossible to get this logged into HA on the correct hour. One could delay the clock on the HA machine, but that is not a good solution.

But why are you commenting in this thread? It doesn’t look like you understand the problem nor able to discuss it in a constructive way?

5 Likes

There are meters you can buy for less than $5 that can report the energy use in real time. https://www.aliexpress.com/item/32373508101.html

$50 if you don’t want to diy. https://shelly.cloud/products/shelly-em-smart-home-automation-device/

Your meter is the issue. Home assistant only works in real time, for all sensors. Not just energy.

Energy usage is always measured in a time frame. It has no meaning without also specifying the time period. The unit is Wh and time (h) is there for a reason. And that is the problem with the HA logger. Something made for logging state is now used for logging energy and that does not work very well without any option for telling HA the time period for the energy used.

1 Like

HA only accepts data at the point in which it receives it and it treats that moment of time as time it changed. It does not have the ability to accept data and change the moment of time to something in the past.

Basically, your device is reporting the information from the past hour inside the next hour. Home assistant doesn’t know that. And if if only reports this once an hour, then that’s the only data that home assistant has for that hour.

If you buy one of the options I recommended you will find that they integrate power to energy continuously, on a very short time interval. Certainly not 15 seconds later for a whole hour at a time.

You probably understand that it is not possible to replace the current energy meter with something what you linked to? And even if they report at a shorter interval, there will always be a problem with the last interval before a new hour.

A service call for the logger where we could set logtime and state would probably solve it.

logger has nothing to do with it, logger displays what’s in your database. When a state comes from your device, this state is then added as a state change in your database. This is all done under the hood and no user has access to it. Your device reports at a time, that’s the time that is used. No api exists to change that.

My point was that this could change. Or is everything in HA written in stone and not possible to change? I think everyone here want HA to perform as good as possible and I am not the first person here asking for the possibility to log something with a specific time together with the state.

I don’t know each end every country in Europe and how electric energy is reported, but in Sweden, Denmark and Norway, electric energy meters report at intervals, usually each hour. It would be nice if HA could show energy usage properly which is not the case when they report a few seconds after each hour has passed.

2 Likes

HA can change, however a change like this is not simple. Also, you’re asking how to do something in a support community section. If you want HA to change, make a #feature-requests. Otherwise arguing about it to people explaining how it works is stupid.

I will make a feature request, but wanted some discussion and suggestions beforehand. Unfortunately it seems no more than me see this as a problem with HA :upside_down_face:

3 Likes

Because that’s exactly what it is. You think it works wrong. However it was never designed to work the way you think it should work. So is it really wrong? No. It’s just something that HA can’t do. Simple as that.

Why is this made, then?

You don’t have to answer - it was an rhetoric question. I will make a feature request and argue that this don’t work properly with the energy meters used in Sweden, Denmark and Norway.

7 Likes