2023-09-11 16:30:41.256 [ERROR] [.module.script.profile.ScriptProfile] - Failed to process script 'config:js:parseTuyaSensorData': org.graalvm.polyglot.PolyglotException: SyntaxError: Unexpected end of input
^[[B^[[B^[[A^[[A^[[A2023-09-11 16:30:54.473 [INFO ] [org.openhab.automation.script ] - Raw data: { '1': 211, '2': 541, '4': 100 }
2023-09-11 16:30:54.475 [INFO ] [org.openhab.automation.script ] - Replaced: { '1': 211, '2': 541, '4': 100 }
2023-09-11 16:30:54.476 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:
org.graalvm.polyglot.PolyglotException: SyntaxError: Unexpected end of input
at <js>.:anonymous(<eval>:13) ~[?:?]
at <js>.:program(<eval>:9) ~[?:?]
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.ScriptTransformationService.transform(ScriptTransformationService.java:215) ~[?:?]
at org.openhab.core.automation.module.script.profile.ScriptProfile.executeScript(ScriptProfile.java:145) ~[?:?]
at org.openhab.core.automation.module.script.profile.ScriptProfile.onStateUpdateFromHandler(ScriptProfile.java:127) ~[?:?]
at org.openhab.core.thing.internal.CommunicationManager.lambda$13(CommunicationManager.java:498) ~[?:?]
at org.openhab.core.thing.internal.CommunicationManager.lambda$15(CommunicationManager.java:519) ~[?:?]
at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
at org.openhab.core.thing.internal.CommunicationManager.handleCallFromHandler(CommunicationManager.java:515) ~[?:?]
at org.openhab.core.thing.internal.CommunicationManager.stateUpdated(CommunicationManager.java:496) ~[?:?]
at org.openhab.core.thing.internal.ThingHandlerCallbackImpl.stateUpdated(ThingHandlerCallbackImpl.java:65) ~[?:?]
at org.openhab.core.thing.binding.BaseThingHandler.updateState(BaseThingHandler.java:268) ~[?:?]
at org.openhab.core.thing.binding.BaseThingHandler.updateState(BaseThingHandler.java:287) ~[?:?]
at org.openhab.binding.exec.internal.handler.ExecHandler.execute(ExecHandler.java:299) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
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-11 16:30:54.485 [ERROR] [.module.script.profile.ScriptProfile] - Failed to process script 'config:js:parseTuyaSensorData': org.graalvm.polyglot.PolyglotException: SyntaxError: Unexpected end of input
We really need to see what is in replaced to understand why the JSON.parse failed. Based on the stack trace that appears to be where the error is occurring. It’s not getting to the dumpObject.
2023-09-11 21:40:35.406 [INFO ] [org.openhab.automation.script ] - Raw data: { '1': 211, '2': 570, '4': 100 }
2023-09-11 21:40:35.407 [INFO ] [org.openhab.automation.script ] - Replaced: { "1': 211, '2': 570, '4': 100 }
2023-09-11 21:40:35.409 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:
org.graalvm.polyglot.PolyglotException: SyntaxError: Unexpected end of input
at <js>.:anonymous(<eval>:13) ~[?:?]
at <js>.:program(<eval>:9) ~[?:?]
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.ScriptTransformationService.transform(ScriptTransformationService.java:215) ~[?:?]
at org.openhab.core.automation.module.script.profile.ScriptProfile.executeScript(ScriptProfile.java:145) ~[?:?]
at org.openhab.core.automation.module.script.profile.ScriptProfile.onStateUpdateFromHandler(ScriptProfile.java:127) ~[?:?]
at org.openhab.core.thing.internal.CommunicationManager.lambda$13(CommunicationManager.java:498) ~[?:?]
at org.openhab.core.thing.internal.CommunicationManager.lambda$15(CommunicationManager.java:519) ~[?:?]
at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
at org.openhab.core.thing.internal.CommunicationManager.handleCallFromHandler(CommunicationManager.java:515) ~[?:?]
at org.openhab.core.thing.internal.CommunicationManager.stateUpdated(CommunicationManager.java:496) ~[?:?]
at org.openhab.core.thing.internal.ThingHandlerCallbackImpl.stateUpdated(ThingHandlerCallbackImpl.java:65) ~[?:?]
at org.openhab.core.thing.binding.BaseThingHandler.updateState(BaseThingHandler.java:268) ~[?:?]
at org.openhab.core.thing.binding.BaseThingHandler.updateState(BaseThingHandler.java:287) ~[?:?]
at org.openhab.binding.exec.internal.handler.ExecHandler.execute(ExecHandler.java:299) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
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-11 21:40:35.417 [ERROR] [.module.script.profile.ScriptProfile] - Failed to process script 'config:js:parseTuyaSensorData': org.graalvm.polyglot.PolyglotException: SyntaxError: Unexpected end of input
It’s only replacing the first matching '. We need it to replace all of them. That’s probably why it’s failing. If it wasn’t valid JSON before, it’s really not valid now.
Thanks, again, for the help @rlkoshak ! Is there any way to get rid of this “info” from the log?
I would now like to display the result as
20.9 °C
Changed the output item type to number:temperature but that did not change the unit. The Exec command output is a string. Any ideas how to make this work?
Well, we added log statements to add this stuff to the log so the answer should be obvious. To remove the lines from the log, remove the logging statements.