The best possible solution for filling glasses or other “reasonably” sized containers, is to use a dummy measuring container in between the storage container and practical container.
Arrangement goes like this: You have flow sensor and automated valve on bottom of the measuring container. The measuring container is sizes so, that when full, it has the same volume as your practical container (eg a glass or tankard). Another automated valve and another flow sensor is placed on top of the measuring container. The measuring container also needs a hose or tube for replacement air to get liquid flow smoothly in and out of the container. The tube or hose end should be placed higher than the liquid level in storage container, so that it won’t overflow during filling. Now you can use your uC of choice to read flow sensors and control the valves.
Procedure is like this: Close valves, open top valve, poll for flow, when no flow, measuring container should be full. Close top valve, open bottom valve to fill the practical container, poll for flow, when no flow, measuring container should be empty. Close bottom valve. Repeat.
With this, one could calculate the remaining liquid in storage container too. As line pressure changes according to the amount of liquid in storage container, tracking the time needed to fill the measuring container would be relative to the amount of liquid still left. Measure time for filling when container is full, maybe some midpoints, and when nearly empty. Or collect a list of times every time the measuring container is filled and create a chart of time/number of fills.
One could also use line pressure, monitor it’s change and use time and line size to fill containers accurately.