Timed functions with Rules Manager

I'm a newbie and having a hard time getting my head wrapped around the process of creating time related rules in Rule Machine. This is not time of day rules. It is rules related to time between events. All signals and controls are working. I'm just unable to figure out the rules needed for timing. I will try to follow this up with a picture of a flow diagram in a comment that describes what I'm trying to do. Thank you so much for your help.

1 Like

You can use Wait for Condition Return Temp >= 85 with timeout of 2 minutes for the crux portion of this. Only allowing it to trigger every 15 minutes is a separate issue.

Trigger Event: Illuminance > 20
Actions:
   IF(Private Boolean false) Exit rule
   Set Private Boolean false
   Set Private Boolean true Delayed 15 minutes
   On: Recirc Pump
   Delay Actions 10 seconds
   Wait for Condition Return Temp > 85 Timeout 2 minutes
   Off Recirc Pump

The first 3 lines of the Actions implement the 'only trigger every 15 minutes' portion. Private Boolean starts out true, so the first time this triggers it sets it to false, then back to true 15 minutes later. Any trigger event in the interim is just going to exit the rule.

The Wait for Condition will be satisfied after 2 minutes or the return temp exceeding 85, whichever happens first. Then the pump is turned off.

There is one possible problem with this as written above: The Wait for Condition will be cancelled if the rule is retriggered during that two minute period. And the pump would stay on... There is a way around that problem. See next post.

1 Like

Amazing. I can see why I wasn't getting my head around this. It is not obvious to me how to get here. But this should get me started. Now to figure out how to load it in. I think I read something earlier today... Thank you!

1 Like

The solution for the cancelled Wait for Condition is to use two rules. The first rule is as above, but excludes the last two lines. Instead, for its last line it runs the actions of the second rule. The second rule has no trigger event at all, it's just stand alone actions: namely, the Wait for Condition and turning the pump off. This prevents the wait from being cancelled. The first rule can be retriggered during the two minutes, but that won't have any effect, because that rule will just exit right away.

Haha, Wait for Conditions with a timeout is a pretty powerful little gizmo.

2 Likes

Can you do me a favor at write that last part out for me please?

Sure:

Second rule (let's call it Pump Timer)

Actions:
   Wait for Condition Return Temp > 85 Timeout 2 minutes
   Off Recirc Pump

The first rule is then:

Trigger Event: Illuminance > 20
Actions:
   IF(Private Boolean false) Exit rule
   Set Private Boolean false
   Set Private Boolean true Delayed 15 minutes
   On: Recirc Pump
   Delay Actions 10 seconds
   Run Actions Pump Timer

4 Likes

Will this keep cycling if the light stays on? i'd like to make the light go off first before retriggering.

Well I just did what you said in your flow chart. I assume that you only want the pump to run once every 15 minutes irrespective of the condition of the light. It could be made to incorporate waiting 15 minutes AND the light being off before running again. You can get it to do anything, just a matter of figuring out the logic that does what you want.

You have been a great help and I can see that it is a powerful tool. I will try to take it from here. My head is still spinning though. Thank you!

1 Like

No problem, glad to point you in a direction at least. I'd get this working, and then see what you might need to alter later...

Note that the Delayed 15 minutes on Set Private Boolean true only affects that action. The rest of the actions keep on going. Whereas, the Delay Actions 10 seconds stops everything for that period. These are two very different types of delays.

1 Like

@deananywhere

Your interaction with @bravenel has created one of the best first-post threads on the Hubitat community by once again reiterating Hubitat's responsiveness to its customers, and the benefit of diagramming out any desired logic before creating an automation. I really liked your diagram!

8 Likes

I cannot find a way to "Exit rule". Any tips?

The Rule 4.x docs are helpful in general, but in this specific case I'd look at the "List of Actions" sections (which I've linked to), and you'll see that "Exit Rule" can be found under "Delay or Repeat Actions, Wait."

Do note that this is used in his example as the action for a simple conditional, so you'll need to create that first, and the result will display exactly as written:

IF (Private Boolean is False) Exit rule

Alternatively, you could do a "full" conditional, which this is more or less a shorter/less-clicky way of writing:

IF (Private Boolean is false) THEN
  Exit Rule
END-IF

(though if you're going to do that, you may wish to consider not doing "Exit Rule" at all and just wrapping all the actions in the opposite conditional, but I digress...)

1 Like

Thank you! "Exit rule" wàs nicely hidden and you pointed me directly to it. Thanks again

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.