Have a look at the below links to other forum topics which have a few ideas that may answer your question. I use the IoTaWatt to monitor the connection between the inverter and my load center (panel) after power is converted from DC to AC. In my case, a negative flow represents charging or exporting power to the battery and a positive number is my home importing/discharging. I try to look at the battery as a secondary Grid feed which can be negative or positive based on the direction of flow.
Let me know if you have specific questions. Today I grab watts and send that info to both EmonCMS and PVOutput. From there I can calculate kWhs, etc. Happy to assist where I can.