energy-flow-card-plus icon indicating copy to clipboard operation
energy-flow-card-plus copied to clipboard

fix: grid to battery calculation in absence of solar production

Open EiNSTeiN- opened this issue 8 months ago • 0 comments

There is an issue with the reporting of "grid to battery" in my off-grid setup. I use a generator as the "grid" source, which is not always online, but when online it is used to charge the battery. The battery is then discharged to the house later.

In my setup, there are only two energy producers:

  1. the generator (grid import energy)
  2. the battery (discharge energy)

The home is only a consumer, it does not produce energy. Therefore whatever is exported to the grid must come from the only other producer available, the battery. And vice-versa, whatever is charged into the battery must come from the grid export.

I've added code to calculate grid.state.toBattery in the case where solar isn't configured.

I've additionally changed totalHomeConsumption to take the total grid export (grid.state.fromGrid) and deduct the energy that is sent from the grid to the battery (grid.state.toBattery), since that energy isn't going to the home.

Before: image

After: image

This may fix some bug reports such as https://github.com/flixlix/energy-flow-card-plus/issues/67 however I'm not sure if it is a complete fix since the original author had a different setup than mine.

@flixlix for your review

EiNSTeiN- avatar Jun 18 '24 15:06 EiNSTeiN-