How to digest energy usage of battery with usage on a "backup port"


I installed shelly energy meter to get metrics from my battery system into home assistant. I am currently measuring the cable going towards the battery system but also the cable connected to the “backup” port on the battery system. This port allows something to be powered even if grid is being dropped (my network equipment).

So I need to pass kwh in and out towards the battery for homeassistant to map it to the energy dashboard. But if I do it as is this also includes the usage of my network equipment on the backup port (if the battery is empty and there is no solar you will see the usage going towards the battery system while it is being used for the network equipment).

I was thinking to calculate the difference between energy to the battery and the usage of the network equipment but that only is correct as long as I do not start using power from the battery. Then my from battery to net should be: battery_to_net + network equipment usage.

For power this is quite straight forward, but for energy not so much.

So any tips that would allow me to get import and export from battery without the usage of the networkequipment?