[Reactor] Variables not updating correctly in latest-25201-2aa18550
-
After updating to latest-25201-2aa18550, I found that an old rule (probably 2-3 years old) has started experiencing a weird behavior.
As you can see from this screenshot:It seems that while rain variable is false and wind is true, debugmessage (and other similar variables) are not updated correctly. If I press on the Play Icon on the variable inside the rule, it is then updated. It was working OK previously, so maybe it's the new version.
As you can see from this screenshot, the first one is updated manually, but the second one is still showing the old value:
The rule has just some action in the SET part doing notifications and calling MQTT endpoints for logging.
Anyone with the same problem? /cc @toggledbits
-
No changes have been made to variable evaluation for some time. Definitely no changes for 25201.
In your
raintripped
variable, you make reference tobadweather_trigger
andbadweather_lastevent
, but the source for those isn't shown. If their values don't change (even if they are evaluated by some other mechanism),raintripped
will not be updated. The use oftime()
does not generate any continuous evaluation, so this (raintripped
) variable is entirely dependent on those other two variables changing value (not just being evaluated). Same applies towindtripped
.If you have been editing these, particularly the deep dependencies like
debugmessage
, you probably will need a restart to get a full deep dependency scan. Current versions of Reactor can't do a full-depth scan when you edit a variable and add dependencies in mid-run. So I recommend a restart after making changes when the dependencies may run deeper than one level. -
I'm 100% sure it used to work before. I did a restart and nothing changed.
I have "Force re-evaluation of expressions and conditions" in the rule and I was under the impression that was forcing updates. Now back to change a couple of rules that have the same problem. I'll move them to Script Action to set the values, but as I said I'm 100% sure it used to work OK before.
Thanks. -
Clearly there's a lot of context you haven't posted, so I really don't have enough to go on.
I can tell you that if a rule is in mid-evaluation, the re-evaluation of variables and triggers in the same rule won't happen instantly or more than once -- infinite loops have to be prevented. What will happen is that a request for re-evaluation will be queued for later, but it's not deterministic when that runs (except that it won't run before the current evaluation completes). If there's already a pending request for re-evaluation queued, new requests are ignored. This is all to prevent infinite loops in rule evaluations where rules manipulate devices and rule-based variables in Reactions that are also part of the rule's dependencies.
And to be specific, the "Force re-evaluation" only queues a request to re-evaluate the rule's triggers and local variables at some point in the future. It does not instantly and immediately re-evaluate every dependent variable of the variable being set.
-
Ok, I was probably lucky in the past, I don't know. I could send you the rule's JSON if you want to take a look. Anyway, I'll try to move some logic into set variables for the time being. Thanks.
@therealdb I noticed a similar behaviour with build 25208, although the issue might have been present also in the earlier (25201) build.
In essence I have a rule with a global variable correctly triggering when it has a certain value, but in reactions it has a Telegram notification using a local variable as message (like this: ${{ msg }}). And this local variable "msg" is using the same global variable that triggered the rule, but its value is something totally different, i.e. seems that it's not updating.
I'm also sure this rule was working fine before, with variables correctly updating.
-
@therealdb I noticed a similar behaviour with build 25208, although the issue might have been present also in the earlier (25201) build.
In essence I have a rule with a global variable correctly triggering when it has a certain value, but in reactions it has a Telegram notification using a local variable as message (like this: ${{ msg }}). And this local variable "msg" is using the same global variable that triggered the rule, but its value is something totally different, i.e. seems that it's not updating.
I'm also sure this rule was working fine before, with variables correctly updating.
@tunnus said in [Reactor] Variables not updating correctly in latest-25201-2aa18550:
In essence I have a rule with a global variable correctly triggering when it has a certain value, but in reactions it has a Telegram notification using a local variable as message (like this: ${{ msg }}).
You know what to do (i.e. what I need to see). I can't do anything from just a post like this.
My simple test case:
- I have a global expression/variable
testVar
(expressionless) with a numeric value assigned. - I have a rule that triggers on
testVar
changing, and sends me a notification in its SET Reaction (shown below). - I have a Reaction that I can run manually to increment
testVar
by 1 using a Set Variable action. This triggers the rule.
This works as expected: when the Reaction is run,
testVar
is incremented by 1. The change is detected by the rule, which updates itslocaltest
variable and then uses that in a notification, which displays the correct value.To be clear here, the Rule triggers on the global variable changing, not the local variable.
- I have a global expression/variable
-
@tunnus said in [Reactor] Variables not updating correctly in latest-25201-2aa18550:
In essence I have a rule with a global variable correctly triggering when it has a certain value, but in reactions it has a Telegram notification using a local variable as message (like this: ${{ msg }}).
You know what to do (i.e. what I need to see). I can't do anything from just a post like this.
My simple test case:
- I have a global expression/variable
testVar
(expressionless) with a numeric value assigned. - I have a rule that triggers on
testVar
changing, and sends me a notification in its SET Reaction (shown below). - I have a Reaction that I can run manually to increment
testVar
by 1 using a Set Variable action. This triggers the rule.
This works as expected: when the Reaction is run,
testVar
is incremented by 1. The change is detected by the rule, which updates itslocaltest
variable and then uses that in a notification, which displays the correct value.To be clear here, the Rule triggers on the global variable changing, not the local variable.
@toggledbits I did a very similar testing arrangement and got the same results as you, i.e. working fine. I guess I have to monitor this more closely and if this update problem happens again, find a way to reproduce it consistently.
One notable difference between my production expression and the test expression is that the production one is a lot more complicated:
- I have a global expression/variable