How does the Power Flow Card Plus calculate home energy consumption?

The Power Flow Card Plus shows total energy consumption on the right-hand side under the house symbol (see below).

I’d like to know how this value is calculated. Theoretically, the calculation itself is simple, but because the data used for this calculation does not come in at the same time, it leads to very wrong results (like -5,000 watts). I’ve never seen this happen in the Power Flow Card Plus, so I assume there’s a better way to do this, and I’d like to know how.

Perhaps someone knows, or someone can find it in the source code. Unfortunately, I don’t understand enough of the code on github to do it myself. My goal is to have this exact value as an entity in Home Assistant.

Ask in this topic then. That’s where the developer is.

1 Like

It explains how its calculated here:

By default the home consumption is calculated by adding up all sources

1 Like

That’s the same way I do it, but as stated, the card does not seem to have the same problems, so I guess there is some kind of magic going on behind the scenes!

Great idea, will do. Thanks!
However, I don’t have much hope in this respect:

Having some spare time, I dove deep into the source code (with some help from GPT4) and was able to extract the information I needed. In case anyone is interested, here it is (of course you have to change all the sensor entities):

{% set solarStateTotal = states("sensor.yourEntityHere")|float %}
{% set gridStateToGrid = states("sensor.yourEntityHere")|float %}
{% set batteryStateToBattery = states("sensor.yourEntityHere")|float %}
{% set gridStateToHome = states("sensor.yourEntityHere")|float %}
{% set batteryStateToHome = states("sensor.yourEntityHere")|float %}

{% set solarStateToHome = (solarStateTotal or 0) - (gridStateToGrid or 0) - (batteryStateToBattery or 0) %}
{% set totalHomeConsumption = max(gridStateToHome + (solarStateToHome or 0) + (batteryStateToHome or 0), 0) %}

{{ totalHomeConsumption|round(0) }} W

1 Like