Rolling integral of power over the last hour

I have a sensor reporting instantaneous power usage and I’d like home assistant to report the integral of that power over the last hour on every input sample.

So at any point I can see how many kWh this device was using over the last hour.

Integration - Riemann sum integral - Home Assistant seems to be it but it’s actually increasing seemingly forever. Like it gives the total kWh used since the sensor inception. This is not what I’m aiming for.

Does the thing I’m describing exist?

Feed the Riemann sum sensor to a Utility meter with an hourly cycle.

Also make sure you have the correct method selected for the Riemann sum. left rather than the default trapezoidal in most cases.

Thank you I’ll give this a try

That’s not it unfortunately as the utility_meter ramps up but then resets to 0 before ramping up again.

In my case I’m only interested by the last point before the reset but I’d like the block to keep updating that last point indefinitely on every input sample.

For example: Windowed Integrator (Communications Blockset)

If you can wait a little bit this will be released in 2021.8. All automagic. You can get a sneak peek here: https://discord.gg/H2hE32pu and here: https://discord.gg/uhrpmrdA

Or join the beta program and help test it now.

1 Like

Hi @tom_l,
looks like these discord links are not working anymore.
Can you give a hint which change in 2021.8 did solve the OP’s problem? I don’t see it and I am working on a similar problem right now.
Thanks.

What is the name of the entity? I am on 2021.11.05.
I would like to use the integration from start to end timestamp.
Thanks

The energy dashboard.

I’m looking to calculate the half-hourly cost of charging my car - I am on a variable tariff that changes every 30 minutes. I have a sensor that gives the instantaneous power going to my car, and another sensor that shows the current rate. That looks very similar to the question posed here. The Energy dashboard solved that for an entire household energy consumption, but I can’t figure out how to do it for a single device.

I was able to getting a rolling window integral by:

  • Creating an Integral sensor
  • Creating a Statistics sensor for the change in the Integral with the desired time window
  • Smoothing out the noise in the change with an average_linear Statistics sensor with a time window larger than the max sub-interval of the original Integral sensor.

Integral Chart

Windowed Integral Chart