Condition (not used) How to use?

Last night in one of those rare instances that only occurs in dark bedrooms between two consenting adults, my wife asked me if I could set our dresser light to turn on red overnight if someone is walking around to avoid tripping dogs and mostly black cats. I set out trying to set up Rule Machine (I know there are other options). When I was trying to set the condition, Motion, it said not used. Even after completing and installing the rule. How do I use it? I don't recall seeing this until the last few months. I wound up setting the rule up in Room Lighting but would like to understand this if I want or need to use Rule machine in the future.

Edit: I now think motion lighting COULD be another option, but honestly, I expect this rule to grow and get more complicated with several schedules to be added as I figure it out.

Conditions are used in either conditional triggers or if statements in actions. When you create a condition, it is unused until you actually put them into a trigger or action.

3 Likes

Are you talking about it saying "Not used" here?

If so, that just means you created the condition, but haven't used it yet anywhere within the rule itself. So it's basically just in a "readily available to use" status.

2 Likes

Yep. but I also couldn't see how to use it anywhere else.

As JB10 said, you'd then use it either in a conditional trigger or an If-Then statement in the rule.

You don't have to create conditions pre-emptively. You can, but it's not a requirement. You can instead just create them as-you-go building the rule itself.

But either way, your conditions will show up in that block there. The main reason is that they are then easier to edit in the future... In many cases, when you need to edit an existing rule, it's often the condition that needs editing. So being able to quickly edit those from that section makes it easier -- then you don't have to go into the "guts" of the rule to monkey around. And if you use the same condition multiple places in the rule, then just the one edit takes care of them all.

4 Likes

I think where I am getting confused with Rule machine (and have been for a while) is where and when to use conditions.

For example, the rule I was trying to create had a required expression only between 2200 and 0700. but then I was trying to set a condition of when motion is active, action set a bulb to red and 35% brightness. So, is the condition pointless in a situation like that?

Not sure why, but conditions use as Required Expressions don't show up in that block -- those are unique.

In your example, the Reqd Expression sounds good, but why not just use "Motion becomes active" as the trigger?

If you can plain-english what you'd like the rule to do, perhaps we can help craft the construction of it with you.

There are two ways to write this:

Option 1 (no condition)
Required Expression between two times
Trigger is Motion

Option 2 (with condition)
Trigger is Motion (only between two times)

Required Expressions are not considered conditions which why they have their own separate area. Option 2 does not use a required expression. Instead it evaluates the trigger to see if the condition is true. If it is, then the actions run.

3 Likes

