Calculate Feed-in of solar to grid

Hi Community,

I want to calculate how much energy from my PV I give away for free. I have the problem that my electric meter doesn’t supply the 2.8.0 value. My meter gives me the current consumption in W (which is negative when I feed-in to the grid).

So I can see when I give power away, however only in W as single point in time and not as W/h. What I already do is to read the value all 10 seconds. What I’m now searching for is a function in Home Assistant that sums only the negative values from a given timeframe and divides them by a variable.
Example: if I add all negative values collected during the last hour, and divide them by their number it should give me a rough estimate how much W/h I “lost” during the last hour. (I know that this can only be an estimate, but it’s much much much better than no value at all…)

Bonus points if anyone has a solution that integrates the result in the energy dashboard. Because currently I have the problem that the only W/h values I have are the power generated by my PV and the power I got from the grid. So home assistant calculates that my power consumption is everything that I generated plus everything from the grid, because I have no W/h value from what i fed-in.

Nope. That will not work. You need to integrate power to obtain energy. Fortunately there is a helper for that.

Make sure to use method: left to minimise approximation errors.

You will also need to feed it only the exported power. That can be isolated with a template sensor. See: How to split a sensor into positive and negative sensors

Thank you so much.
I was already experimenting with SQL functions. It’s crazy how many functions home assistant has (and how you forget about the Riemann integral just 20 years after your last math lesson :wink: )

1 Like