Rule Machine - Get peer assistance here with setting up rules

@Rooster9376
It’s in the OP of the main Rule Machine thread.
I think it’s called, “[Release] Rule Machine”

Here ya go…

Specifically, these two sections…
How to Install or Update Rule Machine
and
GitHub Integration

:slight_smile:

Would you please get the latest source from Github for both Rule Machine and Rule.

Rule Machine github: https://github.com/bravenel/Rule-Trigger/blob/master/smartapps/bravenel/rule-machine.src/rule-machine.groovy. Save and Publish for me.

Rule github: https://github.com/bravenel/Rule-Trigger/blob/master/smartapps/bravenel/rule.src/rule.groovy. Save and Publish for me.

Ross,
I’ve got this worked up for you. It should work. I got stumped on for a bit cause I was approaching it wrong… but this should absolutely work.

If it does, please let me know. If it doesn’t, most definitely let me know.

You will need to make 3 separate rules.

Rule #1 -
Conditions - sunset-10pm, private Boolean of this rule false
Rule - sunset-10pm OR private Boolean false
Actions for true - turn on switch
Actions for false - turn off switch
edit restrictions - only between sunset and sunrise

Rule #2 -
Conditions - tv on
Rule - tv on
Actions for true - private Boolean of rules #1 & #3 set to false
Actions for false - delay 10 min: private Boolean of Rule #1 & #3 to true

Rule #3 -
Conditions - 10pm-sunrise, Morin active, private Boolean of this rule true
Rule - 10pm-sunrise AND motion active AND private Boolean true
Actions for true - private Boolean of Rule #1 to false
Actions for false - pending delay 10 min: private Boolean of Rule #1 to true

Thank you. I’ll report back the results. I’m excited about this one :smiley:

Bruce,

Thanks for the assistance. This is working well for now, but I’ve noticed one small issue: Because the arrival rule won’t run unless the Boolean is set by the departure rule, the arrival rule can only run once, and then the departure rule needs to run again to flip the Boolean so that arrival will run again.

My wife is a teacher, so she frequently gets home before me and RM runs the arrival routine. When I arrive home a few hours later, the routine won’t run since she didn’t leave the house and cause the Boolean to flip the other away again. Any ideas? I’m sure there is a way, but your brain seems to understand how these interactions work much better than me, so I’m hoping you see an easy fix. :slight_smile:

General answer: use a separate Conditional Trigger (or Rule as needed) for each of you. Have the arrival rule flip the boolean back.

Are you saying I should split the current arrival rule into two rules that each flip their own booleans while the departure rule flips them both the other way? If so, wouldn’t that mean that the arrival rule wouldn’t run if someone left the house and came back while the other person never left? Sorry, I’m just not sure I understand.

This is sounding confusing. In the first case you were dealing with what happens when both of you leave, and how to prevent “false positives” for departure.

Now, you want the same thing to happen when either of you return? So that puts you right back where you started with the false positives problem. How will you know that you have actually arrived, not just experiencing a false positive after you are already home?

So yes, one departure rule that “arms” two arrival rules, one for each of you, if you want the same thing to happen when you each return. You could probably get fancier with different things for the first person to get home than for the second.

I’m probably doing a poor job of explaining this. My apologies for that. Let me try to start over:

Basically, I have certain actions that I would like to take only when the first person arrives (turning on certain lights) and actions that I would like to take when each person arrives (opening the garage door). That would also be my end goal for departure, so basically four different sets of action.

Right now, I’m taking care of the “first person to arrive” part by leveraging the mode condition in a separate trigger as my arrival and departure routines cycle them, and it seems to work fine. Likewise, each person arriving opens the garage door without an issue. I currently have only one action taking place on departure that executes when everyone departs, but I figure I can get more granular with that as time goes on, likely by leveraging the same mode change trigger.

My struggle was that b/c presence is so flaky for me, I have to use a virtual presence sensor to combine multiple sensors, and without a delayed action, they would change all the time. The “All Depart” rule with a 10 minute cancel easily solved false departures, but I still had an issue with the false arrivals, so that’s when I reached out for help.

The Boolean solved the issue of the necessary 10 minute away time before running an arrival rule, but obviously introduced the new issue of it not running when each person arrived home without a departure in the middle. It sounds like I may just need to split some of the rules up and get more granular from what I’m reading you say. Let me know if I’m simply over-complicating this. Perhaps there is an easier way to do what I’m trying to do without making this difficult. Either way, I appreciate your help.

You are on the right track. You will need separate arrival rules to do what you want. The first arrival is easy because mode is Away. Second arrival has mode not Away. Presumably both need the false departure/arrival bit.

Is pending delay in rule #3 the same as delay 10 min? I couldn’t find the pending delay.

All that came through is the one rule. Please send all of them. And no, that should be pending with cancel.

Here are the screen shots. I can’t find the pending delay for rule 3.

If you go into Control Switches, Capture/Restore, the option for “Turn on or off these switches after a delay, pending cancellation (default is OFF)” option is the 5th option in the list. On my phone, I have to scroll to get to it as it’s just past the first page of items in that list.

Got it. Thanks!

Ok, I think I know what the problem is. This rule “Kitchen Sink Motion” is wrong.

PM me.

Is there a difference between an event and the state, for example, door just became open, as compared to the state the door is open?

So for example, suppose I want to turn on the light to the basement staircase when the door opens, but do NOT turn off. That will be done manually.

So I open the door, light goes on. Then when I want to turn off the light, I use the light switch to turn off the light, but in order to use the physical light switch the door must be open.

Is this a conflict of state? Or is this simple?

In the rule machine is a trigger processed different then the same condition in a rule?

So for checking motion, is placing the condition in a trigger evaluated differently than in a rule?

You can think of them to be essentially the same.

In a trigger, the contact becomes open is an action causing the trigger to evaluate. When you turn off the light the trigger will not see it as off and evaluate the rule again.

In a rule, the state of the contact is seen. Open. When that contact is open, the rule is true and the actions for true are evaluated.

It’s all about how you write the rule. You have several options.

I recommend you do this, based on what you have said.

Trigger - contact opens
Action - turn on light

It’s really that simple. Every time the door opens the light will come on. It will not turn off until you physically turn it off. To turn it on, the door must actually open, or of course, press the switch.

And yes, if you piss the switch with this rule, the light will come on even when the door is closed.