Need help with a Rule

I tried my best to search the forums and figure out how to create this rule on my own, but it isn't working as expected.

What I'm looking to do:

I have Ecobee Room Sensors and want to utilize the motion ability to trigger my living room fan on between the hours of 8am and 11pm when there is activity on any one sensor, and shut it off outside those hours OR during those hours when BOTH sensors show inactivity. I want the shut off to be delayed 10 mins and to be cancelable should the sensors show activity again during the delay period.

So far this is what I have

I'd think of a couple of things...

First, can you break this down into two rules and make it a bit simpler? You could use the predicate condition function to manage the time windows.

Second, the order of logical operators is important. AND gets processed before OR, so A and B or C is true if A&B are true or if C is true but not if A and (B or C) are true.

I could use two different rules, but where would the fun in learning how rule machine works? lol

You gave me a bit of useful info about the logical operators. I'm going to try changing the order to follow the order.

1 Like

I'm not sure why the Time and NOT Time are both showing as True in your conditions. It should be one or the other as True, not both. That said, there are many ways to achieve what you want. I like using Wait actions but sticking with your rule as written, I would make the Time a predicate condition and remove it from both of your conditional actions. I would also put a 10-minute delay on your Notify action and make it cancelable or you'll get a notice the fan was turned off 10 minutes before it happens.

The one issue I see, though, is if one of the sensors is active at 11:00 PM (or just before) the fan won't turn off because of the predicate condition. How often will this happen? Is this just an edge case that can be address by turning the fan off manually? You'll need to figure that out but this is where Waits have an advantage over a delayed action. You could get around this by having a second rule to shutoff the fan at 11:10 PM.

Going back to your original rule, it should work if you make your motion conditions sub-conditions. For example, it would be IF (Time AND (Main Floor active OR Living Room active)). Notice the ( and ) around the motion conditions. Again, I'm not sure why Time and NOT Time are both True. Perhaps this is a bug that should be reported.

I noticed that too but I was reading the NOT for the (T) true condition. If that condition is true, NOT that. Figured that would prevent me from creating a rule with times from 11:01PM to 7:59AM.

Thanks for your reference to WAIT actions with regards to the fan shutting off after 11pm.

I'm going to rewrite the rule with subs for the motions.

Thanks!

LOL! Simpler is sometimes better even with RM. Plus, you can always get the logic working with two rules and then decide to collapse them into one!

2 Likes

I did have a simpler on/off rule based on time, but figure whats the fun in that if I don't expand and use conditions. Pretty confident once I wrap my head around how these rules are processed, I can better understand them to create other rules.

1 Like

Just curious, how would you use the WAIT command to process the action so that it's cancels within a specific amount a time when a condition changes?

@hypnosis4u2nv Waits are automatically canceled every time the rule is trigger and will still "work" outside the predicate condition. Once a Wait is scheduled, it will remain until it is met and continue running the actions regardless of the predicate.

Here would be my approach:

Predicate:
Time between 8:00 AM and 11:00 PM

Trigger:
Main Floor, Living Room any active

Actions:
On: Living Room Fan
Wait for rule: Main Floor, Living Room all inactive  --> duration: 0:10:00
Off: Living Room Fan
Notify: .....
2 Likes

Gotcha. I was looking at WAIT totally wrong, so your explanation clears that up.

I guess outside the time predicate the rule would work and the fan should shut off. I was trying to prevent it from turning on during those hours outside the predicate, say I was to get up in the middle of the night for something.

Just to be clear. Outside of the predicate, the rule won't trigger so the fan won't turn on; however, the Wait will still run and the fan will turn off.

1 Like

So far the rule is working fine, only quirks are the fan will turn off after 11pm when it first notices inactivity and I get notifications throughout the night that the fan turned off even though an inspection of the event log for the an showed no activity from the time it turned off till it turned on in the morning (after 8am). The sub conditions helped straighten it out.

Cancel Delayed Actions
IF (Time between 8:00 AM and 11:00 PM(T) AND
( EcobeeSensor: Main Floor (Thermostat) motion(active) active(T) OR
EcobeeSensor: Living Room motion(active) active(T)
) [TRUE]) THEN
On: Living Room Fan
END-IF
IF (NOT Time between 8:00 AM and 11:00 PM(T) OR
( EcobeeSensor: Main Floor (Thermostat) motion(active) inactive(F) AND
EcobeeSensor: Living Room motion(active) inactive(F)
) [FALSE]) THEN
Off: Living Room Fan --> delayed: 0:15:00(cancelable)
Notify Pak's Phone: 'Fan Turned off at %time% due to no motion or evening time.' --> delayed: 0:15:00(cancelable)
END-IF

@hypnosis4u2nv Looking again at your rule, that's an expected action. Your rule will trigger on motion changed so anytime one of your motion sensor goes active or inactive between 11 PM and 8 AM you'll meet meet the second conditional action and get the notice. You'll need to rethink your logic or could use a variable to track whether to send the notice.

I encourage you to use a rule that you understand and I think making this work is a great learning experience. What you think a rule should do vs what it actually is doing is always fun (or not) but if you want a quick solution, my approach above should work.

I absolutely want to learn and getting this working in a more difficult way at least gives me a better understanding on how it works so I can "see" what to expect the rule to do.

Definitely going to try and fix the notification aspect, I can live with the fan shutting off after 11pm with the first sign of inactivity, otherwise I would have to create the additional rule to shut off at 11:00pm.

I will also experiment with the wait rule you posted.

Thanks much for all the advise and information shared!