Upgrade gone sideways

I have been running HA on a Raspberry PI 4 running Raspbian. I originally installed Home Assistant using the instructions here: https://www.home-assistant.io/docs/installation/raspberry-pi/.

I tried to upgrade to the latest version of HA a few days ago and, even though the upgrade said it was successful, the WebUI did not come back online. I probably should have stopped and started asking for help here at that point. However, I proceeded to troubleshoot on my own. I finally have the WebUI running, but is seems like HA is not completing the bootup process. I cannot get HACS to run, it keeps stating that it is still waiting for HA to start running. My log file is full of errors, one of which is below:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/update_coordinator.py", line 144, in async_refresh
    self.data = await self._async_update_data()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/update_coordinator.py", line 132, in _async_update_data
    return await self.update_method()
  File "/home/homeassistant/.homeassistant/custom_components/nwsradar/__init__.py", line 67, in async_update_cam
    return await hass.async_add_executor_job(cam.update)
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/nws_radar/nws_radar.py", line 55, in update
    self._image_overlays = self._get_image_overlays()
  File "/srv/homeassistant/lib/python3.7/site-packages/nws_radar/nws_radar.py", line 83, in _get_image_overlays
    imag = self.retrieve_image(url)
  File "/srv/homeassistant/lib/python3.7/site-packages/nws_radar/nws_radar.py", line 76, in retrieve_image
    return Image.open(res.raw)
  File "/srv/homeassistant/lib/python3.7/site-packages/PIL/Image.py", line 2931, in open
    "cannot identify image file %r" % (filename if filename else fp)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x8cec8f60>

I suspect the error with BytesIO is related to the Ubiquiti integration. I have a lot of automatians tied to Ubiquiti devices and entities. Does anyone have any thoughts on how I might fix this?

I have messed around following various troubleshooting topics that I am wondering if I would be better off reinstalling HA. What files would I need to save to keep all my scripts and automations?

I know this is no help, but my upgrade of the OS went sideways, never recovered. I am reinstalling on a new SD.

Did you get this off the console?

I hit the upgrade, thought, probably should have backed up, and 90 minutes later, rebooted RP, to no joy.

The message is from running ‘tail -f home-assistant.log’ in one SSH session on the RPi and watching while HA is stopped and restarted via ‘systemctl’ on a separate SSH session.

What file(s) are you transferring to your new install? Or are you rebuilding everything from scratch?

A few thoughts here…

So you’re running core in a venv then?

Did you also upgrade Python (min version required is 3.8)? What is your Python version? BytesIO is a built-in a Python module so either your Python installation is now broken or something is expecting a different module interface (though I doubt that BytesIO would’ve changed drastically).

Did you upgrade anything else? Maybe a full system update and upgrade via apt would be good.

To back up, there are some other posts about it. In short, create a copy of your whole .homeassistant directory, including your .storage. This will also include the SQLite DB (which I’m assuming you’re using). No need to backup that unless you have a lot of history (which I doubt, since it’s very slow on a PI) that you absolutely want to keep. The storage directory and all YAML files are most important.

Last idea: Delete your DB file (if you don’t mind losing historical data).

Some things started working themselves out it seems. I have verified that I have updated all the standard Raspian packages. After restarting HA and the RPi a couple times yesterday I was able to view the WebUI. I removed a couple integrations that seemed to be having problems. Many of the integrations are working again, including HACS. However, HACS is indicating that it needs to update, but when I tell it to update it will seemingly download the update and then revert back to the page saying that it needs to update. I am not finding anything in the homeassistant.log error message about that issue.

I am also getting a message from HA that it is no longer going to run on Python 3.7 in the near future. I have Python 3.8.5 installed, but I am unsure how to tell HA to us it instead. When I use ‘sudo update-alternatives --config python3’ to set Python 3.8 as the default HA will not start.

I love learning how to fix things, so I am going to continue to try to repair this install. I would appreciate any more suggestions.

Pieter, thank you for pointing out the Phython upgrade and the files that I need to make sure I save.

You could try to increase logging to debug.