How to caclulate/store amount daily water gain/usage (Influx+grafana)

Hi guys,

(OpenHab2.8, KNX, influx , grafana)

perhaps one of you has got an idea. I do have a water cistern including a ultrasonic sensor for available water left (ping every 10min). What I am interested in is , per day , how much water I have used for irrigation e.g. -300 litre, or during a raining day how much water I was gaining into the cistern the last 24hrs e.g. +650 litre for example. The openhab setup including a Grafana charts of progress is working already.

I just don’t have an idea on what the best way of doing a difference calculation every 24hrs. A rule that triggers every midnight and storing and calculation the value in a separate item or is there a min/max function in influx/Grafana available?. Perhaps other easier building options I don’t know about……

Open for suggestions :blush: …. Many thanks

bkumio

Hi Mario,

i have a counter for the total water consumption. (basically the water counter state).
i use this query in grafana to show the water usage in the last 24 hours

SELECT difference(max("value")) FROM "water_counter" WHERE $timeFilter GROUP BY time(1d) fill(none)

your setup is more complex as the water counter can decrease and increase but maybe my query point you to the right direction.

It’s documented

Obviously data from just level sensing isn’t that informative, as you already understand, but will give some indications of ‘winning or losing’ for the day.
Comparing midnight readings or comparing max/min will give you different info, but there’s no reason you shouldn’t do both.

1 Like
<item>.sumSince(AbstractInstant)` 
Gets the sum of the previous States of a persisted Item since a certain point in time
1 Like

Thanks guys… for pointing me in the right direction. Enough ammunition to try something out…