Hi,
I added the template to learn more about it but I received a failure when I ran it. I believe it is because the item word on line 130 has an extra ‘m’
Console Log
2022-09-19 20:15:05.356 [DEBUG] [.script.rules_tools.reminderswitches] - WemoPlug_Switch is in the alert state of OFF
2022-09-19 20:15:05.359 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:
org.graalvm.polyglot.PolyglotException: ReferenceError: "itemm" is not defined
Rule Script
// Item changed to a not alertState, create a looping timer if one doesn't already exist
else if(isAlertState(state)) {
logger.debug(item + ' is in the alert state of ' + state);
// There shouldn't be a Timer if the Item just changed to the alertState, log to show
// something went wrong.
if(timers.has(item) && reschedule) {
logger.debug('Rescheduling timer for ' + item + ' with ' + timeout);
timers.get(item).timer.reschedule(time.toZDT(timeout));
}
else if(timers.has(itemm) && !rescedule) {
logger.warn(item + ' state is now ' + state + ' but an alert timer already exists! This should not have happened!');
The rule partially works after I correct it but I receive a new error. Any suggestions on how to troubleshoot this error. I have installed the prerequisites (sudo npm install openhab & openhab_rules_tools)
2022-09-19 20:37:52.289 [DEBUG] [.script.rules_tools.reminderswitches] - Running door alert rule with:
item: WemoPlug_Switch
state: ON
alertState: ON
invert: true
defaultTimeout: PT0
repeatPeriod: PT1m
dndStart: 00:00
dndEnd: 00:00
noAlertPeriod: true
alertRuleUID: door_open
2022-09-19 20:37:52.291 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'ReminderSwitches' failed: java.lang.IllegalStateException: The Context is already closed.