RuleEngine: Fix startlevel trigger for DSL rules triggers twice during startup

Fixes #4395.
The issue was noticed for Rules DSL, but not for JS Scripting, because JS Scripting is loaded at a point where the rule engine is already started.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
This commit is contained in:
Florian Hotze
2026-01-11 23:25:17 +01:00
committed by Holger Friedrich
parent a70b9859f4
commit bb02591ced
@@ -872,11 +872,12 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
register(rule);
setStatus(ruleUID, new RuleStatusInfo(RuleStatus.IDLE));
// check if we have to trigger because of the startlevel
// If the rule engine is started: Check if we have to trigger immediately because of the startlevel
// Execution of startlevel triggers during startup is handled by executeRulesWithStartlevel()
List<Trigger> slTriggers = rule.getTriggers().stream().map(WrappedTrigger::unwrap)
.filter(t -> SystemTriggerHandler.STARTLEVEL_MODULE_TYPE_ID.equals(t.getTypeUID())).toList();
int startLevel = startLevelService.getStartLevel();
if (slTriggers.stream()
if (started && slTriggers.stream()
.anyMatch(t -> ((BigDecimal) t.getConfiguration().get(SystemTriggerHandler.CFG_STARTLEVEL))
.intValue() <= startLevel)) {
runNow(rule.getUID(), true, Map.of(SystemTriggerHandler.OUT_STARTLEVEL, StartLevelService.STARTLEVEL_RULES,