Rule not working all the time

I’m still learning how to best set up small “complex” rules and could use some feedback on this one here. It’s not working 100% of the time and I’m having a hard time seeing in the logs why that might be the case. I don’t think the problem is with a Lutron Shades and Hubitat so that is leading me to believe that I still need to work on how to conditionally write my rules.

Goal: IF we are not both not home and the guest “switch” is off, THEN close the shades and turn off the fan.

I’m still struggling to figure out the differentiation of predicate and trigger.

I should mention that the presence indicator is working as expected. When the shades do not go down I look at our presence and it does show that we are indeed away. I also double check the rule and see that the predicate rules are highlighted as true.

I suspect that the “Alicia’s Presence, Dan’s Presence” predicate condition is conflicting with the “leaves” trigger. Try removing them from the predicate to see if it helps.

1 Like

Instead of using a predicate, use an If/Then conditional action inside the actions.

They are quite different. Most rules probably do not have or need predicate conditions, so I wouldn't start by thinking of them first (even though they are at the top of the UI). A trigger is something that makes your rule actions run. So if you didn't have a predicate condition defined in your rule, your actions would run any time either of your sensors leaves.

Using a predicate will stop trigger events from actually triggering the rule when the predicate evaluates to false. A predicate becoming true or false will not cause anything to happen on its own. So in your rule as written, your actions will run any time either presence sensor leaves if both were already not present and that other switch is off. As you can imagine, this doesn't really make sense and is unlikely to ever happen (the times it does work are probably explained by the fact that sometimes the last sensor going away causes the rule to realize the predicate is false first, while other times it sees that the trigger event matches first--i..e, Sebastien's guess above).

So I'd second Silvva's idea above, though you don't need to get rid of both parts of the predicate condition. The Guest Switch would do just as well in either place. If you wanted to leave just that in the predicate, you could do something like:

Predicate: Guest switch off

Triggers: Presence 1, Presence 2 any leaves

Actions:

IF (Presence 1, Presence 2 all away) THEN
  Off: Fan, Shade 1, Shade 2
END-IF

For the sake of completeness, the other way (and the only way you could do this in Rule 4.x) would look like:

Triggers: Presence 1, Presence 2 any leaves

Actions:

IF (Presence 1, Presence 2 all away AND Guest Switch is off) THEN
  Off: Fan, Shade 1, Shade 2
END-IF
2 Likes

Thanks for everyone's replies! I ended up trying @bertabcd1234's example and tested it out and it has worked as expected so thank you for that. I do have one more example that I am struggling with:

IF Temperature is greater than 75, turn on fan. But only do so between the hours of 8am-8pm and only when there is someone in the house.

I already have a rule that turns off the fan when someone leaves, so this rules involves turning that fan back on, but under specific conditions.

Any thoughts would be helpful as I am not sure where to start on this one. :smile:

I have a similar scenario for one of my outlets with a plugin air freshener.

For that, I would do the following:

  1. Set Mode to Away when everyone is away and some other value when at least one person is home.
  2. Create the following rule:

Triggers:

Mode changes
Time is 8 am
Time is 8 pm
Temperature changes

Actions:

If (Mode is not Away AND Time is between 7:59 am and 7:59 pm AND Temperature >= 75) Then
    On: Fan
Else
    Off: Fan
End If

If you don't want the fan to turn back off when the temperature falls below 75, then just change the trigger to Temperature >= 75

Thanks @Sillvva! I’m just loving how powerful Hubitat is. I’ve tried it out and will let you know if I have any issues.