Consumption meter via level indicator

Hello dear community,
I’m still fairly inexperienced with Home Assistant. So far, I’ve managed to get everything working, but I have an idea that I can’t seem to get right.
I use a Liquid Check fill level indicator for my cistern.
I was able to integrate this into my system without any problems and I get values ​​in liters, height, and percentage.

Now I would like a meter for my rainwater consumption. This should be possible using the fill level. I’ve already configured a consumption meter, simply using the liter sensor entity. This also counts, but unfortunately, it simply adds the negative and positive values ​​together. Is it possible to have the meter add only negative values, or conversely, only positive values?

The derivative integration will give you flow rate from your tank level sensor:

This will be both positive (flow rate in to the tank) and negative (flow rate out of the tank). You will then need to separate these into two positive values using a template sensor, similar to this: Help with energy sensor templates - Negative to positive - #4 by tom_l

Then you will need to re-integrate the the two sensors (separately) to get total flow in and total flow out:

Alternatively you could fit a flow sensor to your tank, which would be easier and more accurate.