Help with rule

I was trying to figure out my first rule in rule machine and cannot seem to get it right. I have a pond fountain that I am trying to turn on at 5:00 am, turn off at 9:30, turn back on at 2:30 pm and turn off at 11:00 pm. The conditions for the rule are if temp is over 80 degrees turn off fountain and if temp drops back below 80 degrees turn back on and only to run Monday through Friday. Also part of this rule is to turn on fountain lights if illuminance drops below 10 and also turn off if above 10. What am I doing wrong. I have tried multiple ways to get this to work.



Your automation is easy to accomplish; however, for simplicity, it is best to split it into two rules. In both rules, you need to make use of a Required Expression and a Private Boolean for that rule.

Examples of rules that accomplish what you've outlined are shown below.

Rule 1: Controls the pump

This rule is restricted to run only on M-F and in the specified timed. In addition, the PB for this rule must be true for the rule to run. The trigger is the temperature being less than 80 degrees. The rule turns on the switch for the pump and leaves it on until the temperature rises to be above 80 degrees.

Rule 2: Controls the lighting

This rule is restricted to run only when the pump is running. It turns on the lights if the lux is below a certain value and turns off the lights if the lux exceeds that value.

1 Like

Thanks for the reply. So will that rule also turn fountain back on if temp drops below 80 degrees?

Yes. Because temperature <= 80 is the trigger for the rule.

Same with pool lights. They will go off when the illuminance is > 10. Since the trigger is illuminance <= 10, they will turn back on when the illuminance becomes <= 10.

Thanks, that makes total sense

1 Like

One more question. What is private boolean?

Rule 5.1 | Hubitat Documentation, use the contents bar to jump to the private boolean section or just search for the term on the page

Summary

1 Like

Thanks, I will read up on it. I watched some videos but don't know that they mentioned that.

Rules can be exported and imported. If you like, I can export both the rules I posted above. You can save them as text files, and then import it. All you'll have to do is replace my "devices" with the ones you wish to use.

2 Likes

Thank you very much for your help. I am trying to set it up now. I really want to get this figured out. I have done simple and basic rules but never anything in rule machine. I have tried so many variations and nothing worked. Never thought of doing it your way. Do I add an End If at the end?

In this case (referencing screenshots above), there's no IF statement involved, so no need for END-IF.

But in cases where an IF stmt is involved, it's good technique (and often essential) to close every IF statement with a corresponding END-IF.

You can get a way with not doing it if just one IF statement is used in the rule, but just doing every time ensure you're always covered.

2 Likes

As @hydro311 indicated, my rules have no IF statement. So there's no ENDIF needed. Would you like me to give you the rules as TXT files that you can import into Rule Machine?

Sure, then if I get stuck trying to enter this myself then I can use that. Thanks!

  1. PM me an address where you can receive email attachments.
  2. Save the attachments to your computer
  3. In Hubitat, go to Settings and click on "Restore Apps"
  4. Click on "Choose File", and then select "Rule-1.txt", which will be wherever you downloaded it on your computer.

Complete importing Rule-1 and then repeat the process for Rule-2.

Sent, thanks again. I entered everything as your example and it seems to be working.

1 Like

Tried to upload your rule and it won't load. It says wrong format. I copied your examples exactly and thought everything was working. Got up at 2:30 am and fountain and lights were still on. I turned off the fountain and the lights stayed on. This morning it did not turn on automatically at 5:00 am. When I clicked on run actions within the rule it did start up then. Not sure if it matters but it is a Zooz Zen14 that I am using for the lights and fountain?


Has anyone ever requested or suggested a repository where rules could be shared (sort of like github for apps)?

Just thinking :man_shrugging::thinking:

1 Like

In your Fountain Lights rule, Private Boolean is (false) making the Required Expression [FALSE], so the rule will not be Triggered. However after you have manually run the actions once, it sets Private Boolean to [TRUE] and the rule should run the next time.

Note: Private Boolean is used to keep the rule from triggering during the "Wait" period of the "Actions" phase of the Rule. The first action sets Private Boolean to (false) so the Rule won't be triggered while it waits for the Expression Illuminance of Pond Multisensor to become [TRUE].

1 Like

In your second rule, I'm pretty sure you want the first action to be PB set to False (not true).

1 Like