Required expression false but true

Dear all, I see a few historical posts about this. I have 5 rules which have all gone mental in the last week or so. Basically the required expressions are True but they are appearing false in my summary page and also in the rule page heading. Ultimately, they're not triggering because the rule seems to thing the required expression is false. If I hit "update rule" it corrects itself but I can't do this continually. Any help would be appreciated. See screenshot of one of the 5 rules which shares this problem.

1 Like

Is that variable in your required expression a hub variable or a local variable?

Hi Robert, this is a LV, is there any mileage in swapping these out and using. HV. It's really odd behaviour

Hi Robert, this is a LV, is there any mileage in swapping these out and using. HV. It's really odd behaviour. It appears to be a bug

Yes, you should switch them out for hub variables if you want to use them in a required expression. Local variables do not generate events and will not update the evaluation of the required expression when they change. Hub variables will.

2 Likes

Brilliant advice Robert and thanks once again for your wisdom. Is this intentional or more of a bug. I'll keep you posted on progress

Intentional. Event subscriptions have to be to things outside of the rule, and a local variable is internal to the rule -- nothing outside the rule has a direct way to affect its value. Something has to cause the required expression to be evaluated. There is an exception to this for Private Boolean. However, it's worth pointing out that Private Boolean can be set from outside the rule, by another rule.

1 Like

Thanks Bruce, that gives me some understanding. I'll update with HV's and then close the thread as solved when things commence working as expected. Appreciate your speedy response as everπŸ‘

I had a couple of these pop up today. Required expression showing as false so the rule doesn't trigger but it's actually evaluating as true. If I hit done then it clears the problem. Unfortunately, logging is not enabled. Anything else I can share to help figure out why this is happening?

Wow I never put that together. I have a rule 5.1 that didn't work right and it's because i was using a local variable in the required expression.

the rule kept triggering itself, i wanted a way for the rule to be triggered on the device page or the physical button, but not rule machine.

maybe the "find broken rules" can also find those.

It's a bit of a tough choice what to do with these. If it disallows local variables in the Required Expression (one way to solve it), I suspect that might be a problem for some users.