RM rules not firing when rule-truth conditions change

Excellent!

Always the most fun things to debug. At least the failure case was the common case. :slight_smile:

A case of the left hand not knowing quickly enough what the right hand was doing. Fix is to only use one hand. :sunglasses:

This bug has been fixed in the latest release.

1 Like

Rules seem to be firing now for rule truth changes, but I'm seeing at least one case where a rule that's using another rule's truth as a condition isn't seeing the rule's current state (or I'm not fully understanding how that should work).

Here I have an "It's day" rule that doesn't do anything itself, it's just used a truth source in other rules:

And here's a rule that uses it. Note that although the "It's day" rule says it's condition is true, this rule says "It's day" is not true.

This is because a triggered rule is only evaluated when it is triggered.

Ah, then “rule truth” won’t really work as a global state variable. I was assuming that using ‘rule truth’ as a condition would be like using ‘switch state’ as a condition, where the ‘truth’ value would always just be the evaluation of the rule. (Essentially, I imagined a rule as having an internal state variable that was set to ‘true’ when the rule became true, and ‘false’ when the rule became false, and that ‘rule truth’ was just the value of this variable.)

No, it will work that way. But you were looking at it from the perspective of a triggered rule. If that triggered rule were triggered, and the rule evaluated, it would get the correct value for the rule truth. When rule truth is a condition of a rule, there is in fact an internal state variable that is set as you describe. I'm not sure at the moment why the display above did not show [TRUE] for the rule in your second rule. I guess it would depend on when that rule was setup and the evaluation done that yielded [FALSE]. What happens when you go into the condition (Rule truth of it's day true) and hit Done?

That was the issue I was running into -- the triggering condition was happening, but the actions weren't firing, and the "truth" value shown in the condition didn't change (it still said 'FALSE' after the trigger). It looks like the trigger rule is never re-evaluating the condition rule.

I tried going into the "It's day" rule and clicking Done and then looked at the "Turn on Jason's..." rule -- it still reported the "It's day" rule truth as "FALSE". Then I clicked Done for the "Turn on Jason's..." rule, and it continued reporting the "It's day" rule truth as "FALSE".

Would you try deleting the second rule, and re-entering it. See if that fixes it or not. If not, there is a bug somewhere.

I deleted the dependent rule (“Turn on Jason’s bathroom light in the day”) and re-created it. The new rule still shows the state of “Rule truth of It’s day true” as [FALSE] (although the actual state of “It’s day” is currently true), and it doesn’t run its actions when there’s motion or the bathroom door is closed.

Interestingly, when I change the condition to be “Rule truth of It’s day false”, the condition state is still reported as [FALSE]. It doesn’t look like the condition is ever being evaluated (it’s constantly null).

I created a virtual switch to hold the state of the “It’s day” rule (so that when the rule becomes true it turns the switch on, and when it becomes false it turns the switch off), and modified the “Turn on Jason’s…” rule to use that switch state instead of “Rule truth”, and the rule works properly.

Also, my standard rules that use ‘Rule truth’ as a condition (rather than this triggered rule) seem to be working. At least, my “Good morning” rule ran this morning. However, my “Good day” rule, a standard rule that uses “It’s day” as a condition, shows the value of “Rule truth of It’s day true” to be [FALSE], even after clicking ‘Done’ in the “Good day” rule.

I should have mentioned that any dependent rule needs to be opened and hit Done. I’m out of the office today and can’t check the code until tonight. Because the way rule truth is updated to dependent rules, it’s probably a good idea to open dependent rule first, hit Done, and the the source rule, hit Done.

I am having similar issue even after 706 update.
I have 2 rules one checks if I am present between at 5-50A - 5-55AM, if true mode changes to HOME.
Second rule checks if I am not present between 6AM - 6-10AM , if true mode changes to Away.
Neither worked today.

This is not related to the subject of this thread. You would need to show some logging of these events, and other supporting information (app state, rule screen shot, device detail, etc) for us to diagnose your situation.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.