Duty cycle of water well pump

We are on a domestic well, if the water is left on at the barn the well gets low enough to turn water brown and trip the pump run dry sensor. Before that happens it cycles continuously trying to keep up. Otherwise the duty cycle is low as the pump is only on long enough to fill the pressure tank. The duty cycle will change (on long enough to fill pressure tank then off) depending on water use, for example a teenager shower typically runs till the hot water is gone.

I have an AC current sensor hooked to an ESP8266 set up thru ESP Home (binary sensor) so I can see when the pump is on or off by current draw.

Wish to trigger notification alarm when the pump cycles on/off for X amount of time. Have played around with time.pattern but can’t quite get it to trigger on duty cycle. I can get it to trigger when on or off for X time no problem, it’s the on/off (duty cycle) for some amount of time I don’t get. For example longer than it takes for fill a 100 gallon cow water trough (or teenager shower) but shorter than when Granny forgets to turn the water off after the trough is full:-/

Aha, found this example hopefully (with some refactor) it will work for my purposes. The author phrases the question/problem better than I did “Is there a relatively simple way to trigger my automation if a binary sensor changes often (for example 30 times in 15 minutes)?”