Home Assistant Launch Error [cannot import name OrPattern]

Creating a bug report/issue

[Y] I have searched the existing open and closed issues

Required Information

  • DietPi version | cat /boot/dietpi/.version

G_DIETPI_VERSION_CORE=9
G_DIETPI_VERSION_SUB=14
G_DIETPI_VERSION_RC=2
G_GITBRANCH=‘master’
G_GITOWNER=‘MichaIng’
G_LIVE_PATCH_STATUS[0]=‘applied’

  • Distro version | echo $G_DISTRO_NAME $G_RASPBIAN

Bookworm

  • Kernel version | uname --all

Linux DietPi 6.12.23-current-sunxi64 #1 SMP Thu Apr 10 12:39:41 UTC 2025 aarch64 GNU/Linux

  • Architecture | dpkg --print-architecture

arm64

  • SBC model | echo $G_HW_MODEL_NAME or (EG: RPi3)

Orange Pi Zero 3 (aarch64)

  • Power supply used | (EG: 5V 1A RAVpower)
    – 5V 1A
  • SD card used | (EG: SanDisk ultra)
    – Sandisk

Additional Information (if applicable)

  • Software title | (EG: Nextcloud)
    – Home Assistant
  • Was the software title installed freshly or updated/migrated?
    – Fresh
  • Can this issue be replicated on a fresh installation of DietPi?
  • – Yes, it is a fresh installation.
    ← If you sent a “dietpi-bugreport”, please paste the ID here →
  • Bug report ID | echo $G_HW_UUID

Steps to reproduce

  • Install Home Assistant from DietPi Software Store

Expected behaviour

  • Launching normally

Actual behaviour

