ESPHome as a Smart Shunt

Hi
I have made battery shunt with ESPHome and INA219 and I have Volt Current and Power. It says minus Current when there is a load and plus Current when the battery is being charged. What I would like now is to find out how much is in the battery so that it counts up when it is being charged and down at load - I have tried with total_daily_energy but it does not look at whether it is plus or minus. Can any of you help me? :slight_smile:

You might be able to adapt what Athom do for total energy hereโ€ฆ