"Hey it's been X hours and the Well Pump is still pumping" Rule

Looking for some quick start guidance here. The outcome might help others still new to RM.

Early on I had an HSM rule in place to tell me when the well pump goes on and off but obviously that requires paying attention to the on/off pairs and is less than useful. I also have Simple Irrigation set up for my automated valves so without human intervention that works fine.

So what I never implemented was some logic to "automate the watch" when irrigating from a non-automated hydrant. So this morning I woke up to extremely well watered trees which I had forgotten I set a hose on last evening. Human intervention gone wrong.

In building a new rule as a new rule builder , I'm wondering what combination of delay, wait, polling etc. I should use. The configuration of this pump is such that it does not cycle on and off once it's in full throttle irrigation use. So I basically need to note when it goes on and then after X hours be notified that it is STILL on and continue periodic reminders until it is off.

I started off thinking;
a) trigger the watch rule upon "OPEN",
b) delay X hours
c) poll device
d) notify if still on and go back to (b), if not on then end the timed watch

I found polling must not be a valid option for the contact device I'm using because it didn't show up when selecting polling? I also realize I'd like to end the timed watch early if a "CLOSED" comes through before the delay period ends.

This is pretty simple stuff for you guys that build rules all the time. Can someone give me a jump start on this. Thanks in advance.

How does your well pump report to Hubitat? For example, does it report as a switch (on/off status for the "switch" attribute), a contact sensor (open/closed status for the "contact" attribute), or are you using power metering as a proxy for pump state? This will affect how you write the rule but also what apps you can use--like if it's a switch or contact sensor, you could get away with the new Basic Rules app and do this pretty easily:

If you need to use Rule Machine (because the attributes you need aren't supported by Basic Rules) or prefer to for some reason (or want more customization), then this rule does the same as the Basic Rule above and should be easily customized if your device works differently (e.g, isn't a switch):

Trigger: Switch turns on

Actions:

Wait for events: Elapsed time --> 6:00:00
IF (Switch is on) THEN
  Notify: "Switch still on!
END-IF

This rule triggers when the switch turns on and will wait six hours. After that, the rule will run the next actions, which are to check if the switch is still on and send a notification if so. If you are wondering, trigger events cancel any waits, so if the rule gets to this point and the switch is on, then it was on for six hours (avoiding a common mistake people make with delays; this rule ensures that it stayed on for six hours, not just that it is on six hours later).

Wow, thanks....lots of guidance!

Visonic MCT340E - Generic Zigbee Contact hack/hardwired to a current sensor. When the Visonic contacts are closed there is current (and water pumping), open there is no current (no water pumping) but don't let the inverse terms confuse the discussion :crazy_face:

For those interested - Filling in more info on how the pump activity is monitored. Here is what closes the contact wires from the hacked Visonic MCT340E; a Dwyer Miniature Current Switch,Normally Open, MCS-111050, Solid Core .5 to 50 A Continuous
image

Ah. In that case, you should be fine with Basic Rules:

However, the above Rule would work too, just with "Contact" instead of "Switch." Hopefully this helps!

1 Like

Truth be told I hadn't even realized Basic Rules was there and didn't even have it loaded. I was confusing that with Simple Automation which I did have and use.

I have this set up in Basic Rules now but I'm scratching my head if I can achieve the ongoing reminder in the case that the water is validly on for over X hours and want another reminder after another X increment. I see the WAIT option in there but that's not going to help. I need to keep the rule going off the initial trigger while resetting the timer for another pending reminder.

Not to say that this isn't going to be helpful AS IS. This will solve the "oops, it's been on all night" dilemma!

Thanks again !

Ah, no, sorry, I must have missed that. You could go back to the Rule Machine idea. To get the repeated notifications, you could use some idea from this thread:

And actually, come to think of it, the built-in Notifications app might even be able to do that all instead. :slight_smile: What I don't remember off the top of my head is if it can handle the "6 hours" thing, as I know there were some limits on time for certain things when I looked at this in the past...

That might well be the best way, to keep this type of watch & notify utility consolidated.

...

Just set that up. If I interpreted the repeat settings correctly, ( ie. keep notifying every 30 minutes after the initial 120 minute duration notification until the condition changes) this looks to be purpose built for what I needed to do.

Dare I say that sometimes it's a little confusing where best to do things in HE. But had I thought of this being....well, what it is, a Notification on an event or state, I woulda/shoulda started there.

Thanks a bunch.

1 Like

As a side note, I tend to stick to Rule Machine 4.1 as I like to see all of my automations in one place instead of looking over the 2-3 different rule types.

Being newer to creating rules, I would highly suggest you come up with a naming convention to help you find things later on.

I follow a standard of:
(subject area) - (optional: mode) - (trigger) - (action)

Subject area: This would be a grouping of what you are controlling, so for myself this is Climate, Notification, Lights, etc.
Mode: This is optional if it applies. I add in the mode name if its particular to the rule
Trigger: This is what causes the rule to execute
Action: This is a summary of what actually is happening

In your case I would name it something along the lines of:
Notification - Well Pump Run > 6 Hours - Push Notification

1 Like

There is an interesting approach used by Lewis Heidrick (@lewis.heidrick) to organize devices and apps by starting each name with a descriptive emoji. See, e.g.,

Intresting yes. Just not for myself personally.

However, objective and advice is still the same. Come up with a standard and stick with it. You will thank yourself years or 50+ automations later when you need to tweak something :slight_smile:

Good points guys.
Best Practices that should be captured somewhere.

I've already flip flopped a couple times on rule naming conventions having done better on devices. Indeed the "where is it, what does it do, and didn't I do the same kinda thing over there which should be consolidated now that I know better" comes into play.... especially with the mix of rule types.

1 Like

In your case you have a contact so that makes this really easy. The built in "Notifications" app as @bertabcd1234 mentioned is super easy to use and has repeat notifications built in and should do everything you want easily.

So I've had to do something similar to this to auto-turn-off a light that can be either motion- or hand-activated after a time of no motion, and I'll give you a word of warning:

I had a lot of trouble getting the repeating rules to work exactly like I was expecting. I'm not sure why - I may just have been doing something dumb - but I eventually adopted a different approach that was easier for me to understand.

I found that I could just create a pair of rules and some global variables in the rule machine. In your case, one rule would be triggered when your pump turns on, and all it does is set a global Time variable, called, say, PumpTurnedOnTime, to the current time.

Your other rule would be set to just fire periodically. In that rule, you would check to see if it had been a certain amount of time since whatever time was stored in PumpTurnedOnTime, and if your waiting period had expired you could start issuing your alerts.

(Using Rule Machine to check whether the time in a variable is older than a certain threshold is not super obvious, at least not to me. I ended up doing the following:

Variable Set Action: Set (local variable) PumpTurnedOnTimeWindow to (PumpTurnedOnTime + Time Delay I want to monitor)
Conditional Action: IF (Current Time is NOT between PumpTurnedOnTime and PumpTurnedOnTimeWindow) THEN
    //Do your alerting stuff here
Conditional Action: END_IF

)

If you decide you want to mess with this approach let me know and I could get you a screenshot of my rule.

1 Like

Yep, I think it has....but I haven't tested the repeat aspect yet.

And there are other things I'm doing elsewhere that are basically "Notifications" and probably should migrate to there.

Thanks for that.

I actually haven't had time to test the repeat aspect of this. I was happy just knowing I wasn't going to leave the water on all night again. But I do want that...because there are times where things like groups of trees get watered for long periods and not off an automated valve.

So I will test if Notifications gives me that 2 hour warning and then refreshes it every 30 minutes after that until I turn the water off. At least that's what I think I tee'd up configuring the rule.

What you did is kinda the depth I thought I might have to get into and never have. We'll see. Thanks again.

1 Like

For sure. And like I said, it's entirely possible I'm missing some much simpler approach to this. I'm still pretty new to Hubitat. Treat my recommendation like more of a last resort, and listen to these other smarter people first. :wink: