Solution for power given energy?

Theoretically trivial: Derivative Sensor.
But HA has a bug that derivative sensor only takes new values when new value is available. This is problematic when energy stays constant because then power is clearly supposed to be 0.

But since the value is not repeated until the energy entity provides a new value, the derivative sensor shows a large power value even is it’s zero.

Is there any hack/solution for this?

Maybe add some noise?

Create a template sensor that adds a small random value to your energy sensor (+/-0.1Wh). This should average to zero in the long term. Make sure this sensor has a state_class of total not total_increasing, as it will go up and down. Take the derivative of that.

Thanks. You got me an idea. Maybe add a property instead that regularly updates?

Marking this as solved. Seems to work, thank you :slight_smile:

I extended this with the attribute and seems to work as well.