core
core copied to clipboard
Could not reset the state of the bluetooth adapter
The problem
Getting following when booting Home assistant on my Raspberry Pi 4.
Could not reset the state of the bluetooth adapter when booting for the first time.
What version of Home Assistant Core has the issue?
core-2024.1.2 (now also tested with core-2024.1.3)
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
No response
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
2024-01-13 20:42:13.377 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not reset the power state of the Bluetooth adapter hci0 [B8:27:EB:59:18:98] due to timeout after 5 seconds
2024-01-13 20:42:13.383 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not cycle the Bluetooth adapter hci0 [B8:27:EB:59:18:98]: [Errno 1] Operation not permitted
2024-01-13 20:42:13.385 WARNING (MainThread) [bluetooth_auto_recovery.recover] Bluetooth management socket connection lost: [Errno 22] Invalid argument
2024-01-13 20:42:18.386 WARNING (MainThread) [bluetooth_auto_recovery.recover] Bluetooth adapter hci0 [B8:27:EB:59:18:98] could not be reset:
2024-01-13 20:42:18.391 WARNING (MainThread) [bluetooth_auto_recovery.recover] Closing Bluetooth adapter hci0 [B8:27:EB:59:18:98] failed: [Errno 9] Bad file descriptor
Additional information
I followed this documentation to come up with a small installer script.
https://www.home-assistant.io/installation/linux#install-home-assistant-core
I'm running my Raspberry 4 on Debian Bookworm.
python3 is already the newest version (3.11.2-1+b1).
python3-venv is already the newest version (3.11.2-1+b1).
python3-pip is already the newest version (23.0.1+dfsg-1+rpt1).
python3-dev is already the newest version (3.11.2-1+b1).
bluez is already the newest version (5.66-1+rpt1+deb12u1).
libffi-dev is already the newest version (3.4.4-1).
autoconf is already the newest version (2.71-3).
build-essential is already the newest version (12.9).
tzdata is already the newest version (2023c-5+deb12u1).
ffmpeg is already the newest version (8:5.1.4-0+rpt1+deb12u1).
libssl-dev is already the newest version (3.0.11-1~deb12u2+rpt1).
libjpeg-dev is already the newest version (1:2.1.5-2).
zlib1g-dev is already the newest version (1:1.2.13.dfsg-1).
libopenjp2-7 is already the newest version (2.5.0-2).
libtiff6 is already the newest version (4.5.0-6+deb12u1).
libturbojpeg0-dev is already the newest version (1:2.1.5-2).
liblapack3 is already the newest version (3.11.0-2).
liblapack-dev is already the newest version (3.11.0-2).
libatlas-base-dev is already the newest version (3.10.3-13).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
#!/usr/bin/env bash
USER=homeassistant
DIR=/opt/homeassistant
sudo apt-get install -y python3 python3-venv python3-pip python3-dev \
bluez libffi-dev autoconf build-essential tzdata ffmpeg \
libssl-dev libjpeg-dev zlib1g-dev libopenjp2-7 libtiff6 libturbojpeg0-dev liblapack3 liblapack-dev libatlas-base-dev
if ! id -u "${USER}" >/dev/null 2>&1; then
sudo useradd -rm "${USER}"
fi
sudo mkdir -p "${DIR}"
sudo mkdir -p "/home/${USER}/.homeassistant"
sudo chown "${USER}:${USER}" "${DIR}"
if systemctl is-active --quiet home-assistant; then
sudo systemctl stop home-assistant
fi
sudo -u "${USER}" -H -s <<EOF
pushd "${DIR}" >/dev/null
python3 -m venv .
source bin/activate
python3 -m pip install wheel
pip3 install homeassistant==2024.1.3
popd >/dev/null
EOF
cat <<EOF | sudo tee "/etc/systemd/system/home-assistant.service"
[Unit]
Description=Home Assistant
Wants=network-online.target
After=network-online.target
[Service]
User=${USER}
WorkingDirectory=/home/${USER}/.homeassistant
ExecStart=${DIR}/bin/hass -c "/home/${USER}/.homeassistant"
RestartForceExitStatus=100
RestartSec=5
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl --system daemon-reload
sudo systemctl enable home-assistant
sudo systemctl start home-assistant
I have also tried adding the homeassistant user to the bluetooth group to see if that resolves the issue.
sudo usermod -a -G bluetooth homeassistant
See here the output of the upgrade to 2024.1.3
Collecting homeassistant==2024.1.3
Downloading https://www.piwheels.org/simple/homeassistant/homeassistant-2024.1.3-py3-none-any.whl (33.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 33.6/33.6 MB 384.6 kB/s eta 0:00:00
Requirement already satisfied: aiohttp==3.9.1 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (3.9.1)
Requirement already satisfied: aiohttp-cors==0.7.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (0.7.0)
Requirement already satisfied: aiohttp-fast-url-dispatcher==0.3.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (0.3.0)
Requirement already satisfied: aiohttp-zlib-ng==0.1.3 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (0.1.3)
Requirement already satisfied: astral==2.2 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (2.2)
Requirement already satisfied: attrs==23.1.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (23.1.0)
Requirement already satisfied: atomicwrites-homeassistant==1.4.1 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (1.4.1)
Requirement already satisfied: awesomeversion==23.11.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (23.11.0)
Requirement already satisfied: bcrypt==4.0.1 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (4.0.1)
Requirement already satisfied: certifi>=2021.5.30 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (2023.11.17)
Requirement already satisfied: ciso8601==2.3.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (2.3.0)
Requirement already satisfied: httpx==0.26.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (0.26.0)
Collecting home-assistant-bluetooth==1.12.0
Downloading https://www.piwheels.org/simple/home-assistant-bluetooth/home_assistant_bluetooth-1.12.0-py3-none-any.whl (7.9 kB)
Requirement already satisfied: ifaddr==0.2.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (0.2.0)
Requirement already satisfied: Jinja2==3.1.2 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (3.1.2)
Requirement already satisfied: lru-dict==1.3.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (1.3.0)
Requirement already satisfied: PyJWT==2.8.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (2.8.0)
Requirement already satisfied: cryptography==41.0.7 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (41.0.7)
Requirement already satisfied: pyOpenSSL==23.2.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (23.2.0)
Requirement already satisfied: orjson==3.9.9 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (3.9.9)
Requirement already satisfied: packaging>=23.1 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (23.2)
Requirement already satisfied: pip>=21.3.1 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (23.0.1)
Requirement already satisfied: python-slugify==4.0.1 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (4.0.1)
Requirement already satisfied: PyYAML==6.0.1 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (6.0.1)
Requirement already satisfied: requests==2.31.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (2.31.0)
Requirement already satisfied: typing-extensions<5.0,>=4.9.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (4.9.0)
Requirement already satisfied: ulid-transform==0.9.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (0.9.0)
Requirement already satisfied: urllib3<2,>=1.26.5 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (1.26.18)
Requirement already satisfied: voluptuous==0.13.1 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (0.13.1)
Requirement already satisfied: voluptuous-serialize==2.6.0 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (2.6.0)
Requirement already satisfied: yarl==1.9.4 in ./lib/python3.11/site-packages (from homeassistant==2024.1.3) (1.9.4)
Requirement already satisfied: multidict<7.0,>=4.5 in ./lib/python3.11/site-packages (from aiohttp==3.9.1->homeassistant==2024.1.3) (6.0.4)
Requirement already satisfied: frozenlist>=1.1.1 in ./lib/python3.11/site-packages (from aiohttp==3.9.1->homeassistant==2024.1.3) (1.4.1)
Requirement already satisfied: aiosignal>=1.1.2 in ./lib/python3.11/site-packages (from aiohttp==3.9.1->homeassistant==2024.1.3) (1.3.1)
Requirement already satisfied: zlib-ng>=0.3.0 in ./lib/python3.11/site-packages (from aiohttp-zlib-ng==0.1.3->homeassistant==2024.1.3) (0.4.0)
Requirement already satisfied: pytz in ./lib/python3.11/site-packages (from astral==2.2->homeassistant==2024.1.3) (2023.3.post1)
Requirement already satisfied: cffi>=1.12 in ./lib/python3.11/site-packages (from cryptography==41.0.7->homeassistant==2024.1.3) (1.16.0)
Requirement already satisfied: habluetooth>=0.11.0 in ./lib/python3.11/site-packages (from home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (2.0.2)
Requirement already satisfied: anyio in ./lib/python3.11/site-packages (from httpx==0.26.0->homeassistant==2024.1.3) (4.1.0)
Requirement already satisfied: httpcore==1.* in ./lib/python3.11/site-packages (from httpx==0.26.0->homeassistant==2024.1.3) (1.0.2)
Requirement already satisfied: idna in ./lib/python3.11/site-packages (from httpx==0.26.0->homeassistant==2024.1.3) (3.6)
Requirement already satisfied: sniffio in ./lib/python3.11/site-packages (from httpx==0.26.0->homeassistant==2024.1.3) (1.3.0)
Requirement already satisfied: MarkupSafe>=2.0 in ./lib/python3.11/site-packages (from Jinja2==3.1.2->homeassistant==2024.1.3) (2.1.3)
Requirement already satisfied: text-unidecode>=1.3 in ./lib/python3.11/site-packages (from python-slugify==4.0.1->homeassistant==2024.1.3) (1.3)
Requirement already satisfied: charset-normalizer<4,>=2 in ./lib/python3.11/site-packages (from requests==2.31.0->homeassistant==2024.1.3) (3.2.0)
Requirement already satisfied: h11<0.15,>=0.13 in ./lib/python3.11/site-packages (from httpcore==1.*->httpx==0.26.0->homeassistant==2024.1.3) (0.14.0)
Requirement already satisfied: pycparser in ./lib/python3.11/site-packages (from cffi>=1.12->cryptography==41.0.7->homeassistant==2024.1.3) (2.21)
Requirement already satisfied: bleak>=0.21.1 in ./lib/python3.11/site-packages (from habluetooth>=0.11.0->home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (0.21.1)
Requirement already satisfied: bleak-retry-connector>=3.3.0 in ./lib/python3.11/site-packages (from habluetooth>=0.11.0->home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (3.4.0)
Requirement already satisfied: bluetooth-adapters>=0.16.1 in ./lib/python3.11/site-packages (from habluetooth>=0.11.0->home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (0.16.2)
Requirement already satisfied: bluetooth-auto-recovery>=1.2.3 in ./lib/python3.11/site-packages (from habluetooth>=0.11.0->home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (1.2.3)
Requirement already satisfied: bluetooth-data-tools>=1.16.0 in ./lib/python3.11/site-packages (from habluetooth>=0.11.0->home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (1.19.0)
Requirement already satisfied: dbus-fast<3,>=1.83.0 in ./lib/python3.11/site-packages (from bleak>=0.21.1->habluetooth>=0.11.0->home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (2.21.0)
Requirement already satisfied: mac-vendor-lookup>=0.1.12 in ./lib/python3.11/site-packages (from bluetooth-adapters>=0.16.1->habluetooth>=0.11.0->home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (0.1.12)
Requirement already satisfied: usb-devices>=0.4.5 in ./lib/python3.11/site-packages (from bluetooth-adapters>=0.16.1->habluetooth>=0.11.0->home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (0.4.5)
Requirement already satisfied: PyRIC>=0.1.6.3 in ./lib/python3.11/site-packages (from bluetooth-auto-recovery>=1.2.3->habluetooth>=0.11.0->home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (0.1.6.3)
Requirement already satisfied: btsocket>=0.2.0 in ./lib/python3.11/site-packages (from bluetooth-auto-recovery>=1.2.3->habluetooth>=0.11.0->home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (0.2.0)
Requirement already satisfied: aiofiles in ./lib/python3.11/site-packages (from mac-vendor-lookup>=0.1.12->bluetooth-adapters>=0.16.1->habluetooth>=0.11.0->home-assistant-bluetooth==1.12.0->homeassistant==2024.1.3) (23.2.1)
Installing collected packages: home-assistant-bluetooth, homeassistant
Attempting uninstall: home-assistant-bluetooth
Found existing installation: home-assistant-bluetooth 1.11.0
Uninstalling home-assistant-bluetooth-1.11.0:
Successfully uninstalled home-assistant-bluetooth-1.11.0
Attempting uninstall: homeassistant
Found existing installation: homeassistant 2024.1.2
Uninstalling homeassistant-2024.1.2:
Successfully uninstalled homeassistant-2024.1.2
Successfully installed home-assistant-bluetooth-1.12.0 homeassistant-2024.1.3
Happy to help out and provider more debugging info with some guidance.
I have the same issue on Dietpi 8.25 that is based on Debian Bookworm. Noticed that before the update of HA to 2024.1 there was some updated of system packages related to bluetooth, like libbluetooth
also if I login in as homeassistant user and launch bluetoothctl
I can successfully open the controller.
also granted python root access to hci as mentioned here in step 0 https://custom-components.github.io/ble_monitor/Installation
Looks like the same issue as https://github.com/home-assistant/core/issues/92379
This is the default /dbus/
config.
<!-- This configuration file specifies the required security policies
for Bluetooth core daemon to work. -->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- ../system.conf have denied everything, so we just punch some holes -->
<policy user="root">
<allow own="org.bluez"/>
<allow send_destination="org.bluez"/>
<allow send_interface="org.bluez.AdvertisementMonitor1"/>
<allow send_interface="org.bluez.Agent1"/>
<allow send_interface="org.bluez.MediaEndpoint1"/>
<allow send_interface="org.bluez.MediaPlayer1"/>
<allow send_interface="org.bluez.Profile1"/>
<allow send_interface="org.bluez.GattCharacteristic1"/>
<allow send_interface="org.bluez.GattDescriptor1"/>
<allow send_interface="org.bluez.LEAdvertisement1"/>
<allow send_interface="org.freedesktop.DBus.ObjectManager"/>
<allow send_interface="org.freedesktop.DBus.Properties"/>
<allow send_interface="org.mpris.MediaPlayer2.Player"/>
</policy>
<!-- allow users of bluetooth group to communicate -->
<policy group="bluetooth">
<allow send_destination="org.bluez"/>
</policy>
<policy context="default">
<allow send_destination="org.bluez"/>
</policy>
</busconfig>
The bluetooth group might require more permissions for home assistant? 🤔
Today I've updagraded HA to 2024 1.3 and the issue is solved for me.
I'm on 2024.1.3 but the issue remains for me.
Today I've updagraded HA to 2024 1.3 and the issue is solved for me.
Are you on a raspberry Pi? Which OS?
I'm running 2024.1.3
as well but it still fails.
@marcofranssen do you stille have the issue?
@marcofranssen do you stille have the issue?
Yes haven't found a solution yet. Although I see there is a new release, so I can try to upgrade once I find some time.
I have no idea if this is the same issue. Suddenly I had a check box in the Passive BLE monitor integration, where I had to uncheck "Dont use bluetooth adapter". Now everything is fine :D
Den 9. februar 2024 20.23.08 CET, Marco Franssen @.***> skrev:
@marcofranssen do you stille have the issue?
Yes haven't found a solution yet.
-- Reply to this email directly or view it on GitHub: https://github.com/home-assistant/core/issues/107981#issuecomment-1936478570 You are receiving this because you commented.
Message ID: @.***>
I have no idea if this is the same issue. Suddenly I had a check box in the Passive BLE monitor integration, where I had to uncheck "Dont use bluetooth adapter". Now everything is fine :D Den 9. februar 2024 20.23.08 CET, Marco Franssen @.***> skrev: …
@marcofranssen do you stille have the issue? Yes haven't found a solution yet. -- Reply to this email directly or view it on GitHub: #107981 (comment) You are receiving this because you commented. Message ID: @.***>
Unfortunately I don't have that integration.
I did test with the 2024.2.1
release as well, still an issue. I suspect linux permissions issues, but have no clue what has to be fixed.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.