Multiple item and rule files

  • Platform information:
    • Hardware: Synology DS416Play in docker with 8GB ram
    • OS: Docker
    • Java Runtime Environment: from docker image
    • openHAB version: latest snapshot
  • Issue of the topic:
    I’m using multiple item and rule files.
    It seems that on a restart the rules or some of them load before the items are loaded.
    I have to reload the item file and than the rules.
    Is there a command to force the reload of all rules or someting?
    Or can I control the order how the files are loaded?
    I had a similar problem when I wanted to move all groups to a groups.items file.
    The other item files didn’t know the groups than.

08:40:56.734 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'Charging': The name 'pVacAll' cannot be resolved to an item or type; line 196, column 9, length 7 08:41:26.705 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'Charging': The name 'pVacAll' cannot be resolved to an item or type; line 196, column 9, length 7 08:41:56.720 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'Charging': The name 'pVacAll' cannot be resolved to an item or type; line 196, column 9, length 7 08:42:03.334 [INFO ] [del.core.internal.ModelRepositoryImpl] - Refreshing model 'roborock.items' 08:42:03.411 [INFO ] [smarthome.event.ItemUpdatedEvent ] - Item 'gXiaomiVacProx' has been updated. 08:42:03.442 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'Pause update': The name 'vacPause' cannot be resolved to an item or type; line 41, column 25, length 8 08:42:03.470 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'Charging': The name 'pVacAll' cannot be resolved to an item or type; line 196, column 9, length 7 08:42:03.603 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'Charging': The name 'pVacAll' cannot be resolved to an item or type; line 196, column 9, length 7 08:42:04.121 [INFO ] [smarthome.event.ItemUpdatedEvent ] - Item 'gVacPower' has been updated. 08:42:31.781 [INFO ] [del.core.internal.ModelRepositoryImpl] - Refreshing model 'roborock.rules'

The fact that items, rules, persistence, etc are not loading in sequence is well known issue and may only be resolved in future revisions of OH.
There are several workarounds, see the docs for some examples: https://www.openhab.org/docs/configuration/persistence.html#startup-behavior others can be found in the forum…all have benefits and drawbacks. Often the issue can be resolved by simply restarting OH2 a second time or even simpler by waiting until the system settled…the wait and hope techniques are unlikely to work when persistence is used, but the workarounds linked above do help in these cases.

The second workaround looks like the best one.
Thank you for the link.

Is this even nessesary for the item files?
I just wanted to control a device with alexa and the log said this device doesn’t exist.
I touched the items file where the item is declared and now it is working again.

Normally you need the workarounds for rule files only…
I am not aware that item files give problems, however, there is a risk that items are loaded before things (if you have them defined in files)…which occasionally does create issues.
Sometimes clearing the cache can help…Clear the Cache

As I tried to mention earlier, sometime you can see these errors during startup, however, the system will settle shortly thereafter and everything works despite the error. Just try it out.

Now I added a script that clears the cache at the start of the docker container and a rules that triggers 3 minutes after the start to reload all items and rules.
Hope this helps.