-
-
Notifications
You must be signed in to change notification settings - Fork 456
Description
When creating a rule that uses a SystemStartlevelTrigger from JavaScript (openhab-js, GraalJS), the rule is not initialized and openHAB throws
HANDLER_INITIALIZING_ERROR
Getting handler 'core.SystemStartlevelTrigger' ... failed:
class java.lang.String cannot be cast to class java.math.BigDecimal
This happens regardless of how the trigger is created:
- via rules.when().system().startupComplete()
- via rules.when().system().startlevel(100)
- via triggers.SystemStartlevelTrigger(100)
- via triggers.SystemStartlevelTrigger(new BigDecimal(100))
- via JSRule with manual trigger config
--> All variants produce the same error.
Expected Behavior
The rule should initialize without error and get triggered when system level reaches 100
Current Behavior
Generated rule is not initializing nor running upon js script re-load
Possible Solution
org.openhab.core.automation.module.system.handler.SystemStartlevelTriggerHandlerFactory
Modify the handler init to support String values ?
Steps to Reproduce (for Bugs)
- create a js automation scrtip init.js under openhab/conf/automation/js/
const log = require('openhab').log('init.js');
const { rules, triggers } = require('openhab');
rules.JSRule({
id: 'test_startlevel',
name: 'Test startlevel trigger',
triggers: [
// All variants fail
triggers.SystemStartlevelTrigger(100)
// triggers.SystemStartlevelTrigger("100")
// triggers.SystemStartlevelTrigger(new BigDecimal(100))
// triggers.SystemStartlevelTrigger(new BigDecimal(100))
],
execute: () => {
log.info("Triggered");
}
})
- Reload rule.
- Check the created rule in the UI, the error is in the banner and the rule is not initialized nor is running.
Context
I would like some code in my JS automations to only run when the system is ready (level = 100)
Your Environment
Openhab docker image openhab/openhab:5.0.2 running in a docker container under win11 WSL2
openhab-js : "version": "5.15.0
Node.js v20.19.2
java --version
openjdk 21.0.9 2025-10-21
OpenJDK Runtime Environment (build 21.0.9+10-Debian-1deb13u1)
OpenJDK 64-Bit Server VM (build 21.0.9+10-Debian-1deb13u1, mixed mode, sharing)
Thanks, I am happy to provide more details or perform more tests...