Help with Repeating Conditional Rule, please

Hi all,

I would like to make a rule that checks conditions and performs an action repeatedly.

Conditions:
Time between 18:00 and 20:30 AND
Lights A and/or B are switched on AND
Switch C is off.

Action:
Speak: Don't forget to turn on switch C.

Repeat every 10 minutes until conditions are FALSE.

My problem isn't making the rule. I also know how to repeat the actions.
But I do not know where and how I could repeat the Conditions check.

Thanks in advance for any help!

If it turns 1800 and A or B are on do you want C turned on? At 2030 do you want C turned off?

Make a rule with trigger periodic check 10 minutes

for action start with if condition
add all your 3 condition with "and" in between

after if condition add your action whatever it is
add a new conditional action END IF

1 Like

No. If lights A or B are switched on between 18:00 and 20:30, I want a reminder to turn on C.
C stays on all night. Sometimes I do not want to turn on C. But I do not want to forget to turn it on, when I want it on. Hope it makes sense...

Thank you. I haven't thought of that. Is it possible to limit a periodic check to certain hours? I have so much running on my poor Hubitat already :smiley:

In Rule 4.0, the "Conditions" section does not do anything on its own. You can use them to build IF statements in your rule actions, which is how you actually check if your desired conditions are true. Your actions sections runs any time one of your triggers fire. Triggers are the only thing in Rule 4.0 that cause anything to happen (aside from things you've timed/scheduled in your actions, but those can only be set off by a trigger that caused them to run in the first place or the actions section itself being called by another rule).

I can help write one that might do what you want, but I want to make sure that this is what you want first: you want a speech notification every 10 minutes between 6 PM and 8:30 PM if Switch C isn't on but either (or both) A or B is? I would get quite annoyed if it was one of the times I didn't want C on. :slight_smile: The above idea would probably work, but I don't know I'd want a job running every 10 minutes when I only care about it for a few hours a day--something that triggers at the desired start time then repeats every 10 minutes to check (and stops when C is on or the time is up) might be better.

1 Like

Thank you. This is perfect!

Sometimes I go in and out of the room. Then I would turn on either A or B or both. It will be seldom that I spend more than 10 minutes. But if I do stay longer, I want to turn on C, but only when I want it on :slight_smile:

Yeah, complicated, but it makes sense to me... Thanks anyway for thinking with me.

Why not just have the rule turn on C too?

Here's another option that doesn't run every 10-minutes all day long. Instead, it only runs when switch A or B (Dimmer 1 or 2 in my rule) turns on, then checks to see if the time is between 1630 and 2200. If so, it notifies you every 10 minutes (after an initial 10-minute delay) if Switch C (Switch 2 in my rule) isn't on. It stops the repeats if the switch does get turned on or the time conditions are no longer met or if both A and B get turned off (at any time).

The rule is a bit "wordy" and I'm not super-happy about having to do some things twice (specifying "0:10:00" and "between 16:20 and 22:00"), and I might have too many (harmless) stops/cancels, but it's the best I could come up with at the moment and just really wanted to make sure the repeat never kept going when you didn't want it to--they can be tricky to work with. [EDIT: See below for a different user's suggestion on how to make this less wordy. Have I mentioned how much I hate repeats? :slight_smile: ]

This also won't check at 16:30 if A or B is already on to see whether C is on. If you want that, adding "Time is 16:30" as a trigger should take care of that with no ill effects. There may be other things I haven't thought about, but hopefully this is a good starting point (I encourage competent adults to verify my work, as always).

Why do you have the time in so many place and so many nested if's in the first have of the rule? I think you could simplify this greatly.

image

I just tried that example rule and it worked perfectly.

Yeah, moving the end time and "Switch C changed" to the triggers allows that to be simplified quite a bit, doesn't it. :slight_smile: So for the poster, I'd recommend that IF be something like IF (Switch A is on OR Switch B is on AND Switch C is off AND Time between 16:30 and 22:00), then that one ELSE should catch everything they want to cancel the repeat (and delay).

....exactly what I posted then? Yes, substitute in your own devices and times....but I think you get the point.

I don't understand your constant hostility. If the poster is not familiar with Rule Machine, the order of conditions in the IF matters since OR and AND are evaluated left to right with equal precedence, and changing the order would cause undesirable results. I just wanted to make sure that didn't cause any problems. Peace. :peace:

1 Like

You too.

Thank you @Ryan780 and @bertabcd1234
Good ideas from both of you. At the moment I'm using the "every 10 minutes" rule, but I will look into your rules for sure!

One other quick question:
image
I understand the difference between AND and OR. Will OR be treated the same as the human and/or? In other words, if I use OR, will it also trigger if both lights are on?

Yes

Highly advise against this. Hubitat is an event driven system. 99% of the time this rule is going to do nothing but consume resources. This is not SmartThings where you have unlimited cloud computing power that you can use. There are only same many operations that the Hub can do in a given moment. Do you really want it tied up with something adding no value?

Agree with you 100%.
My Hubitat is working like a little slave already.

@Ryan780, I'm looking at your rule now. Unfortunately I'm not at home, so I cannot test it now.

I do not understand your REPEAT.
If conditions are met, after a delay, the Hubitat will speak.
Then it will repeat, but what exactly will repeat? Will checking the conditions repeat, or is it only going to repeat the speak part?
And it's stopable, but what exactly will stop it?
(Sorry if these are noob questions)
image

EDIT: Wait, I think I see it, if "Office Hue Strip" turns on, the whole rule will trigger again! Will this kill the first (repeating) instance of the rule? If so, I understand the rule completely.