I thought it would be simple, but apparently it is not.
I have two items which are both numbers.
These two items should be added together so that I can continue working with the result.
In short, there are two inverters and I want to add the current yield.
I have built a simple script in Blockly, which should add the two values and write this to the item “Total Yield”.
Unfortunately the item always stays at NULL.
I have tried several possibilities, which I have also found here in the forum, has only brought nothing so far.
The item remains at NULL
Trying to format all values into a string did not work either.
I created a second item, which was formatted as a string instead of a number.
events.log 2022-11-19 17:08:43.767 [INFO ] [openhab.event.RuleUpdatedEvent ] - Rule 'GesamtertragRechner' has been updated.
openhab.log
2022-11-19 17:09:14.826 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule ‘GesamtertragRechner' with status 'UNINITIALIZED'
2022-11-19 17:09:50.345 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - ScriptEngine for language 'application/javascript' could not be found for identifier: 993a26f2-5e49-45a4-a0ee-a527157da7a6
I think I found a problem here with JavaScript in general on x86/x64.
I have once again set up a fresh installation of openHAB in a proxmox container.
After that I installed the Modbus binding and the two addons “JavaScript Scripting” and “JavaScript Transformation Service”.
Additionally I created a small JavaScript in the transformations folder:
As soon as I assign the JavaScript to a Thing, I always get only NULL as result of the item state and the following error messages in the openhab log:
2023-01-08 19:50:16.495 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Execution of scheduled (5000ms) poll task BasicPollTask [getEndpoint=ModbusIPSlaveEndpoint [address=192.168.178.161, port=502], request=ModbusReadRequestBlueprint [slaveId=3, functionCode=READ_INPUT_REGISTERS, start=30769, length=26, maxTries=3], getResultCallback()=org.openhab.binding.modbus.handler.ModbusPollerThingHandler$ReadCallbackDelegator@5bb4d35e, getFailureCallback()=org.openhab.binding.modbus.handler.ModbusPollerThingHandler$ReadCallbackDelegator@5bb4d35e] failed unexpectedly. Ignoring exception, polling again according to poll interval.
java.lang.NullPointerException: null
2023-01-08 19:56:34.240 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Execution of scheduled (5000ms) poll task BasicPollTask [getEndpoint=ModbusIPSlaveEndpoint [address=192.168.178.161, port=502], request=ModbusReadRequestBlueprint [slaveId=3, functionCode=READ_INPUT_REGISTERS, start=30769, length=26, maxTries=3], getResultCallback()=org.openhab.binding.modbus.handler.ModbusPollerThingHandler$ReadCallbackDelegator@5e6214e8, getFailureCallback()=org.openhab.binding.modbus.handler.ModbusPollerThingHandler$ReadCallbackDelegator@5e6214e8] failed unexpectedly. Ignoring exception, polling again according to poll interval.
java.lang.NullPointerException: Cannot invoke "javax.script.Compilable.compile(java.io.Reader)" because "engine" is null
at org.openhab.transform.javascript.internal.JavaScriptEngineManager.getCompiledScriptByFilename(JavaScriptEngineManager.java:77) ~[?:?]
at org.openhab.transform.javascript.internal.JavaScriptTransformationService.transform(JavaScriptTransformationService.java:119) ~[?:?]
at org.openhab.binding.modbus.internal.SingleValueTransformation.transform(SingleValueTransformation.java:140) ~[?:?]
at org.openhab.binding.modbus.internal.CascadedValueTransformationImpl.transform(CascadedValueTransformationImpl.java:51) ~[?:?]
at org.openhab.binding.modbus.internal.ValueTransformation.transformState(ValueTransformation.java:48) ~[?:?]
at org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler.lambda$16(ModbusDataThingHandler.java:1001) ~[?:?]
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1707) ~[?:?]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) ~[?:?]
at org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler.processUpdatedValue(ModbusDataThingHandler.java:969) ~[?:?]
at org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler.onRegisters(ModbusDataThingHandler.java:847) ~[?:?]
at org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler.lambda$11(ModbusDataThingHandler.java:801) ~[?:?]
at java.util.Optional.ifPresent(Optional.java:178) ~[?:?]
at org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler.onReadResult(ModbusDataThingHandler.java:801) ~[?:?]
at org.openhab.binding.modbus.handler.ModbusPollerThingHandler$ReadCallbackDelegator.lambda$2(ModbusPollerThingHandler.java:144) ~[?:?]
at java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:807) ~[?:?]
at org.openhab.binding.modbus.handler.ModbusPollerThingHandler$ReadCallbackDelegator.notifyChildren(ModbusPollerThingHandler.java:142) ~[?:?]
at org.openhab.binding.modbus.handler.ModbusPollerThingHandler$ReadCallbackDelegator.handleResult(ModbusPollerThingHandler.java:88) ~[?:?]
at org.openhab.binding.modbus.handler.ModbusPollerThingHandler$ReadCallbackDelegator.handle(ModbusPollerThingHandler.java:105) ~[?:?]
at org.openhab.core.io.transport.modbus.internal.ModbusLibraryWrapper.invokeCallbackWithResponse(ModbusLibraryWrapper.java:337) ~[?:?]
at org.openhab.core.io.transport.modbus.internal.ModbusManagerImpl$PollOperation.lambda$1(ModbusManagerImpl.java:216) ~[?:?]
at org.openhab.core.io.transport.modbus.internal.SimpleStopWatch.timeRunnable(SimpleStopWatch.java:152) ~[?:?]
at org.openhab.core.io.transport.modbus.internal.ModbusManagerImpl$PollOperation.accept(ModbusManagerImpl.java:216) ~[?:?]
at org.openhab.core.io.transport.modbus.internal.ModbusManagerImpl$PollOperation.accept(ModbusManagerImpl.java:1) ~[?:?]
at org.openhab.core.io.transport.modbus.internal.ModbusManagerImpl.executeOperation(ModbusManagerImpl.java:614) ~[?:?]
at org.openhab.core.io.transport.modbus.internal.ModbusManagerImpl$ModbusCommunicationInterfaceImpl.lambda$1(ModbusManagerImpl.java:812) ~[?:?]
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) [?:?]
As soon as I change it to “default”, the error is gone, but my values are not correct.
On a Raspberry Pi 4B the whole thing runs without problems.
There is only openHAB installed for a long time and also a few other Linux packages.