openhab-core
openhab-core copied to clipboard
OH4 transformationService of type ‘JS’ is unavailable
See forum https://community.openhab.org/t/oh4-transformationservice-of-type-js-is-unavailable/148786/1
Problem
- OH 4.0.2
- on start up the log shows about 20 .. 30 warning messages as below.
- the log messages stop once the start level has reached the stage of starting the rule engine
- the error is probably caused 1) by use of JS transforms on thing channels in the Modbus binding and b) by the use of JS transforms in some item definitions -- see below.
2023-08-16 17:33:51.921 [WARN ] [s.internal.SingleValueTransformation] - couldn't transform response because transformationService of type 'JS' is unavailable
Bridge modbus:tcp:g24 "Modbus Binding" @ "Under Stairs" [host="192.168.1.xxx", port=yy, rtuEncoded=true] {
Bridge poller poller "Electricity Meter Poller" @ "Under Stairs" [start=0, length=10, refresh=5000, type="input"] {
Thing data voltage "Electricity Meter Voltage" @ "Under Stairs" [readStart="0", readValueType="uint16", readTransform="JS(24g-dV.js)"]
Thing data current "Electricity Meter Current" @ "Under Stairs" [readStart="1", readValueType="uint32_swap", readTransform="JS(24g-mA.js)"]
Thing data power "Electricity Meter Power" @ "Under Stairs" [readStart="3", readValueType="uint32_swap", readTransform="JS(24g-dW.js)"]
Thing data energy "Electricity Meter Energy" @ "Under Stairs" [readStart="5", readValueType="uint32_swap", readTransform="JS(24g-Wh.js)"]
Thing data frequency "Electricity Meter Frequency" @ "Under Stairs" [readStart="7", readValueType="uint16", readTransform="JS(24g-dHz.js)"]
Thing data powerfactor "Electricity Meter PowerFactor" @ "Under Stairs" [readStart="8", readValueType="uint16", readTransform="JS(24g-percent.js)"]
Thing data alarm "Electricity Meter Alarm" @ "Under Stairs" [readStart="9", readValueType="uint16"]
}
}
Number:Time System_CPU_Uptime "System CPU Uptime [JS(24g-uptime.js):%s]" <time> {channel="systeminfo:computer:g24:cpu#uptime"}
Solution
As suggested by @jimtng "we need to do something to the add-on load order so that automation add-ons get loaded before things and items are loaded".
This issue has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/oh4-transformationservice-of-type-js-is-unavailable/148786/10
Same issue here with modbus... First read leads to log messages as the values cannot be extracted/transformed via JS. Annoying in case the read frequency is low (in my case once per hour).
After upgrading to OH4 from OH3, it actually seems to break the system for me for a short amount of time. I have a transformation that divides the value by 1000.0, so that the reading in Watts is transformed to Kilowatts because OH3 UOM didn't work correctly with persistence.
It seems that, when the transformation service is unavailable for Modbus, the value is passed through 1:1, and not an "error-value". This can result in ridiculous calculations afterwards and break several other things.
See: https://github.com/openhab/openhab-addons/blob/01dc99c6b6da7956daad718e7da7ad19380b21bf/bundles/org.openhab.binding.modbus/src/main/java/org/openhab/binding/modbus/internal/SingleValueTransformation.java#L142C3-L142C3
It may be good to enforce loading any transformation service before any binding is allowed to start.
I have a transformation that divides the value by 1000.0, so that the reading in Watts is transformed to Kilowatts because OH3 UOM didn't work correctly with persistence.
If you set the unit
metadata on the Item to kW it will work with persistence in OH 4 now without this transformation.
This doesn't change the over all comment and this issue but I wanted to point this out. You don't need the transform for this.
Furthermore, the modbus binding comes with a profile that handles this sort of thing too so even if that transformation between units wasn't handled automatically now, there is another work around by using the modbus profile instead of SCRIPT profile.
If you set the
unit
metadata on the Item to kW it will work with persistence in OH 4 now without this transformation.
Yes, that's why I upgraded to OH4 now to prepare for that migration. But that isn't so easy as a one-click as I have several DSL item- and thing-files to migrate and check each calculation and dependency manually.
You only need to look at your Items. And among those you only need to look at the Number:Something
Items. There is nothing relevant in your .things files for this.