Contact activated action time restriction

Trigger: contact open
Action: turn on light
Conditions: (1) contact open (auto filled), (2) between 11 pm and 6 am.

Light is turning on outside of time range when contact is opened. What am I doing wrong? Do both conditions have to be met? I am assuming they do.

I would also like to add an OR condition being away mode, i.e., action would take place within time range or if in away mode.

It would be helpful if you pasted the actual rule.

Here are the screenshots:

The "Conditions" section is simply a bank of pre-buit (a sensible default will be placed there based on your trigger, but you can add more and edit any) conditionals that you can use in your "Actions" section. They do not do anything on their own.

If you want your actions to happen only when the time is between 11 PM and 6:30 AM (and when the contact sensor is open), then you could do something like this:

Trigger: Contact open


IF (Time between 11 PM and 6:30 AM) THEN
  Speak "Door open"
  On: Bedroom Light
  On: Barn Door Virtual Switch

Note that I'm not explicitly including "Contact open" as a condition here (e.g., IF (Time between 11 PM and 6:30 AM AND Contact open) THEN since your actions run only when your trigger fires and your trigger is the contact sensor opening (so you know it will be), but it would be the same either way.

I'm not sure where you want mode to fit in here--do you want it to happen if either both of those (time and contact) conditions are met, or the contact condition is met but mode is away, regardless of time? If so, a conditional like IF (Time between 11 PM and 6:30 AM OR Mode is Away) THEN would work (again, I'm leaving out the contact sensor because these actions will only run when it opens). If you want something else to happen when it closes (I assume your virtual switch as a separate auto-off, for example), then you'd need a "changed" trigger, an ELSE, and you'd need to put this condition in there somewhere. Otherwise, something like the above should work. Good luck!

1 Like

Thanks. I'll give it a shot tonight.

I'm still a bit confused about the conditions. How to they fit into the rule?

Conditions don't do anything unless you use them in your rule as part of an IF THEN (a "full" conditional, also requiring an END-IF to "close" it) or a simple conditional (a one-line IF, nothing you couldn't do with the previous method but less clicking if it's only one action you want to restrict). In other words, you need to use them somehow in your actions. Simply having them defined in "Conditions" doesn't do anything (except make them easier to use later).

1 Like

Thanks for the clarification.

So defining conditions is just basically populating a dropdown menu for use in the actual rule?

Yep! RM usually (always?) creates one predefined condition for you based on your trigger under the assumption that it will save you time because you're likely to want to use it in the rule. You can add more of your own, as you did, beforehand too, or you can create them on the fly as you're building a conditional statement in the rule actions (they'll get added to this list too). It also makes it easier to edit later, since if you just want to change something about the condition, you can do it there and don't have to go back into the rule action to do to.

1 Like

Got it. I think I can do this now. Thanks again for the help.