Rule triggering after 'Refreshing model'

Is it possible to write a rule that triggers after saving an edited .items file, when the log message:

Refreshing model 'xyz.items'

is written?

I don’t think it is possible with normal openHAB triggers but there is a logreader binding that maybe of some use.
Or you could always implement your own routine in python for example to watch over the log file and trigger OH when that string appears.

When you save a .rules file, all of the System started roles in that file will fire.

I don’t think there is an equivalent for .items files. You might be able to use a Item MyItem changed to NULL to detect when a .items file is reloaded since all your items will go to NULL before being restored from the DB is you have persistence set up with restoteOnStartup. But that will not help you identify which .items file was changed because all items go to null, not just those in that one. Items file.

Perhaps if you tell us why you want to do this and what you are trying to accomplish we can help you with your real goal instead of just helping you solve your problem in the way you have already determined to solve it.

Often there are multiple ways to solve any given problem. But when you come to us with a predefined solution your limit our options in how we can help.

Okay could you give me an example for the persistence file?
I’ve read something about that i have to install any persistence Service in order to work with it. Does it mean without a Persistence Service, there is no restoreOnStartup? Or does a default DB exist?

And how can I combine it with a Rule? Doesn’t it mean, that every item changes automatically to value NULL if I save an .items file independently wether I use a persistence file/service or not? But a Rule that says something like ‘when MyItem changed’ or ‘when Member of MyGroup changed’ does not trigger after refreshing an .items file.

That is correct.

https://docs.openhab.org/configuration/persistence.html

restoreOnStartup happens BEFORE your Rules run. From your Rules perspective, the Items never go to NULL and instead get initialized to the most recent value in the database.

However, for some people there are timing issues when OH starts up that causes the Rules to start running before restoreOnStartup is done. There are ways to address that if it becomes a problem.

For Restore On Startup

  1. install mapdb from the persistence section using paperUI
  2. Select mapdb as default persistence
  3. copy this into a text file and save as mapdb.persist in openhab conf/persistence folder
Strategies {
	default = everyChange
}

Items {
	* : strategy = everyChange, restoreOnStartup
}```