root@DietPi:/home/homeassistant# systemctl status home-assistant
× home-assistant.service - Home Assistant (DietPi)
     Loaded: loaded (/etc/systemd/system/home-assistant.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Mon 2025-06-30 19:04:55 BST; 5s ago
   Duration: 8.644s
    Process: 43758 ExecStart=/home/homeassistant/homeassistant-start.sh (code=exited, status=1/FAILURE)
   Main PID: 43758 (code=exited, status=1/FAILURE)
        CPU: 8.512s

Jun 30 19:04:54 DietPi Home Assistant[43758]:     from homeassistant.helpers.config_entry_oauth2_flow import OAuth2AuthorizeCallbackView
Jun 30 19:04:54 DietPi Home Assistant[43758]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/homeassistant/helpers/config_entry_oauth2_flow.py", line 25, in <module>
Jun 30 19:04:54 DietPi Home Assistant[43758]:     from habluetooth import BluetoothServiceInfoBleak
Jun 30 19:04:54 DietPi Home Assistant[43758]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/habluetooth/__init__.py", line 26, in <module>
Jun 30 19:04:54 DietPi Home Assistant[43758]:     from .scanner import BluetoothScanningMode, HaScanner, ScannerStartError
Jun 30 19:04:54 DietPi Home Assistant[43758]:   File "src/habluetooth/scanner.py", line 39, in init habluetooth.scanner
Jun 30 19:04:54 DietPi Home Assistant[43758]: ImportError: cannot import name OrPattern
Jun 30 19:04:55 DietPi systemd[1]: home-assistant.service: Main process exited, code=exited, status=1/FAILURE
Jun 30 19:04:55 DietPi systemd[1]: home-assistant.service: Failed with result 'exit-code'.
Jun 30 19:04:55 DietPi systemd[1]: home-assistant.service: Consumed 8.512s CPU time.

Extra details

  • Tried reinstalling, even activating the pyenv and trying to downgrade/upgrade the Bluetooth dependencies, nothing works.
1 Like

can you share the whole service log

journalctl -u home-assistant

I have the same problem.
My journalctl -u home-assistant says the following:

dietpi@DietPi:~$ sudo journalctl -u home-assistant
Jun 29 23:49:12 DietPi systemd[1]: Started home-assistant.service - Home Assistant (DietPi).
Jun 29 23:49:16 DietPi Home Assistant[17055]: Traceback (most recent call last):
Jun 29 23:49:16 DietPi Home Assistant[17055]:   File "/home/homeassistant/.pyenv/versions/3.13.5/bin/hass", line 8, in <module>
Jun 29 23:49:16 DietPi Home Assistant[17055]:     sys.exit(main())
Jun 29 23:49:16 DietPi Home Assistant[17055]:              ~~~~^^
Jun 29 23:49:16 DietPi Home Assistant[17055]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/homeassistant/__main__.py", line 192, in main
Jun 29 23:49:16 DietPi Home Assistant[17055]:     from . import config, runner
Jun 29 23:49:16 DietPi Home Assistant[17055]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/homeassistant/runner.py", line 16, in <module>
Jun 29 23:49:16 DietPi Home Assistant[17055]:     from . import bootstrap
Jun 29 23:49:16 DietPi Home Assistant[17055]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/homeassistant/bootstrap.py", line 41, in <module>
Jun 29 23:49:16 DietPi Home Assistant[17055]:     from .components import (
Jun 29 23:49:16 DietPi Home Assistant[17055]:     ...<22 lines>...
Jun 29 23:49:16 DietPi Home Assistant[17055]:     )
Jun 29 23:49:16 DietPi Home Assistant[17055]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/homeassistant/components/auth/__init__.py", line 158, in <module>
Jun 29 23:49:16 DietPi Home Assistant[17055]:     from homeassistant.helpers.config_entry_oauth2_flow import OAuth2AuthorizeCallbackView
Jun 29 23:49:16 DietPi Home Assistant[17055]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/homeassistant/helpers/config_entry_oauth2_flow.py", line 25, in <module>
Jun 29 23:49:16 DietPi Home Assistant[17055]:     from habluetooth import BluetoothServiceInfoBleak
Jun 29 23:49:16 DietPi Home Assistant[17055]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/habluetooth/__init__.py", line 26, in <module>
Jun 29 23:49:16 DietPi Home Assistant[17055]:     from .scanner import BluetoothScanningMode, HaScanner, ScannerStartError
Jun 29 23:49:16 DietPi Home Assistant[17055]:   File "src/habluetooth/scanner.py", line 39, in init habluetooth.scanner
Jun 29 23:49:16 DietPi Home Assistant[17055]: ImportError: cannot import name OrPattern
Jun 29 23:49:17 DietPi systemd[1]: home-assistant.service: Main process exited, code=exited, status=1/FAILURE
Jun 29 23:49:17 DietPi systemd[1]: home-assistant.service: Failed with result 'exit-code'.
Jun 29 23:49:17 DietPi systemd[1]: home-assistant.service: Consumed 5.166s CPU time.
Jun 30 20:26:54 DietPi systemd[1]: Started home-assistant.service - Home Assistant (DietPi).
Jun 30 20:27:00 DietPi Home Assistant[26616]: Traceback (most recent call last):
Jun 30 20:27:00 DietPi Home Assistant[26616]:   File "/home/homeassistant/.pyenv/versions/3.13.5/bin/hass", line 8, in <module>
Jun 30 20:27:00 DietPi Home Assistant[26616]:     sys.exit(main())
Jun 30 20:27:00 DietPi Home Assistant[26616]:              ~~~~^^
Jun 30 20:27:00 DietPi Home Assistant[26616]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/homeassistant/__main__.py", line 192, in main
Jun 30 20:27:00 DietPi Home Assistant[26616]:     from . import config, runner
Jun 30 20:27:00 DietPi Home Assistant[26616]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/homeassistant/runner.py", line 16, in <module>
Jun 30 20:27:00 DietPi Home Assistant[26616]:     from . import bootstrap
Jun 30 20:27:00 DietPi Home Assistant[26616]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/homeassistant/bootstrap.py", line 41, in <module>
Jun 30 20:27:00 DietPi Home Assistant[26616]:     from .components import (
Jun 30 20:27:00 DietPi Home Assistant[26616]:     ...<22 lines>...
Jun 30 20:27:00 DietPi Home Assistant[26616]:     )
Jun 30 20:27:00 DietPi Home Assistant[26616]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/homeassistant/components/auth/__init__.py", line 158, in <module>
Jun 30 20:27:00 DietPi Home Assistant[26616]:     from homeassistant.helpers.config_entry_oauth2_flow import OAuth2AuthorizeCallbackView
Jun 30 20:27:00 DietPi Home Assistant[26616]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/homeassistant/helpers/config_entry_oauth2_flow.py", line 25, in <module>
Jun 30 20:27:00 DietPi Home Assistant[26616]:     from habluetooth import BluetoothServiceInfoBleak
Jun 30 20:27:00 DietPi Home Assistant[26616]:   File "/home/homeassistant/.pyenv/versions/3.13.5/lib/python3.13/site-packages/habluetooth/__init__.py", line 26, in <module>
Jun 30 20:27:00 DietPi Home Assistant[26616]:     from .scanner import BluetoothScanningMode, HaScanner, ScannerStartError
Jun 30 20:27:00 DietPi Home Assistant[26616]:   File "src/habluetooth/scanner.py", line 39, in init habluetooth.scanner
Jun 30 20:27:00 DietPi Home Assistant[26616]: ImportError: cannot import name OrPattern
Jun 30 20:27:01 DietPi systemd[1]: home-assistant.service: Main process exited, code=exited, status=1/FAILURE
Jun 30 20:27:01 DietPi systemd[1]: home-assistant.service: Failed with result 'exit-code'.
Jun 30 20:27:01 DietPi systemd[1]: home-assistant.service: Consumed 6.667s CPU time.

The habluetooth module tries to import OrPattern, until python 3.13 it was part of pythons regex module, but was changed with python 3.13

So your python version is not compatible with the HA modules you use.
So you could downgrade python or you wait until HA (or the provider of the third party modules you are using) provides an update to fix this.

BTW the “most optimal” python version for HA is version 3.11.9

Latest HA requires Python 3.13.2 minimum :smile:: core/pyproject.toml at 80a1e0e4cda4644cb12e30ebdffef8229b7bc03f · home-assistant/core · GitHub

But yeah, that does not mean that all integrations are compatible. Some are just not maintained anymore.

Looks like habluetooth imports OrPattern from bleak, which just released its first major v1. There is a PR to add bleak v1 support: feat!: support bleak 1.x by Expl0dingBanana · Pull Request #252 · Bluetooth-Devices/habluetooth · GitHub

Workaround until this has been merged and released might be to downgrade bleak:

sudo -u homeassistant bash
. /home/homeassistant/pyenv-activate.sh
pip3 install bleak==0.22.3
exit
systemctl restart home-assistant