OH 4.0.4 Startup Order (for files)

There has not been the ability to control the order that config files are loaded since OH 1.8. There is no ability for you to change this. Since then the startup of OH has always been an asynchronous affair and sometimes the timing doesn’t work out.

In OH 3 and OH 4 there was introduced “system runlevels”. Items get loaded before runlevel 30. Rules get loaded at 40, the rule engine starts at 50, Things are initialed at 80.

In practice restoreOnStartup is often still occurring when runlevel 40 is hit.

But your error isn’t caused by Items being loaded after the rules. It’s being caused by Items receiving events that triggers rules before the rule engine has started.

It’s complaining about systemStarted and Thread. You should not have an Item with either of these names. These are reserved words, not Items.

Usually you see this error in cases where the rules start triggering before the rules engine is ready. And you can see that in the logs. The errors occur before “Rule Engine started.”

Often this occurs when there was an update or when you clear the cache because it takes some extended amount of time to download the add-ons and OH doesn’t wait for that before it continues with the startup process. Clearing the cache in this case is definitely going to exacerbate the problem.

I don’t know if there is an issue open for this or not. I’ve worked around it using Delay Start [4.0.0.0;5.9.9.9] but I only have a couple of rules that have a lot of Items which update frequently and frequently trigger rules to run between run levels 40 and 50.

If this happens on every boot, I recommend filing an issue. In the mean time you should be able to use the rule template above to block execution of rules triggered by Item events