- Platform information:
- Hardware: _Intel I3, 16 Gb
- OS: _Linux mint Victoria 21.2 Mate 64 bit all updates installed
- Java Runtime Environment: which java platform is used and what version
- openHAB version: 4.0.3
- Issue of the topic: failed to execute script
- Please post configurations (if applicable):
- Items configuration related to the issue
- Sitemap configuration related to the issue
- Rules code related to the issue:
The blockly rule has to be executed form this rule.
configuration: {}
triggers:
- id: "1"
configuration:
event: END
channelUID: astro:sun:a4ef62ea88:daylight#event
type: core.ChannelEventTrigger
conditions:
- inputs: {}
id: "3"
configuration:
itemName: LocalWeatherandForecast_Cloudiness
state: 80%
operator: ">="
type: core.ItemStateCondition
actions:
- inputs: {}
id: "2"
configuration:
considerConditions: true
ruleUIDs:
- 4bc082e8b3
type: core.RunRuleAction
Rulescode cereated in Blockly
var Day;
function deibich_blockly_get_zdt_component_from_returned_value(value) {
if(typeof value == 'number')
{
return value;
}
return value.getValue()
}
var deibich_blockly_ZonedDateTime = Java.type('java.time.ZonedDateTime');
var thread = Java.type('java.lang.Thread')
Day = deibich_blockly_get_zdt_component_from_returned_value(deibich_blockly_ZonedDateTime.now().getDayOfWeek());
if (Day == 1) {
items.getItem('Woonkamerhanglamp_Status').sendCommand('ON');
thread.sleep(20000);
items.getItem('Staandelamplinksvoor_Status').sendCommand('ON');
thread.sleep(30000);
items.getItem('Staandelamprechtsvoor_Status').sendCommand('ON');
thread.sleep(45000);
items.getItem('Eetkamerstaandelamp_Status').sendCommand('ON');
thread.sleep(25000);
items.getItem('Woonkamerdressoir_Status').sendCommand('ON');
thread.sleep(40000);
items.getItem('Halfotokast_Status').sendCommand('ON');
console.info('Het is dagnr 1, maandag, alle lampen aan');
} else if (Day == 2) {
items.getItem('Staandelamprechtsvoor_Status').sendCommand('ON');
thread.sleep(30000);
items.getItem('Staandelamplinksvoor_Status').sendCommand('ON');
thread.sleep(25000);
items.getItem('Woonkamerdressoir_Status').sendCommand('ON');
thread.sleep(35000);
items.getItem('Eetkamerstaandelamp_Status').sendCommand('ON');
thread.sleep(45000);
items.getItem('Halfotokast_Status').sendCommand('ON');
thread.sleep(10000);
items.getItem('Woonkamerhanglamp_Status').sendCommand('ON');
console.info('Het is dagnr 2, dinsdag, alle lampen aan');
} else if (Day == 3) {
thread.sleep(10000);
items.getItem('Staandelamprechtsvoor_Status').sendCommand('ON');
thread.sleep(20000);
items.getItem('Woonkamerhanglamp_Status').sendCommand('ON');
thread.sleep(45000);
items.getItem('Woonkamerdressoir_Status').sendCommand('ON');
thread.sleep(25000);
items.getItem('Staandelamplinksvoor_Status').sendCommand('ON');
thread.sleep(20000);
items.getItem('Eetkamerstaandelamp_Status').sendCommand('ON');
thread.sleep(35000);
items.getItem('Halfotokast_Status').sendCommand('ON');
console.info('Het is dagnr 3, woensdag, alle lampen aan');
} else if (Day == 4) {
items.getItem('Staandelamplinksvoor_Status').sendCommand('ON');
thread.sleep(20000);
items.getItem('Eetkamerstaandelamp_Status').sendCommand('ON');
thread.sleep(35000);
items.getItem('Woonkamerdressoir_Status').sendCommand('ON');
thread.sleep(20000);
items.getItem('Woonkamerhanglamp_Status').sendCommand('ON');
thread.sleep(45000);
items.getItem('Staandelamprechtsvoor_Status').sendCommand('ON');
thread.sleep(25000);
items.getItem('Halfotokast_Status').sendCommand('ON');
console.info('Het is dagnr 4, donderdag, alle lampen aan');
} else if (Day == 5) {
items.getItem('Staandelamprechtsvoor_Status').sendCommand('ON');
thread.sleep(35000);
items.getItem('Woonkamerdressoir_Status').sendCommand('ON');
thread.sleep(45000);
items.getItem('Eetkamerstaandelamp_Status').sendCommand('ON');
thread.sleep(50000);
items.getItem('Staandelamplinksvoor_Status').sendCommand('ON');
thread.sleep(25000);
items.getItem('Woonkamerhanglamp_Status').sendCommand('ON');
thread.sleep(45000);
items.getItem('Halfotokast_Status').sendCommand('ON');
console.info('Het is dagnr 5, vrijdag, alle lampen aan');
} else if (Day == 6) {
items.getItem('Woonkamerhanglamp_Status').sendCommand('ON');
thread.sleep(20000);
items.getItem('Staandelamplinksvoor_Status').sendCommand('ON');
thread.sleep(30000);
items.getItem('Staandelamprechtsvoor_Status').sendCommand('ON');
thread.sleep(45000);
items.getItem('Eetkamerstaandelamp_Status').sendCommand('ON');
thread.sleep(25000);
items.getItem('Woonkamerdressoir_Status').sendCommand('ON');
thread.sleep(40000);
items.getItem('Halfotokast_Status').sendCommand('ON');
console.info('Het is dagnr 6, zaterdag, alle lampen aan');
} else if (Day == 7) {
items.getItem('Staandelamprechtsvoor_Status').sendCommand('ON');
thread.sleep(20000);
items.getItem('Woonkamerhanglamp_Status').sendCommand('ON');
thread.sleep(25000);
items.getItem('Woonkamerdressoir_Status').sendCommand('ON');
thread.sleep(45000);
items.getItem('Staandelamplinksvoor_Status').sendCommand('ON');
thread.sleep(35000);
items.getItem('Eetkamerstaandelamp_Status').sendCommand('ON');
thread.sleep(50000);
items.getItem('Halfotokast_Status').sendCommand('ON');
console.info('Het is dagnr 7, zondag, alle lampen aan');
} else {
console.warn('Dagnr =??, dagnr is onjuist!!!');
}
console.info('I did it!!!!!');
- Services configuration related to the issue
- If logs where generated please post these here using code fences:
2023-09-21 19:09:11.107 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:
org.graalvm.polyglot.PolyglotException: ReferenceError: "events" is not defined
at <js>.:program(<eval>:61) ~[?:?]
at org.graalvm.polyglot.Context.eval(Context.java:399) ~[?:?]
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) ~[?:?]
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:426) ~[?:?]
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262) ~[java.scripting:?]
at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[?:?]
at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[?:?]
at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[?:?]
at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[?:?]
at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:71) ~[?:?]
at java.util.Optional.ifPresent(Optional.java:178) ~[?:?]
at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:68) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1188) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1039) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl$1.runNow(RuleEngineImpl.java:248) ~[?:?]
at org.openhab.core.automation.internal.module.handler.RunRuleActionHandler.execute(RunRuleActionHandler.java:106) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1188) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:997) ~[?:?]
at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:87) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
2023-09-21 19:09:11.119 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '4bc082e8b3' failed: org.graalvm.polyglot.PolyglotException: ReferenceError: "events" is not defined
Since a couple of days I’ve a strange issue. After updating from OH 3.4.4 to OH 4.03 I get an error when a rule should be executed. I’m a beginner, but as far as I can see is has something to with java and event. But what is the problem now? This rule has worked for about 3 years.
Any help would be welcome.