Create kWh sensor knowing heater state + fixed power

Hi. I have a current sensitive relay that (via and ESP32 / ESPHome) tells HA if a heater is on or off.

I know the power of the heater in kW. I would like to add the heater as a “Monitored individual device” in the Energy Dashboard.

How do I create a new sensor that will use the heater state (on / off) + known power and calculate kWh as a ‘fake’ sensor the Energy Dashboard can use?

Create a virtual power sensor:

Then use the Riemann Sum integration to calculate the energy.

1 Like

One issue you may have is that the Riemann sum integral is only calculated when the power sensor updates. Not sure if there is a way to force regular updates in powercalc.

Thanks… I have added the power sensor and will see what sort of values I get :slight_smile: Thanks again…

You need create a power sensor with a template that return 0 when the heater is off and the power when the heater is on.

After that, you can use a integral to create a energy sensor using the power sensor.

Powercalc will force regular updates (every 10 minutes) even if the value doesn’t change. You can even change that with force_update_frequency option.
No need to create a riemann integral sensor manually. Powercalc will do so automatically for each virtual power sensor by default.

2 Likes

Nice! Powercalc makes it very easy then.