Rule Machine - Get peer assistance here with setting up rules

Thank you, I’ll try this.

Reposting someone bamarayne :slight_smile: might be up for figuring this out.

Turn on a light switch at sunset and keep it on until 10pm. If the TV is drawing power at 10pm leave the light switch on, otherwise turn it off. If the light switch stays on after 10pm, because the TV is drawing power, turn off the light switch 10 minutes after the TV stops drawing power. I think what bravenel provided will cover this, although I must have missed something because the light only came on if the TV was on.

If the same light switch is off after 10pm and a motion sensor detects motion turn the light switch on for 10 minutes. If during that 10 minutes the TV starts to draw power then leave the light on until the TV stops drawing power and then turn the light switch off 10 minutes later.

2 Likes

Yeah, I’ll work this up for you, but it is going to be more than one rule. Not a problem.

Give some time, I’m in the middle of a project… I’ll post it here later tonight.

sweet! Thank you! I’m really looking forward to having this in place.

How do you update rule machine? I’m probably running the initial source code. I just copied and pasted something someone steered me to. Do I need to manually update the code anytime bravenel updates it? Do I update rule machine or do I update the rule trigger?

@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.

2 Likes

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

2 Likes

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

1 Like

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.

1 Like