App keeps losing its subscription to events and thus stops triggering

I'm on a C-8 running 2.3.7.140. Been having trouble with rules not triggering because it's not subscribed to events. I thought the one rule was corrupt, so I actually recreated it from scratch. It worked for a while, but then stopped working. When I noticed that the app wasn't subscribed to any events, I reinitialized it (by clicking done) which re-subscribed it to the events, but the app seems to lose its subscriptions again at some point and stops working. Here are the details:

Trigger set on rule:

Hub Variable Changes:

No trigger on the app (logging is turned on for example app 2196):

No event subscriptions in the app (2196):
image

What would cause an app to lose subscriptions like this (other than a bug)? I will continue to monitor it to see if I can tell when the subscriptions are lost, but not seeing any pattern yet.

Required expression false. What controls the private Boolean ? (It can be controlled from other rules, regardless of the “private” qualifier)

Thanks... I didn't realize that the app actually unsubscribes from events when PB is false. PB is set to false at the start and to true at the end of the rule. There are no exits in the rule (or long waits), so perhaps something is happening that is killing the rule mid-run, keeping the PB false. I don't think I'm changing this PB from another rule, but I'll need to check that also.

I've also been having a bunch of weird stuff happening on this latest version (Z-wave issues, things not triggering, Room Lighting misbehaving), so maybe I'm conflating this issue with the others.

To be a bit more precise, the rule doesn't unsubscribe when PB is false. The rule unsubscribes when the required expression is false. In your case those two are equivalent, but any false required expression should remove the subscriptions.

I don't see your rule actions, but something must be stopping the rule between when you set the PB false and when you set it true again.

From another post:

2 Likes

Actually, I’m not losing my mind like I thought I was. This happened again today. Below is my required expression which shows that the only requirement is the private boolean being true. In the logs that I posted below, you can see that after the private boolean was set to true at 13:59, the App switched over to required expression being false. The required expression only returned to true again at 22:38 when I reinitialized the app this evening after I realized that the rule was no longer running upon trigger events. Prior to reinitializing, the app had no event subscriptions, as would be the case if the private boolean was false.


The rule unsubscribes from events when the Required Expression becomes false.

Could very well be. It can be challenging to get to the root cause. Logs are the best way to sort out the sequence of events that are happening as expected, or not happening as expected.

Without showing the entire rule, those logs don't really tell us everything that may be relevant.. Why did you hit Update? Please show the entire rule. Also, please show what happens when it runs from start to finish (logs), by hitting Run Actions.

The portion of the logs that I pasted clearly shows that the required expression went to false after the Private Boolean was set to true, so I thought that was enough. I hit done on the app because the required expression was true but the app had no event subscriptions, so I needed to initialize it again to get the event subscriptions to work and continue triggering the app. Below is the full rule along with the original event that didn’t complete correctly, the event at that shows what should actually happen, and then the most recent event, where the rule broke again… the private boolean was set to true, but the required expression was set to false. Note that when the error happens on the rule, from the app page, the rule displays required expression false in red after the name of the app, but when I open the app that red lettering of required expression false goes away. However, if I go into the settings of the app, there are no events subscribe to. That’s why I have to reinitialize the app. Even now the required expression on the app says true, but there are currently no event subscriptions for the app. I will leave it like this for now in case you’re able to take a look at it, But in the meantime, my heating rule will not be running correctly until I reinitialize it.





This morning I updated to 2.3.7.141, and upon hub boot up the app was not subscribed to any event subscriptions even though the private boolean is set to true and the required expression is true. I'll leave it in that state.

Have you tried having the hub evaluate the required expression on startup? This is an option when creating/editing the required expression in the rule.

Ah, yes, good callout. That may solve the the issue for startup (although it shouldn’t be needed for startup - none of my other apps have this turned on). Unfortunately the app is still losing its event subscriptions during the course of normal operation, so won’t be a full solution.

So… I just set the rule to “Evaluate at Startup” and rebooted the hub, but despite the private Boolean being true, no subscribed events.

@bravenel - Any ideas as to what may be going on here?


I have no idea. Why don't you try removing the Required Expression entirely, then hit Update, and see if you get the Event Subscriptions.

Make an export or clone of the rule.

Agreed. The only time this should come into play is when a condition could be changed and missed while the hub is booting (eg. Sunrise/Sunset/etc). Thought it might be a way to force it to recognize, similar to clicking the update button.

I often try to pretend I am an idiot (which isn't as difficult as it should be) when I am troubleshooting and try things that I think may not work or am convinced will not work. If they do work, then I work on figuring out why so I can prevent the issue the next time .

2 Likes

Hitting update even without removing the required expression restores the event subscriptions. The problem is, after run, the rule reverts back to “required expression = false” and drops the event subscriptions again as shown in the logs.

I’ll try this. But I have already rebuilt the rule from scratch and it’s still happening. Won’t a clone or export>import just replicate the issue if there’s something wrong with the rule itself?

I was just suggesting that you make a backup.

OK, so I need you to try my suggestions, not improvise. Remove the entire Required Expression, then hit Update. Confirm that there are the expected Event Subscriptions on the App Status page. Then, on the Actions page, make sure that Private Boolean is true, if not, set it to true.

Once that's done. Recreate the Required Expression from scratch, and hit Update. Confirm that the Event Subscriptions are as expected. Next step after that is to Run Actions with Action Logging on. Post those logs.

Ok, I followed your instructions exactly. Here is the result. The required expression went back to false after private Boolean was set to true:

After the actions run, the app showed (required expression false)

I refreshed the page using browser refresh, and the “required expression false” was gone, but…

There are no event subscriptions:

Please remove the delay on the Set Private Boolean true action, and do Run Actions again. Post the logs.

That seems to have done the trick. The delay is messing it up?

I don't know, I don't see how it would. Why did you think you needed those final delays? If it works without the delay, take the win.

I'm not able to reproduce anything like this at all. I setup a skeleton rule, and it works exactly as expected:

I have the PB delay because this rule runs actions on another rule which can make changes to the devices that trigger this rule, so I am giving those devices time to change without re-triggering this rule.

I’m going to try adding a separate “wait for event - time” and keep the delay off of the PB action.