OH3: out of interest, does saving an item reload all rules?

  • openhabian 3.3.0 on rPi4

When I saved an .items file in OH2 it would trigger a reload of all rule files. Like so:

2022-11-06 17:58:37.459 [INFO ] [home.model.script.HouseSensors.00.00] - System start or rule file reload for HouseSensors.
2022-11-06 17:59:43.484 [INFO ] [.smarthome.model.script.Modbus.00.00] - System start or rule file reload for Modbus.
2022-11-06 17:59:50.916 [INFO ] [e.smarthome.model.script.Astro.00.00] - System start or rule file reload for Astro.
2022-11-06 17:59:50.916 [INFO ] [marthome.model.script.MainGate.00.00] - System start or rule file reload for MainGate.
2022-11-06 17:59:50.919 [INFO ] [smarthome.model.script.weather.00.00] - System start or rule file reload for weather.
2022-11-06 17:59:50.924 [INFO ] [e.smarthome.model.script.Water.00.00] - System start or rule file reload for Water.
2022-11-06 18:00:03.459 [INFO ] [se.smarthome.model.script.Shed.00.00] - System start or rule file reload for Shed.

...

Will it do the same in OH3 when using the GUI items, instead of .items files?

Thanks.

Is this really a reload of the rule ?
Could it be that the content of your rule checks for changes from NULL to a value that is different from NULL and then logs this INFO ?

AFAIK it does not reload ALL rules but quite some (those affected by your change).
Interactive edits of things/items files hence are a bad idea on a slowish RPi machine.
Then again, to the best of my knowledge there has been no substantial change in this behavior since OH 2.5 so it’s not new.

Can’t prove it, but it is my perception as the “reload” interrupts any timers and item states.

The bug bear is, why reload all the rules, and not the ones that contain the item.
Maybe it updated all items, rather then the new ones.

with the items in the database, I suspect it does not update any rules.

All speculation on my part on how it behaves, but it would be nice to know that updating one item does not disrupt the whole system.

I have to delay updating items to a time where nothing happens, as in things switch on|off.

Some more reloaded files…

2022-11-06 18:00:53.550 [INFO ] [se.smarthome.model.script.Zeva.00.00] - System start or rule file reload for Zeva.
2022-11-06 18:00:53.556 [INFO ] [smarthome.model.script.spp_bms.00.00] - System start or rule file reload for spp_bms.
2022-11-06 18:01:20.395 [INFO ] [.smarthome.model.script.GeoLoc.00.00] - System start or rule file reload for GeoLoc.
2022-11-06 18:01:20.395 [INFO ] [smarthome.model.script.RF433TX.00.00] - System start or rule file reload for RF433TX.
2022-11-06 18:01:20.398 [INFO ] [marthome.model.script.GPS_Base.00.00] - System start or rule file reload for GPS_Base.
2022-11-06 18:01:20.747 [INFO ] [se.smarthome.model.script.init.00.00] - System start or rule file reload for init.
2022-11-06 18:01:20.747 [INFO ] [pse.smarthome.model.script.433.00.00] - System start or rule file reload for 433.
2022-11-06 18:01:22.379 [INFO ] [thome.model.script.Irrigation1.00.00] - System start or rule file reload for Irrigation1.
2022-11-06 18:01:22.387 [INFO ] [smarthome.model.script.TeslaM3.00.00] - System start or rule file reload for TeslaM3.
2022-11-06 18:01:22.387 [INFO ] [marthome.model.script.Fritzbox.00.00] - System start or rule file reload for Fritzbox.
2022-11-06 18:01:22.390 [INFO ] [arthome.model.script.testRules.00.00] - System start or rule file reload for testRules.
2022-11-06 18:01:35.419 [INFO ] [thome.model.script.Irrigation2.00.00] - System start or rule file reload for Irrigation2.

I checked my log files that start in february 2022 and I do not see such a message although I use .items files and I recently have done changes in some of them.
The string System start or rule file reload is not part of your rules ?

Sorry for any misunderstanding…

This is a string I have in every rule file in OH2.

E.g.,

rule "Tesla rules started"
	when
		System started
	then
        logInfo(logPrefix + "00.00", "System start or rule file reload for {}", logPrefix)
end

Not in my case.
I changed on item in one item file.
This item is only used in one rule file.
It reloads all of them.

Here 21 rule files:
image

… and 21 reloads

