Hi, I tried to search the forum, but had no success. I don’t even know if this is the right section to post. If not, accept my apologies and let me know the right place.
I am a somewhat advanced HA user doing many things with automation and templates. I am a professional developer (but with weak python skills).
I need to monitor water use in a “irrigation cistern system”. I need to protect against leakage and running out of water. It is somewhat complex and expensive to meter water use directly. However, I can use pump energy usage as a proxy for water usage (I’ve evaluated that before and it would work).
I have several daily irrigation time slots in the 10 to 20 minute range. Irrigation usually happens daily, so intervals usually re-occur daily (except in rainy periods). Each irrigation period matches one irrigation area.
Detecting empty cistern is simple: pump energy usage is zero to very-close-to-zero during the irrigation period.
Detecting leaks is more complex. During normal operations, the pump does not run continously (there is a small water buffer inside the system). If there is a (sufficiently large) leak, the pump either runs continously or much more often. In other words: the pump uses more energy in today’s irrigation interval than in “yesterdays”. To make things slightly more complex, water usage (and thus energy usage) can fluctuate somewhat due to external conditions. Side-note: that means that even I would monitor water usage directly, the base problem would persist.
The solution to the problem is to build the daily average usage of (pump energy/water) for each irrigation interval. Then, emit a warning if today’s interval usage is outside of some permited fluctuation.
Basically, that requires me to store daily usage per interval, build averages on that and compare the usage at the end of the current interval against that average. Note that I have only one pump and one sensor, so the intervals are not identified by the sensor but by the irrigation time frame.
I know I can do this by sending sensor data from HA to MQTT, reading and processing that data with an external script, and make this script notify HA on potential problems via MQTT/template sensor (and take up this warning via an automation).
I just wonder if there is a simpler way using only HA features directly.
Any help/hints would be deeply appreciated.
Many thanks,
Rainer