Order of execution: RM vs logs vs apps, what happens when?

I am working on app that monitors my door locks' event text description and sets several virtual switches based on lock events that can't be evaluated in rule manager, specifically manual locking/unlocking actions versus keypad lock/unlock. They're both the same as events but the text description is different.

I also have rules that are triggered by the lock/unlock events and rely on settings of the virtual switches set in the above app to control actions.

So what is evaluated first by HE? Rule machine, event log, apps, or does everything happen in "parallel".


Theoretically, everything should happen at about the same time; my guess is that a "smaller" purpose-built app like yours is like to finish executing sooner than large app like Rule Machine, but the difference is likely to be small enough that the order would more or less seem random each time.

If your rules depend on your apps, I wouldn't count on consistent behavior here. I'd do something to make sure it happens. If your rules use conditionals to check virtual switches or other things modified by the app, you could just put a delay in your rule before the conditional action (a few seconds should be more than enough, but you'd probably want to test). Alternatively, you could trigger on that virtual switch changing (if it does change--the stock drivers won't cause an event unless they do, so this may or may not work depending on what you really want to happen when). If nothing else, you could also use a dedicated virtual switch that you turn on when the rule is done executing so you know for sure--or at least that's an easy-ish way. Since you're writing a custom app, you could also use the Rule Machine API there to just do something like call a certain rule's actions (or whatever you want) when you're done. Or you could just put the logic for the rules into the app. As usual, lots of options. :slight_smile: