Calculate remaining battery capacity

Hi all, i’ve got a big question …
i’ve got a standalone PV setup with a PV module, a 200 Ah 12V battery and some current and voltage sensors that feeds into a emoncms system.

i want to know how much capacity i’ve left into my battery. i have kwhd in and kwhd out from the battery and the kwhd produced by the PV module.

i know that my battery has a total capacity of 2kwh so i let emoncms do the math and i know at the end of the day how many kwh i have left on my battery. BUT al midnight the kwhd feeds reset itself.

how can i pass the remaining battery capacity to the day after midnight and reset the remaining capacity to 2 ( full capacity ) when the battery voltage exceed 13,8 volts?

i find no way to do this in emoncms. i need at least the possibility to reset external feeds into the process option.

can someone help me?

Thank you !