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.
1 Like

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!

Ouch… found this after a new install of openHABian 4.2.

Would these steps:

… also apply to a fresh install of 4.2.0?

Or can I use:

  1. install 4.2.0
  2. stop OH and restore the backup from OH v3.4.3
  3. Run the upgrade tool manually:
    java -jar /usr/share/openhab/runtime/bin/upgradetool.jar
    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…
  4. not required, as it is already OH latest.

… and that’s it?!

You can always give it a try and find out. The big gotcha is going to be that the upgradeTool was introduced after OH 4.0 so it might not be able to identify and correct everything itself so you might have additional work to manually adjust for breaking changes.

Be sure to review the announcements for OH 4.0, 4.1, and 4.2 so you don’t missing anything.

Finally, I recommend getting your Items unit metadata in place in your 3.4.3 config first. If the unit isn’t right (e.g. you are expecting mm but don’t have unit defined so your Item ends up storing m) the values saved to persistence and your charts will be wrong for the periuod between the upgrade and finally adding the unit. You will want to set the unit to what ever unit is actually being held by the Item. For OH 3.4 that usually is the state description pattern if present and not just %unit%. Otherwise it’s defined by the Channel. You can tell by looking at the events.log.

Sure… :slight_smile: I put meaning into the label… I had too many occasions where a device moves elsewhere; arguably not the case with lights… but these are just lined up on the veranda and eaves. So 001…nnn will do; could say Eave_Light_West_001…nnn; will see.
I reckon the my main (secret) issue is that I still favour text files for speed and change. Yes, I have seen your posts, and templates, but.

I have changed naming schemes over the years, and getting a standard that works is not easy. As most know, you start with one device, and name it blah. A while later you get a second device, and it should be named blah_2… and then a few more. To iterate via split, there is no _1… and hence, you have to rename blah to blah_1 to make it work.
One could then say name it with a _1 on the first place; do I then chose leading zeros… and the list of thoughts goes on.
I am not asking for a solution, just whining :slight_smile:

Or another one: things were/are all lower case with underscores… items started with camel case; which I changed to Capitalised_Underscore notation.
Endless possibilities.

I am thinking of extending my idea, and passing in a “proper name” that is then translated into thing, channel and item… all named properly.

Anyway… :slight_smile:

Yes, have seen and will consult the release notes, blog and Git.


My questions:

  1. Where does the unit need to be added?
  2. Do I have to change channels to be say Number:Temperature, or only the item in the state description? %.2f °C?
  3. Or in other words where does UoM happen ? In the channel or item, or both?

[edit 1]
→ the UoM is in the channel. This means I can remove the unit in the State Description, but have to deal with it in calculations. I shall think about it.

[/edit 1]

I have (so far) chosen the simple way of only using Number in the channel (actually I just checked an item and it says Number:Dimensionless — never noticed before), so I don’t have to deal with the lengthy type in the rules… and have taken care of conversions via transformations; e.g., div_by_1000.js… to take 3000 [mV] and 3.0 V out of it.

[edit 2]
Alright, I read the docs; all I can say “Oh dear!”… lots of work and checking coming my way. :frowning:
[/edit 2]

There is no such thing as openHABian 4.2.
You installed openHAB 4.2. But it’s unclear if you reinstalled the OS, too, openHABian that is.

If your plan was to move to a newer OS (and maybe Java with it) and upgrade OH, you should separate this into two steps:

  • install latest openHAB with openHAB3 and import your existing OH3 config
  • upgrade OH on the new box through openhabian-config.

See this HOWTO in OH migration FAQ

???

I downloaded this image: openHABian image openhabian-raspios32-latest-202404091722-crce1583db6.img.xz

I made these changes to the `openhabian.conf`
hostname=openhabian4
timezone=Australia/Brisbane

And ended up with this:

# [2024-07-10 19:02] openhabian@openhabian4 ~ $ 
openhab-cli info

Version:     4.2.0 (Build)

User:        openhab (Active Process 912)
User Groups: openhab tty dialout audio bluetooth gpio

Directories: Folder Name      | Path                        | User:Group
             -----------      | ----                        | ----------
             OPENHAB_HOME     | /usr/share/openhab          | openhab:openhab
             OPENHAB_RUNTIME  | /usr/share/openhab/runtime  | openhab:openhab
             OPENHAB_USERDATA | /var/lib/openhab            | openhab:openhab
             OPENHAB_CONF     | /etc/openhab                | openhab:openhab
             OPENHAB_LOGDIR   | /var/log/openhab            | openhab:openhabian
             OPENHAB_BACKUPS  | /var/lib/openhab/backups    | openhabian:openhab

URLs:        http://192.168.1.223:8080
             https://192.168.1.223:8443

It has openHABian written all over it.

No, it has openHAB written all over it
(wherever a version is mentioned)

So why the names openHABian everywhere?

