Successful Openhab upgrade v3.4.3 to v4.0.1 - potential stumbling blocks

Hi all,
im writing down for others my experiences with the upgrade to Openhab 4.0.1 because im thinking others could have benefit from my experiences how to successfully do the upgrade:
upgrading after docker pull the new image told me successful and some problems then were waiting for me to solve:

  • [ERROR] [ipt.internal.ScriptEngineManagerImpl] - ScriptEngine for language 'application/javascript' could not be found for identifier:
    [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'c283d3976d' failed: org.graalvm.polyglot.PolyglotException: ReferenceError: "ir" is not defined
    i had to install addon Nashorn Engine for getting my ecma-scripts again running.
    all my rules had application/javascript; in there which i had to change to application/javascript;version=ECMAScript-5.1 and then you have time to migrate the scripts one by one later
  • [WARN ] [penhab.core.library.items.NumberItem] - Failed to update item 'Sensor_HelligkeitWesten' because '8197.12 °C' could not be converted to the item unit 'lx'
    my knx channels with illuminance were automaticly detected as °C. This means that no more values were updated to the item. To change this i had to redefine the channels with the correct DPT:
    example: <31/1/0 change to 9.004:<31/1/0
    also this was nessecary for humidity to add 5.001 as DPT.
  • Persistence
    i had some items which had Power in W in there. This where automaticly taken as kW.
    I had to go to the item and had to set the unit manually as W and then all was fine.
  • excessive Logging in event.log “updated to” (multiple lines per second same Item)
    2023-08-03 19:16:17.540 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'xxx' updated to OFF
    you have to add 2 lines to openhab_userdata/etc/log4j2.xml if you have this outside on a volume (See case )
                <Logger level="ERROR" name="openhab.event.ItemStateUpdatedEvent"/>
                <Logger level="ERROR" name="openhab.event.GroupStateUpdatedEvent"/>

Until now i did not get any other things to change. What are your experiences to get the new version successfully to run?

Best regards
Andreas

1 Like

The 2 lines are already in the official log4j2. xml

Maybe you had a customized version of this file? I read that in this case your file is not overwritten by the new one when updating.
@wborn or @J-N-K could probably confirm that.

For your point about persistence and unit, it is strange that you have to force a unit to W as the default for Power dimension is W and not kW.
https://www.openhab.org/docs/concepts/units-of-measurement.html
Was your item and your binding channel of type Number:Power?
Is your item managed by UI or define in a config file?

The logger config was not updated because the update command to do that was missing, see:

Hi @Lolodomo ,
log4j2.xml: it was on my docker-install on a volume and thats why possibly not updated by pull the new container.
Power: These were calculated by a rule from voltage and current measurements since a long time and saved to persistence. It did wrong graphs with doing nothing. And so it was nessecary because the 2 year retention would be bad if i would change calculation to kw and saving to the historical data. So i deciced to enter a “W” in Unit and all was fine for me.
Best regards
Andreas

Do you know if this fix is already in 4.0.1?

Ok, so looks like something normal/expected with new UoM stuff in OH4.

yeah, i got this from a former discussion with Rich Confusion about UOM on my energy-measurement in Wh displayed in kWh

It was only merged yesterday so it will be part of OH 4.0.2.

Interesting. Do you think it could be a reason of higher CPU usage and ultra high CPU usage noticed by some users?

no. Logging seems not the reason because i can see the higher cpu too since the upgrade but it did not came down by entering the 2 lines. From my point of view the higher cpu has another reason

Now that I have CPU monitoring with systeminfo binding, I will add these 2 lines and see the impact.
Maybe it is noticeable for users having very frequent item updates which is not my case.

This is prometheus monitoring of “cpu busy” (from node exporter dashboard) and you can see impact in middle of img. left side was openhab 3.4.3 and right side openhab 4.0.1 (about 30 or more container on a raspi4 8GB and the only change was updating openhab). Baseline changed from 20% to 30% with upgrade on my side. The upper higher parts i guess from some rules which i rebuilded. But baseline is a good indicator for what the new version did. On my side cpu is not a problem but i noticed it too.

Very interesting, it clearly shows the difference when moving from OH3 to OH4.
Maybe the move from Java 11 to Java 17 has increased the CPU usage ?
By the way, the CPU usage remains low in your case as in mine.

this i cannot say because java is bundled in your docker-container-image. but could possibly be.
my install is about 500 items, 75 things, about 800 ruleruns per hour and about 3000 itemchanges per hour that you can imagine about size. i could imagine that the 2 lines would have an impact with slow harddisks/sd-cards which some users could have and filling up their diskqueue. this makes high cpu normally. But this was not on my side because i have a very fast ssd in there.

I updated today from 3.4.4 to 4.0.2 and got the same problem. The 2 lines for the logger in the log4j2. xml are missing.
I don‘t know how to add them manually. When I try to edit the log4j2. xml file I got an error because of missing permissions.
How can I update the file?

Either edit the file as an other user and then copy it with sudo privileges or use sudo to start an editor with higher privileges.
At the end you need to make sure that the privileges are correct.

hi @dirkdirk had the same issue and did it for first time correctly today :slight_smile: the team @Wolfgang_S and @Scriptwriter here helped me understand how and here is the more noob level data to share.

i am assuming you can use putty or the equivalent to ssh into the enviroment and you are on an RPI to find the file

type:

sudo bash (this gives you root access be careful what you do with it)
enter your pass (probably openhabian)
cd /srv/openhab-userdata/etc/
nano

*use the short cut to read file - enter log4j2.xml
navigate to the xml using keyboard keep same format/lines/tabs - add your logger item.
use write command from the shortcuts
use exit short cut
type exit to leave the root access

restart your system either via sudo shutdown -r or the service itself via sudo systemctl restart openhab service (didnt check this 2nd one but i think it is the same effect)

hope this helps. (btw always keep a backup if you can of the file you mess with and you can check the permissions via ls - l while in the correct folder.

2 Likes