Measuring pump starts and time

Hi,
I have a pump that feeds water to the house. I want to be alerted if the pump starts too many times (a leaking connection or tap dripping) or if it runs for too long (a tap left on).
I have the first part and will get an alert if the pump starts to many times. I use the current power draw of a TP-Link power switch to know when the pump is on. Use a rule to increment a global variable. Test if it is above a preset amount and send a notification. I then have aother rule clearing this variable every hour. At night I don't clear it so aften to make it more sensitive.
Eventually after I find the suitable values I can turn the pump switch off if I detect high usage.
Here is the rules for the first part.


2nd Rule

What I can't work out is the 2nd part. How do I measure and store in a global variable, the number of minutes the pump is running for. I can the use the same logic and reset this value each hour.

Is there a better way to do what I am currently doing?
Any ideas on the 2nd part?

Use a decimal variable and two Time variables.

Set a start time and stop time to now and then do a time difference calculation using the decimal variable.
I actually didn't know this myself, but you can also set decimals to current minute or hour. That would be another way to go.

Thanks terminal3

In case it helps anyone else here is what I have done.
Two global variables to hold the pump starts and the pump run time for the current hour. I noticed that filling up the toilet caused the pump to stop and restart so to counteract this I have disabled the rule from re-triggering using the private bolean so no matter how many times it sops and starts within the minute so long as it is still running when it get to the end of the minute and re-tests it will treat it as being on continuously.

One rule that is triggered off the global variables above when they reach a threshold. Once I find suitable values I will add to this rule to turn off the pump power if the threshold is reached. Maybe I'll only do this if I am in away mode. Still thinking on that one.

The last rule resets the variables. Normally every hour but at night not so often as the usage is low. This increases the sensitivity if something were to go wrong.