Upgrade OH 3.4.4 to OH 4.1 Best Direction

I’m finally ready to upgrade OH to 4.1 in order to use the resolved Amazon Echo binding that fixes the lastVoiceCommand issue.

I’ve tried upgrading before but it completely failed so I want to get some input. So many posting about this upgrade.

My plan . .

  1. Following this to install Java 17 on Ras
    How to Install Java-17 on Raspberry Pi

  2. Then do I choose “manual” to download and install OH → Download openHAB | openHAB

OR

Do I go into the OH config and do the upgrade from there (that is if it starts with Java 17 installed)?
openhabian-config

Best, Jay

It’s important to separate openHAB and openHABian in your mind. openHABian is a bunch of scripts and tools to configure and prepare a system for OH. It is not OH itself. It installs OH.

If you are on a recent enough based OS (bullseye or bookworm) and already running openHABian, I believe you can install Java 17 through openhabian-config. If you are on buster or earlier I’m not certain either openHABian nor those instructions will work. There is only one Java 17 implementation that I’ve seen reported that works on buster and below because of a dependency on a version of a shared library. Search the forum and you should find the posts that talk about it.

Given these limitations, I’d recommend installing a fresh new openHABian image. This is one of the rare cases where a restore of your configs from 3.4 over 4.1 should work so you don’t need to worry to much about installing openHAB 3.4, restoring, and then upgrading.

The steps are:

  1. Install a fresh openHABian image with OH 4.0 (latest release).
  2. Stop OH and restore your backup using openhabian-config or openhab-cli.
  3. Run the upgrade tool manually: java -jar /usr/share/openhab/bin/upgradetool.jar (at least I think that’s where it is, I use docker so the paths are different.
  4. When that completes start OH and make any changes to your configs required by the breaking changes between OH 3.4 and OH 4. unit metadata and opening and resaving your Blockly rules will be the two biggest ones but look at the release notes for OH 4 for details.
  5. Once you are up and running error free, upgrade to the OH 4.1 milestones or snapshots. That should go smoothly.

Here’s my journey in the upgrade, it took around 10 hours. Thanks @rlkoshak with the overview above which helped!

I needed/wanted to upgrade Pi OS from Buster to Bullseye

sudo apt-mark hold openhab
sudo apt-mark hold openhab-addons
sudo apt-mark hold speedtest-cli
sudo apt-mark hold python3
sudo apt-mark hold openjdk-11-jre-headless:armhf

Show package status on Linux → validate the HOLD status on the above
dpkg --get-selections | less

https://jamesjdavis.medium.com/how-to-update-raspberry-pi-just-follow-these-easy-steps-ac507cf70238

sudo apt update
sudo apt dist-upgrade
sudo apt clean
sudo reboot

sudo nano /etc/apt/sources.list
Change buster to bullseye on first line

sudo apt update

https://unix.stackexchange.com/questions/592657/full-upgrade-to-debian-testing-fails-due-to-libc6-dev-breaks-libgcc-8-dev

sudo apt install gcc-8-base ← this resolves an error before upgrading

sudo apt dist-upgrade ← this will take a lot of time with default prompts
sudo apt autoclean
sudo reboot

Reinstall SAMBA if you use it
Upgrade Putty on your clients to latest vesion (0.79), older version won’t connect to Bullseye
Removed DHCP from Bullseye since I have a static IP and didn’t want the 169.x.x.x IP showing up

https://www.openhab.org/download/
curl -fsSL "https://openhab.jfrog.io/artifactory/api/gpg/key/public" | gpg --dearmor > openhab.gpg
sudo mkdir /usr/share/keyrings
sudo mv openhab.gpg /usr/share/keyrings
sudo chmod u=rw,g=r,o=r /usr/share/keyrings/openhab.gpg

OH 3.x should continue to run as normal with Bullseye installed now

** Make a SSD copy before proceeding to upgrade OH for a disaster backup scenario

Make sure OH is stopped before proceeding.
apt-get install openhab
sudo /bin/systemctl start openhab.service

Make sure OH is stopped before proceeding.
apt-get install openhab-addons

My upgrade took me from OH 3.4.4 to 4.0.4

Start OH
→ lots of “Could not resolve modules”
Stop OH
Removed these bindings in Addon’s due to resolutions never happening, need to upgrade them to 4.0.x versions once up and running via GUI
org.smarthomej.binding.androiddebugbridge
org.smarthomej.commons
org.openhab.io.hueemulation
org.smarthomej.binding.amazonechocontrol
Removed everything from /cache and /tmp

Start OH
Downloaded from Market Place:
org.smarthomej.binding.amazonechocontrol (beta)
org.smarthomej.binding.androiddebugbridge

Downloaded from jFrog, HUE Emulation, couldn’t find where to install/activate this via the GUI anywhere.

Stop OH
Reboot Pi

In 4.0 go to Settings → Other (under Add-ons) or in 4.1 go to Add-on Store → Other.

In both cases it’s found under System Integrations.

Alternatively you can click the magnifying glass icon to search for it.

In OH 4.0, once installed, any add-on setting can be reached by navigating to the same place you install the add-on (see above) and click the blue gear icon. In 4.1 go to Settings and the add-on will appear under Add-on Settings.

I am trying to upgrade from 3.4.1 to 4.1.2 stable following this post:

I did a clean install of 4.1.2 getting

openHABian Configuration Tool — [openHAB]{2024-04-09T17:35:01+02:00}(eae809f)
 openHAB 4.1.2 - Release Build

Then I stopped OH with
sudo systemctl start openhab.service
and restored the “small” backup I had from 3.4.1 (931 kB) using 51 in openhabian-config
After restarting OH the panel shortly showed some previous items.
Now OH is not starting, panel and fronttail are not reachable, the log entries in /var/log/openhab do not show anything new.

I tried sudo java -jar $OPENHAB_RUNTIME/bin/upgradetool.jar as suggested in this thread but got an error

Please either set the environment variable ${OPENHAB_USERDATA} or provide a directory through the --dir option.

I also did a full backup of 3.4.1 (465 MB). Should I try to use this backup in step 2?

Can you help me?

Addition: I added --dir /var/lib/openhab to the upgradetool -line and got lots auf Warnings about units:

Could not determine if channel 'shelly:shellyplugs:SH11:meter#totalKWH' sets a state description. Check if you need to set unit metadata

Can I fix these errors in the configuration files I find in /var/lib/openhab/jsdon.db or is it better not to touch these files (My configuration was made by the openhabpanel).

If those are the steps you took you didn’t follow the steps I outlined. You never ran the upgrade tool.

So you need to set $OPENHAB_USERDATA to /var/lib/openhab. Or provide that path with the --dir argument, like the error says. The upgrade tool needs to know where the userdata folder is in order to find the files to fix.

But all-in-all your system is in such an unknown and broken state, I’d start over with a fresh install and if something goes wrong at a step do not proceed and get help with that step before continuing.

Doubt it. There really isn’t anything in those files that would completely prevent OH from starting in the first place. Something else is wrong. What? :person_shrugging:

1 Like

Thank you!
I reached step 3, started OH again with

sudo systemctl start openhab.service

OH ist starting and shows panel and graphs in the webinterface.
Now I can start to work with the units - they seem to be all wrong (W instead of kW …)
Thank you!
So the above mentioned steps seem to work with 4.1.2!