For right now. I only wanted it overnight. Eventually I'll try to set up day rules as well. This is for our bedroom and is going to end up with an elaborate and complicated set of rules. For example during the day We want the lilght to comeone white with motion, but i work all three shifts in a week, so Tuesday and Wednesday afternoons and Thursday mornin, I either dont want it to comeone at all, or to cme on red.. Turn off in the evening at sunset, and transition to motion at about 2100. This is the one room i have been Leary about doing too much automation in primarily because schedules and the way we use the room can be complex or erratic. For the first pass Room lighting with time periods seems to work, and i figure I can just layer in the other rules as things evolve. I've run across this before and just found another way around it (like using room lighting), but I may need to use rule machine one day and wanted to understand why this happened and how it works (or doesn't). With the various versions of Rule machine, I've had this tendency to just keep adding layers and really don't get anywhere. I've been really trying to wrap my head around it lately.

For Right Now...
Between 10:00 PM and 7:00 a.m. If the is motion (Hue indoor sensor), set the dresser light (nano leaf essentials) to red at 35% brightness. turn it off after 5 minutes of inactivity. Every day.

  • Eventually we will want to include 2300K @ 40% during the day (except Tuesday and Wed afternoon), with motion.

  • Tues and Weds afternoon similar rule to overnight.

  • Thursday to Monday turn the lamp on at 2300K and 40% brightness at an hour before Sunset and off (or switch to motion activation) at 9:00pm.

Because of all these different periods is why i thought eventually Room Lighting may be better suited.

Not sure if this will be helpful or not, but for RM rules, I first think about my trigger -- knowing in general what I want to build overall, what's really going to kick all of it off?

Sometimes that answer is hella obvious, but sometimes I need to noodle on it (and that's commonly when the conditions I'll need start to flesh out). Once I know my trigger, then I think about whether or not a Reqd Expression would be helpful.

Remember that a Required Expression = False means that the hub won't even bother watching for the trigger. For high-activity triggers (like motion perhaps), that can be a helpful way to help keep hub resources down.

Then, you can use conditions within the rules (If-Then, If-Then-Else, etc) to further refine how the rule executes.

For your criteria above, I'm guessing it's possible to do it w/in RL, but I'd have to defer to someone way smarter on RL than me.

Final thought about RM though... Rules are free; so at least initially here, think about just setting up those various parts as separate rules. There's no prize out there for building the biggest, gnarliest all-in-one rule. Breaking it up into multiple smaller rules is usually the best answer on all fronts.

I was just sitting here trying to write down all the variations I can see needing. There is also currently a rule on that same lamp to turn it on red if I arrive home after 2200 then off after an hour (that part hasn't been remarkably reliable, however. That is the one day a week I get off at 2230. That COULD be jettisoned in favor of the motion rule. I'm not married to Room Lighting. I'll admit Rule Machine does tend to get me a bit twisted up, however the last few versions have been getting steadily easier for me to grasp. For a while I was all in Event Engine. but since that isn't being maintained any more I need to get a better grasp of Rule Machine.

EDIT:

I still have the rule I started to write in my hub, it's just stopped currently. I'll play with it again when I get home and maybe post what ai have. Hopefully, someone can help me walk through it, and maybe find a better way to do all I eventually want to do.

Question, for the turn off portion, are "wait for event" and "delay" the same? Right now, I have it set as wait 5 minutes then the next action is turn off. Would it be better to use delay , or is it all basically the same?

In many cases, effectively the same. But here's the Tip in the RM5.1 documentation that talks about the difference:

TIP: Using Wait for Events with Elapsed Time chosen as the capability is a particularly handy method of delaying actions. Unlike the Delay action (or the Delay? option on an action), waits are cancelled when the rule is re-triggered without any additional configuration required. This can save a couple clicks compared to a "delay" if this is the desired outcome. (Note: the Elapsed time option is not available if other events have already been selected. But in this case, it is effectively equivalent to setting a timeout on that wait.)

1 Like

So here is the Rule 5.1 rule I had. I don’t see how to actually use the conditions

The motion-active is being used as the trigger, so there's no need to include it as a condition too. I realize it's confusing that they say the same thing in that screenshot, but as the trigger, it was built as "motion becomes active", and as the condition, it was built as "motion is active".

Triggers can only ever be events, and Conditions can only ever be states.

The "Time is..." would be a good candidate for the Req'd Expression. Or you could use it w/in the rule in the "If" portion of an If-Then statement.

The "Day In" one isn't doing anything for you, since it's all 7 days of the week -- there's no reason to include that unless you're going to tighten it down to one or just some days of the week.

I originally had the between times as a required expression. I removed that based on @JB10 post above

I guess the way it originally was. Meets his first example.

Something more like this?

Right on -- that is indeed the third option there where you're using it as a Conditional Trigger (which is a relatively new feature). Overall, that's very similar to a Req'd Expression.

The difference is that the trigger (and entire rule) is put off-duty when the Reqd Expression is false. As a Conditional Trigger, the trigger is always on-duty, but it has to check everytime with its condition to determine if it should fire the rule or not.

2 Likes

So I guess the follow along question would be how do i get the light to go back to CT outside those hours?

Working on the folow along rule, how do i cnage OR to AND, so alll 3 conditions (motion active), days and time are all true?

That just turned the light on at 2000. Didn't even look at motion, so never turned it off.

This can’t be done as a trigger for all three conditions. You could move two or all three to required expressions to satisfy the AND. Triggers can only use OR outside of the one conditional allowed.

1 Like