# Accumulated energy sensor per hour

I’m trying to figure out how to create an Accumulated energy sensor per hour. I know about the utility meter, however the meter only updates once per hour. What I want is something similar, but the sensor should update constantly and then reset at every full hour. I think I might need an statistics sensor, but I’m out of depth on this one. So I was hoping for some ideas

Background for the sensor is to use with new energy tariffs her in Norway where when we peak over thresholds (on a per hour basis) we get a more expensive tariff, and the idea with this sensor is to keep track of the current hour as it progresses to further utilize in some automations to cut of energy demanding components.

1 Like

Not sure where you got that idea. It updates whenever the source sensor updates.

1 Like

Sorry about that, came out wrong. My “upstream” sensor only updates hourly, so subsequently the utility meter also does that.

However I have an watt meter for the entire house (which updates every 10s), so I was thinking maybe I could base this of that?

Sure, feed the power meter to the Riemann Sum integration. Then feed the resultant energy sensor from that to the utility meter on an hourly cycle.

1 Like

Thanks! Thats it!

For others finding this thread, solution is as follows:

``````# the sensor
- platform: integration
name: energy_per_hour
unit_time: h
unit_prefix: k
source: sensor.strommaler_power # this is my power meter for the entire house
round: 3
...
# the utility
accumulated_energy_hourly:
source: sensor.energy_per_hour
cycle: hourly
``````
2 Likes

So I let this sit for a few hours now and the results seems off? I’m comparing the energy dashboard towards the history of the accumulated_energy_hourly utility and as you can see its off by a few:

I completed the config’s and sensors/utility was online before 11:00 - so the measurements should be good hour to hour

``````Energy dashboard:
11:00 -> 12:00 = 4,34 kWh
12:00 -> 13:00 = 4,12 kWh
13:00 -> 14:00 = 3,39 kWh
Utility sensor:
11:00 -> 12:00 = 4,13 kWh
12:00 -> 13:00 = 3,42 kWh
13:00 -> 14:00 = 6,11 kWh
``````

Any idea as to why?

The `sensor.strommaler_power` is reporting every 10s, might there be an issue with timings?

Change the method of your Riemann Sum to `left` to reduce errors:

1 Like

Petro wrote a great post on the errors the Riemann Sum `approximation` of an integral can introduce and how to minimise them:

2 Likes

Thanks @tom_l, I’ll make sure to read it

So I let this sit for a few days, however something odd. It seems the energy dashboard is one hour behind (in regards to the utility)? Eg for hours 00:00->01:00 this get accounted at 01:00->02:00 in the energy dashboard? See pictures:

Otherwise the measurements seems to align pretty good (roughly the same between the utility and energy dashboard hour for hour, adjusting for the offset on the energy dashboard)

Feed the energy dashboard a daily utility meter. Let it count the hours.

Could you explain how to feed the energy to a daily utility meter? I am looking to have kwh consumption hourly, daily and monthly.