# Convert kWh to W

Hi everyone,

Lots of topics about converting W to kWh, but I’m trying to do the opposite here

In order to avoid feeding back into the grid, I’d like to automate energy consuming devices so that they use the available overproduced PV energy. To achieve this, I need to know the current (as in “now”) PV overproduction and house consumption.

My inverter has a sensor for `grid_power` in Watts, my smart meter tells me the `power_produced` (returned to the grid) in Watts. However, to make calculations and take decisions, I need the amount of power consumed by the “big consumers”. Some of them only have a “consumed_today” summing sensor in kWh.

I’d like to convert the summing (and resetting) kWh sensor to a momentary consumption in Watts sensor. Can somebody point me in the right direction on how to achieve this?

Best regards,
Mike

The derivative of energy is power:

The derivative example here might be useful:

Btw. I don’t know your level of expertise but careful with expectations that you can “convert” between energy and power. The derivative and all other methods you might see discussed on this forum are only approximations with a bunch of underlying assumptions. Wherever possible, you should always work with values directly provided by devices, e.g. your inverter. I am surprised yours does not provide active power!?

2 Likes

Thanks a lot for the quick answers!

Thanks for pointing that out, @ThomDietrich. I do use the values in the correct units whenever possible. Sorry, I might have expressed myself in a misleading way: My inverter provides both values, but e.g. my heat pump only outputs values for its energy consumption in kWh (daily total).

1 Like

If you need more accuracy (it’s not too bad if your sensor updates regularly) you could always add a power sensor. There are plenty of power sensors that work well with HA.

\$ to \$\$\$

• ESPHome and PZEM-004T
• Shelly PM
• Shelly EM
• IoTaWatt
• and more.

That’s ok it happens. But Tom’s right. You’ll either need that info on a very small time scale to get anything resembling a good value or you are much better off using a meter.

Let’s ignore Kilowatt for now and just deal in Watts. Watt is a measure of how much Now. Wh watt-hour is the measure of how strong over time. Now say we ran at 1 watt for 59 seconds and 100 watts in that last second for a total of 60 seconds.

60 consecutive 1 second power measurements woulds say 1,1,1…100

1 - 1 minute measurement would say 159

Which is correct? Both. (add up the 60, one second measurements… Over time they’re exactly the same.)

Which is correct for your purpose. Probably not the latter.

So in this case unless your system is at a 1 second or less time scale I’m buying a meter.

The precision isn’t that much of an issue for me. I’d be averaging the power consumption over 5-10 minutes anyway.

I do have 2 problems though:

1. The daily reset of the source sensor makes the derivative go negative
2. The derivative only updates whenever the source sensor emits a new value. However, the source sensor doesn’t emit a new value if it didn’t change. So the derivative never goes back to 0 (which it should do whenever the source sensor didn’t change between two measurements).

It looks like I’d have to add yet another intermediate sensor to fix these?

(ignore my units and scale btw, I misconfigured the derivative units when I first created the sensor and it doesn’t want to change once it has a history apparently)