Upgrading Home Assistant

I run Home Assistant Core on a Raspberry Pi. I installed it in a Python venv and now and then I feel a need to upgrade. Today was such a day.

So, having backed everything up, I went for the plunge. Let’s install version 2025.1.2.

The usual dance goes a bit like this:

sudo systemctl stop homeassistant
sudo su homeassistant
cd /opt/homeassistant
source bin/activate
pip install --upgrade homeassistant
exit
sudo systemctl start homeassistant

Then all the dependencies are installed, so I usually go for a coffee, and once things have settled down (I use top to check that the system is idle), I usually restart homeassistance, just to make sure that it stops and starts nicely.

This time, I had no such luck. Lots of little issues. The major one seemed to be that import av in one of the core modules suffered from some sort of ValueError exception.

Having duckducked the issue for a while, I realized this meant that I had to do the upgrade from Python 3.12 to 3.13. Upgrading va to version 14.x using pip does not help. Since I always forget how to do this, I’m now writing this blog post.

Recollecting the steps, the moves are, more or less these:

sudo apt-get install python3.13 python3.13-venv python3.13-dev
sudo systemctl stop homeassistant
sudo su homeassistant
cd /opt/homeassistant
mkdir old
mv bin/ cache/ include/ lib/ lib64 LICENSE pyvenv.cfg share/ old
python3.13 -m venv .
source bin/activate
pip install homeassistant
exit
sudo systemctl start homeassistant

Again, restarting Home Assistant takes a while and a bit more since all the dependencies are built. Go grab a snack or just a quiet coffee and, viola, you will end up with a fresh install of Home Assistant version 2025.1.2