Usually I manage to do the openhab upgrades, this time I seem to be stuck somehow.
I am using zigbee2mqtt with the mqtt binding. For the bulbs a javascript transformation is used. After upgrading to OH4, these transformations are not working anymore. Whenever triggering a such a Item / thing, I see this error in the logs:
2023-09-13 21:16:18.372 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service JS for pattern openhabdimmer2zigbeebridge.js not found!
Yes. As mentioned in the list of breaking changes you must install the JS Scripting add-on. The old separately installed JS Transformation no longer exists and JS no longer just comes with OH by default. If you want to use JS in a transform, you must install the add-on.
I have no idea what it’s called in addons.cfg or what line it goes on. I haven’t used addons.cfg for half a decade now. I assume you can still get the name of the addon that goes there from the URL of the readme.
I know it definitely doesn’t go on the transformation line. It’s not a transformation add-on, it’s an automation add-on.
Maybe automation="jsscripting" ?
Note, if you have “js” anything on the transformation line, you’ll be seeing errors in your logs and need to remove it.
No, nothing gets installed by default any more, not even rrd4j. However, the first run wizard makes suggestions on some common add-ons to install which includes JS Scripting.
If JS Scripting is not installed, Blockly is not shown as an option. But it is true that it’s still there since it’s 100% implemented as part of MainUI and not really separate.
I suspect that UoM could handle both of these cases without a transform. Without the actual error generated I’m afraid I can’t really offer more than that. Maybe make sure that the JS Scripting add-on is installed?
I put the tenth.js file into automation/jsr232 (and into automation/js just in case) it made no difference. Restarted the Docker container and it started working - but from the version in transform. I’m not sure what’s going on here.
It definitely needs to be in the transform folder.
It might be the case that the file watcher isn’t working as it should or there is some issue with Docker and the file watcher. I’ve use only managed configs for quite some time so .
this uses inline jruby (which means you’d need to install the jrubyscripting addon) but you can replace it with the equivalent JS code if preferred
Text item=AGMSoC label="AGM SoC [RB(|'%.1f %%' % (input.to_f/10)):%s]" icon="Energy"
But a much better way to solve this is by making the AGMSoC item to be Dimmer (or number if you think the value can go outside 0-100) and to contain the correct percentage value. Then your label format can be [%.1f %%] without using any transformations
The main issue with your original label format is that transformation results are always strings, so you need to use :%s
It now works using the JS transform in the item - I don’t understand how it worked before as a number. Dimmer won’t work as the values are always over 100