Grid, Battery consumption problem

Hello,

I have a house with two different flats. In my flat is a power meter.

If the battery is empty, I will consume from the grid. But how can I different the two flats, how many kW/h is consumed per each flat? Huawei Smart Meter is installed and in my flat I have a second power meter which is imported in HA.

Maybe I can make a template sensor, which only count if I consume from the grid?

Three Victron Multiplus two complete my house.

Thank you.