Home Assistant for fair usage on community microgrid

Hi all. I am helping setup a small PV/BESS microgrid for a 42-unit apartment block in South Africa. Not an impoverished community—but nevertheless a price sensitive one. To manage fair usage, we need to:

  1. Assign a battery capacity quota to each unit i.e. total battery capacity/42.
  2. When running on battery, meter each unit’s
  3. Notify units as they draw down on their quota (e.g. at 75%, 50%, 25%
  4. Cut units off if they hit zero on their quota.

I have established that it is technically possible, and the hardware involved need not be complicated—we are likely to go with a combination of simple smart maters and contactors in our existing metering room. However we need the software to enable the above functions.

We do NOT need frontends for every user, or any sort of customisation per flat. Just something that sits in the superintendent’s office and keeps everyone to their assigned battery capacity.

I found an academic paper that proposed HA for exactly this purpose. Has anyone done something like this/got any tips? And is there a way to get HA talking to smart meters and contactors in this way?