Hi all,
I am in the process of migrating to OH3 from OH 2.5. I ran into some connected problems. I am hoping that there are others that might help solve these problems, or at least this post might help others facing the same problem. The problems I ran into are:
- My solution to the delayed execution of a rule in OH2 doesn’t work in OH3
- If a .rules file is modified or renamed, the
system started
trigger part of the file is not processed. (The documentation states it should be.) Let me elaborate.
A Delay in first time a rule is run and old fix
In OH2 and OH3 there is a problem that the first time a rule runs this rule takes (a lot) more time than normal. A solution under OH2 was to include a system started
trigger in each .rules file like this:
rule "System started"
when
System started
then
logInfo("System started Rule", "done")
end
The effect of this rule is that the rule file was loaded at startup and you had no more delay. See for example:
B Clean up startup process
At the same time I used a trick to clean up the startup process. This trick is to rename the .rules files at shutdown and rename them a X number of seconds after system startup. The effect is a much cleaner startup process. This was also incorporated in the last version of openhabian I used, before I temporarily switched to docker to be able to switch between OH2 and OH3 to migrate my system. I don’t know if this is still in openhabian. See:
C Changes in system startup
trigger under OH3
Under OH2 saving or renaming a rules file would trigger the system startup
trigger part of that .rules file. This is no longer the case, although the documentation still states that it does. The documentation states:
System started is triggered upon openHAB startup, after the rule file containing the System started trigger is modified, or after item(s) are modified in a .items file.
However it is no longer the case that system started is triggered if a rules files is modified. See:
A + B + C is headache
The effect of the above is my current headache. As a result of the changes in system startup
, the .rules files are not preloaded after they are renamed. As a result the fist time a rule is executed it is delayed. This causes a sluggish first time performance of OH3. Of course after a while most of the rules have been triggered, restoring the normal performance for the most part, but WAF is down.
Furthermore, some .rules files need the system started
trigger to do stuff after they were reloaded in order for them to function properly. This doesn’t work anymore.
My questions / solutions
Does anyone see a way to solve these problems? Is there a way to speed up the first rule execution on OH3 and is there a way to run stuff when a .rules file is modified?