2024-03-15_15:07:37_UTC [openHABian] Starting the openHABian initial setup.
2024-03-15_15:07:37_UTC [openHABian] Storing configuration... OK
2024-03-15_15:07:37_UTC [openHABian] Starting webserver with installation log... OK
2024-03-15_15:07:42_UTC [openHABian] Changing default username and password... SKIPPED
2024-03-15_15:07:42_UTC [openHABian] Setting up NetworkManager and Wi-Fi connection... 2024-04-09_00:00:00_UTC [openHABian] Ensuring network connectivity... OK
2024-04-09_00:00:00_UTC [openHABian] Waiting for dpkg/apt to get ready... OK
2024-07-09_04:29:52_UTC [openHABian] Updating repositories and upgrading installed packages... OK
2024-07-09_04:32:08_UTC [openHABian] Updating myself from https://github.com/openhab/openhabian, openHAB branch... OK
Linux openhabian4 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64
openhabian@openhabian4:~ $ sudo systemctl status openhab.service
● openhab.service - openHAB - empowering the smart home
     Loaded: loaded (/lib/systemd/system/openhab.service; enabled; preset: enabled)
    Drop-In: /etc/systemd/system/openhab.service.d
             └─override.conf
     Active: active (running) since Tue 2024-07-09 14:58:25 AEST; 5h 47min ago
       Docs: https://www.openhab.org/docs/
             https://community.openhab.org
    Process: 921 ExecStartPre=/bin/rm -f /var/lock/LCK..ttyAMA0 /var/lock/LCK..ttyACM0 (code=exited, status=0/SUCCESS)
   Main PID: 928 (java)
      Tasks: 150 (limit: 4695)
        CPU: 3min 18.184s
     CGroup: /system.slice/openhab.service
             └─928 /usr/bin/java -XX:-UsePerfData -Dopenhab.home=/usr/share/openhab -Dopenhab.conf=/etc/openhab -Dopenhab.runtime=/>

Jul 09 14:58:25 openhabian4 systemd[1]: Starting openhab.service - openHAB - empowering the smart home...
Jul 09 14:58:25 openhabian4 systemd[1]: Started openhab.service - openHAB - empowering the smart home.

I did not run any updates, not even the openhabian-config.

Because they all have a specific meaning in the context they appear. Read more carefully.
The log lines are messages from the proceeding openHABian install process. Unrelated to the OH version.
openhabian@openhabian4 means the Linux user you chose is named ‘openhabian’ and the box name you chose is ‘openhabian4’.
You gave these names (well, or at least you didn’t change the defaults so these were used).

Meanwhile the output ‘4.2.0’ is result of what ? The openhab-cli command you entered.
Note: the command is NOT openhabian-cli.

I am sure you know this stuff in and out…

I never heard of:

# [2024-07-10 19:13] openhabian@openhabian4 ~ $ 
openhabian-cli
-bash: openhabian-cli: command not found

and it isn’t on my v3 either:

# [2024-07-10 14:03] openhabian@openhabian /var/log $ 
openhabian-cli
-bash: openhabian-cli: command not found

And what about this when I log onto the machine?

ssh openhabian@192.168.1.223
openhabian@192.168.1.223's password:
Linux openhabian4 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Jul  9 14:50:20 2024 from 192.168.1.13


                          _   _     _     ____   _
  ___   ___   ___   ___  | | | |   / \   | __ ) (_)  ____   ___
 / _ \ / _ \ / _ \ / _ \ | |_| |  / _ \  |  _ \ | | / _  \ / _ \
| (_) | (_) |  __/| | | ||  _  | / ___ \ | |_) )| || (_) || | | |
 \___/|  __/ \___/|_| |_||_| |_|/_/   \_\|____/ |_| \__|_||_| | |
      |_|                  openHAB 4.2.0 - Release Build

Looking for a place to get started? Check out 'sudo openhabian-config' and the
documentation at https://www.openhab.org/docs/installation/openhabian.html
The openHAB dashboard can be reached at http://openhabian4:8080
To interact with openHAB on the command line, execute: 'openhab-cli --help'

Read this. It tells you all about it:

openhabian is a collection of scripts that install openHab as well as other things so you don’t have to go to the command line as far as I can tell.

I don’t use it as I use debian on a VM and use the Debian packages.

This is what I followed… :slight_smile:

I literally went by the ‘book’.
Downloaded the image
burned
modified openhabian.conf
and let it rip.
… and done nothing further!
A clean machine…

Oops, I did install a few bindings through the MainUI on 8080.
But that’s it…
Oops, and took a backup :slight_smile:

Of course not. It does not exist.
Mine was a rhetorical statement to emphasize the difference.

What do you think is wrong with that ?
Read more carefully:
nowhere it says openHABian 4.2. Only openHAB 4.2[.0 - Release] Build.

I’m not getting your point.

What?
Are you pulling a leg?
What a waste of time.