2022-11-06 17:57:55.135 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'watersystem.items'
2022-11-06 17:58:32.677 [INFO ] [e.smarthome.model.script.Max01.00.00] - System start or rule file reload for Max01.
2022-11-06 17:58:37.458 [INFO ] [e.smarthome.model.script.Other.00.00] - System start or rule file reload for Other.
2022-11-06 17:58:37.459 [INFO ] [home.model.script.HouseSensors.00.00] - System start or rule file reload for HouseSensors.
2022-11-06 17:59:43.484 [INFO ] [.smarthome.model.script.Modbus.00.00] - System start or rule file reload for Modbus.
2022-11-06 17:59:50.916 [INFO ] [e.smarthome.model.script.Astro.00.00] - System start or rule file reload for Astro.
2022-11-06 17:59:50.916 [INFO ] [marthome.model.script.MainGate.00.00] - System start or rule file reload for MainGate.
2022-11-06 17:59:50.919 [INFO ] [smarthome.model.script.weather.00.00] - System start or rule file reload for weather.
2022-11-06 17:59:50.924 [INFO ] [e.smarthome.model.script.Water.00.00] - System start or rule file reload for Water.
2022-11-06 18:00:03.459 [INFO ] [se.smarthome.model.script.Shed.00.00] - System start or rule file reload for Shed.
2022-11-06 18:00:53.550 [INFO ] [se.smarthome.model.script.Zeva.00.00] - System start or rule file reload for Zeva.
2022-11-06 18:00:53.556 [INFO ] [smarthome.model.script.spp_bms.00.00] - System start or rule file reload for spp_bms.
2022-11-06 18:01:20.395 [INFO ] [.smarthome.model.script.GeoLoc.00.00] - System start or rule file reload for GeoLoc.
2022-11-06 18:01:20.395 [INFO ] [smarthome.model.script.RF433TX.00.00] - System start or rule file reload for RF433TX.
2022-11-06 18:01:20.398 [INFO ] [marthome.model.script.GPS_Base.00.00] - System start or rule file reload for GPS_Base.
2022-11-06 18:01:20.747 [INFO ] [se.smarthome.model.script.init.00.00] - System start or rule file reload for init.
2022-11-06 18:01:20.747 [INFO ] [pse.smarthome.model.script.433.00.00] - System start or rule file reload for 433.
2022-11-06 18:01:22.379 [INFO ] [thome.model.script.Irrigation1.00.00] - System start or rule file reload for Irrigation1.
2022-11-06 18:01:22.387 [INFO ] [smarthome.model.script.TeslaM3.00.00] - System start or rule file reload for TeslaM3.
2022-11-06 18:01:22.387 [INFO ] [marthome.model.script.Fritzbox.00.00] - System start or rule file reload for Fritzbox.
2022-11-06 18:01:22.390 [INFO ] [arthome.model.script.testRules.00.00] - System start or rule file reload for testRules.
2022-11-06 18:01:35.419 [INFO ] [thome.model.script.Irrigation2.00.00] - System start or rule file reload for Irrigation2.

I do not think it will.

Even if it did, your “telltale” system-started rule will not run, as system started now means what it says, rather than file loaded.

Just to summarize and add a little more detail.

  1. Yes, when using text configs a change to a .items file (even if it’s a non-change like adding a space somewhere) will cause a reload of all your .rules files. I think this is required because there is nothing mapping the Items to the rules where it’s used so it couldn’t just load those rules files that use the Items from the file that changed. Also, what happens when a .items file is unloaded is all those Items and their Links are destroyed. When the .items file is reloaded, the Items and the Links are created anew. This means that the triggers for those rules that use those Items need to be recreated.

  2. Indeed, no reload occurs when Items and/or rules are managed (i.e. created through the UI). In this case, the Items and rules are not read-only which allows OH to come along and clean up as necessary. Also, changes are much less disruptive. You can change everything about an Item except its name without deleting it meaning that these changes are much less disruptive.

  3. The system started trigger bears more explanation. One of the breaking changes in OH 3 is the system started trigger now actually means “the system has started”. It has also been expanded to support multiple run levels (see below) such as when the rules engine has started, Things are initialized, etc. But this means system started no longer means “this .rules file was just loaded.” So those rules would only trigger when OH restarts, not when the .rules file is reloaded. If you happen to have a rule that needs to be triggered when the .rules file is loaded, for now you’ll need to find some other way to trigger that. Usually, just remembering to manually run the rule is enough but I’m sure there are other ways. There is an issue open that discusses adding a rule loaded/unloaded features to .rules files (like exist in the other languages) but I don’t remember where that is in getting implemented and merged.

1 Like