Just migrated from OH3 to OH4(.0.3) using openHABian.
Most things run smoothly, but I’m kinda lost here. In my JS Scripting rules&scripts I use multiple “DateTime”-items:
label: Spülmaschine letzter Start
type: DateTime
category: ""
groupNames:
- PL12EMSLoads
groupType: None
function: null
tags:
- Point
With OH3, the following code worked nicely:
var LetzerStart = time.toZDT(items.getItem("EMS_SpMaLetzterStart"));
With OH4, the following error appears:
2023-10-01 10:29:23.838 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:
org.graalvm.polyglot.PolyglotException: Error: "EMS_WaMaLetzterStart (Type=DateTimeItem, State=2023-10-01T10:11:28.000+0200, Label=Waschmaschine letzter Start, Category=, Tags=[Point], Groups=[PL12EMSLoads])" is an unsupported type for conversion to time.ZonedDateTime
at <js>.R(@openhab-globals.js:2) ~[?:?]
at <js>.checkWW(<eval>:82) ~[?:?]
at <js>.:program(<eval>:44) ~[?:?]
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.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-10-01 10:29:23.843 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'EMS_checkWW' failed: org.graalvm.polyglot.PolyglotException: Error: "EMS_WaMaLetzterStart (Type=DateTimeItem, State=2023-10-01T10:11:28.000+0200, Label=Waschmaschine letzter Start, Category=, Tags=[Point], Groups=[PL12EMSLoads])" is an unsupported type for conversion to time.ZonedDateTime
I tried to:
var LetzerStart = time.toZDT(items.getItem("EMS_SpMaLetzterStart").state);
var LetzerStart = time.toZDT(items.getItem("EMS_SpMaLetzterStart").rawState);
but this also didn’t help. What has to change here?