- Platform information:
- Hardware: Proxmox VM 4 x amd64 CPU 8G
- OS: Debian 11 6.1.0-11-amd64
- Java Runtime Environment: Debian 17.0.8
- openHAB version: 4.0.3
Created an ECMAScript (ECMAScript 262 Edition 11) rule using MainUI that uses the JSRule code as follows based on variables ruleName
and RuleID
:
rules.JSRule({
name: ruleName,
description: "Script auto created by rule GUI-VACUUM",
triggers: [triggers.GenericCronTrigger(cronJob)],
execute: (event) => {
items.getItem("ROBSched1StartNow").sendCommand("ON")
},
id: ruleID,
});
The rule created looks as follows when opened from developer sidebar:
The JSRule created code is as follows:
configuration: {}
triggers:
- id: 55cc5cde-a98b-4013-ac3c-57302b524320
configuration:
cronExpression: 0 0 16 ? * MON,TUE,WED,THU,FRI,SAT,SUN *
type: timer.GenericCronTrigger
conditions: []
actions:
- inputs: {}
id: "1"
configuration:
privId: i182
type: application/javascript;version=ECMAScript-2021
script: >-
// Code to run when the rule fires:
// Note that Rule Builder is currently not supported!
(event) => {
items.getItem("ROBSched4StartNow").sendCommand("ON")
}
type: jsr223.ScriptedAction
The rule shows in the Rules section of the MainUI as follows:
When I test if the rule tiggers setting a time in the next 10 minutes the rules trigger fine and all works as intended. After some time (min was 20 min but some 2 hours, no pattern and no restarts) the rule disappears and cannot be found in the UI. When deleting/creating rules the logs show a message like:
2023-09-27 13:02:47.660 [INFO ] [.openhab.automation.openhab-js.rules] - Removing rule: Vacuum rule - Schedule 1
2023-09-27 13:02:47.661 [INFO ] [.openhab.automation.openhab-js.rules] - Adding rule: Vacuum rule - Schedule 1
Checking the logs there is no message showing the system Removes the rule and I’m at a loss why the rule is disappearing. Verified that the rule is gone by trying to delete it and there is no log message that it is "Removing rule: " making me conclude it is really gone.
Did notice that when clicking on the rule in the MainUI when the rule is under the rules section that the MainUI jumps to the script section but not sure if that is intended behaviour:
First time I used the JSRule command, did I misunderstand or miss something?