Hi I came up with an idea to “precompile” rule files after openHAB was started or a rules file was refreshed. This is working for OH2 only, because OH2 is “compiling” a complete rules file, if one rule was triggered. In OH1 each single rule was compiled separately. With OH1 I used to trigger each rule once, after editing it, to be sure my girlfriend has a good experience with our home automation setup and each button press will result in an immediate response. As a result I was running 10 minutes through our house to press every single wall switch combination.
With OH2 it takes a huge amount of time if you trigger a rule from a big rules file, but you have to trigger only a single rule to compile all at once.
Now in OH2 all you have to do is creating a rule in each rules file which triggers itselfs and voila, all rules are “precompiled”. System started event is triggered in every rule if openHAB starts or a rule file was touched. That’s it. Works very well and full automatic. Never ever worry about bad first response times anymore.
//### Rule warmup
rule "default.rules loaded Event"
when
System started
then
logInfo("Warmup","default.rules warmup completed")
end