Required expression not working how I'd think?

I'm on version 2.3.2.135 and am seeing what I think might be new behavior but I did recently modify the required expression for two rules so maybe I just never noticed this before....

I have two rules that have very similar required expressions:

The desired intent is to never run this rule unless someone is actually home. As seen in this screenshot, I'd expect this to not run since the expression evaluated to false.

However, I have another rule that changes the thermostat settings when we leave and in doing so, is triggering this rule which is unexpected since the away rule can only ever trigger if the presence changes. In the log shown below, app 936 is the rule that changes the setpoints when we leave and it is triggered because "Any Home, All Away" was not present (shown in log). After it changes the thermostat (at 2022-07-10 01:21:30.165 pm), we see app 934 get run even though, as shown in the screenshot above, the required expression is false at that time.

Am I misunderstanding how the required expression should work? If so, is there a better way to do this other than maybe a PB for app 934 controlled by app 936?

@bravenel - any ideas? thanks!

No way to tell with what you've shown. I can't tell what's what in those logs. You may have a race condition if everything is happening due to the same triggering event: by that I mean the other rule changing the thermostat due to you leaving AND simultaneously this rule's required expression becoming false for the same reason. No way to predict which will happen first.

If that is the case, in the other rule delay the thermostat change by a few seconds so that this rule has a chance to flip its Required Expression.

I've highlighted the relevant log snippets --

  1. app 936 fires at 01:21:07.002 because the presence device is not present
  2. app 934 fires at 01:21:30.205 because app 936 changed the thermostat

app 934 has a required expression that says the presence device must be present. I agree this could be a race but am finding it hard to think that after 22 seconds app 934 didn't see the presence device as not present and thus not meeting the required expression. There's already a 20 second delay in app 936 prior to changing the thermostat so there was plenty of time for app 934 to recognize presence changed.

What would you need to see that would help more than the logs and rule info?

Full rules in case that's helpful:

  1. app 936

  2. app 934

Never mind. There is a bug, and I can see it. It has the wrong subscription for the presence in the Required Expression. I will get that fixed.

We will be doing a release tomorrow or the next day...

2 Likes

Sure, here are event subscriptions for app 934

The problem is presence.present

That causes it not to see the departure event to flip the Required Expression. As in interim work-around, you could use another rule that sets a variable based on presence changes, and use the variable in the Required Expression.