Determine if battery is being used

Hey, is there also a way to check when a device is using grid energy or battery energy?

I want to check how much a device is consuming from the grid and have 3 sensors:

  1. Smart gateway sensor that tracks minus watts (usage from the grid) or positive watts (export into grid)

  2. Shelly consumption in watts and overall usage

  3. Battery state in % (since when this is > 5% - this electricity is used, not from the grid, even without input from solar)

Not with the sensors you have mentioned.