You are not logged in.
Pages: 1
Hello, and thanks in advance. Hope this is in the correct forum.
I have installed home assistant and am trying to get the bluetooth integration working, which connects over dBus. For some reason the dBus connection is not happening, it is giving a connection reset error whenever it tries. Here are the relevant log entries:
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
From what I have seen it doesn't look like pacman created a proper user and is using a systemd dynamic user instead. Would this cause problems with dbus connections, as it looks like it is refusing the connection? Anybody came across this before?
Thanks in advance,
dustovich
Last edited by dustovich (2022-08-29 23:13:04)
Offline
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.
Last edited by dustovich (2022-08-29 23:14:37)
Offline
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!
Ps. I'll see if I can figure out how to add this info to the wiki
Offline
Ya, I submitted a bug report to the package maintainers to do exactly what you have posted. Great minds think alike.
Have you had any issues with zeroconf by chance? I have had an issue with hass going up before the network and it not detecting the network interfaces. I was able to fix it, just wondering if you have experienced anything similar.
Offline
Afraid I didn't see your last question until now. No, haven't had any problem with zeroconf ... but could have something to do with that I have disabled avahi-daemon.service. As always with an installation that one have been running for years is that one have tried and tested hundreds of things and kind of forgot along the way why one did this and not that. In this case I believe I was fooling around with IPV6-resolved-avahi-and-so-on but ended up having to disable those in order to get my server machine running with hostapd+dnsmasq.
Cheers!
Offline
For some extensions (Passive BLE monitor) you also need the CAP_NET_RAW for the (Python) executable.
The earlier method was to use this command:
setcap 'cap_net_raw,cap_net_admin+eip' /usr/bin/python
But the current systemd service is using Python venv together with DynamicUser. You need to add CAP to systemd .service file (ideally to override.conf):
[Service]
AmbientCapabilities=CAP_NET_RAW
CapabilityBoundingSet=CAP_NET_RAW
Offline
Pages: 1