[Solved] Cannot get bluetooth integration to start. Dbus error. Arch

Hello,
I am trying to get the Bluetooth to work in my HA install. I am running Arch fully updated using the latest 1:2022.8.7-1 version provided by the maintainers. Bluetooth is working just fine for other devices and this is a fairly fresh install so everything should be OK. It looks to me like it cannot connect to dBus, but the services are all there and running without issue. Please see the attached log entries from the HA web interface.

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/bluetooth/__init__.py", line 261, in async_setup_entry
    await manager.async_start(
  File "/usr/lib/python3.10/site-packages/homeassistant/components/bluetooth/__init__.py", line 359, in async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
  File "/usr/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 812, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 295, in async_init
    await bus.connect()
  File "/usr/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 177, in connect
    return await future
  File "/usr/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 158, in on_hello
    raise err
  File "/usr/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 365, in _message_reader
    if self._unmarshaller.unmarshall():
  File "/usr/lib/python3.10/site-packages/dbus_next/_private/unmarshaller.py", line 304, in unmarshall
    self._unmarshall()
  File "/usr/lib/python3.10/site-packages/dbus_next/_private/unmarshaller.py", line 243, in _unmarshall
    self.read(16, prefetch=True)
  File "/usr/lib/python3.10/site-packages/dbus_next/_private/unmarshaller.py", line 89, in read
    data = read_sock(missing_bytes)
  File "/usr/lib/python3.10/site-packages/dbus_next/_private/unmarshaller.py", line 83, in read_sock
    return self.stream.read(length)
  File "/usr/lib/python3.10/socket.py", line 705, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer

and

 Logger: homeassistant.config_entries
Source: config_entries.py:388
First occurred: 10:33:22 PM (1 occurrences)
Last logged: 10:33:22 PM
Config entry 'Bluetooth' for bluetooth integration not ready yet: DBus connection broken: [Errno 32] Broken pipe; try restarting `bluetooth` and `dbus`; Retrying in background

Thanks in advance

More info. It looks like arch uses a systemd dynamic user in the unit file so there is no ‘real’ user account created. This might have something to do why dBus doesn’t want to talk.

It looks like this is a bug in systemd that is not solvable at this moment. Switching to dbus-broker solves the issue according to the github issue.

Great work, I experienced the same issue with my Arch installation. For reference I can mention an alternative solution. If one doesn’t want to switch from dbus to dbus-broker one can add a system user and group “hass”:

sudo useradd -U -r -s /usr/bin/nologin hass

sudo systemctl edit home-assistant

[Service]
DynamicUser=false

Thanks for finding the root cause and cheers!

1 Like

Thank you. Having the same problem and thanks to your solution I managed to solve it.
Thank you very much. Great.