Open npasslick opened 7 months ago
Similarly to #3047 it seems to me that the adapter still works but habluetooth
ends up stuck trying to restart it - IMHO it should be more resilient to that, please create a Core issue for debugging it on that side. I don't see any apparent issues with the adapter, can you also check dmesg | grep -i bluetooth
?
This is the dmesg
output
Similarly to #3047 it seems to me that the adapter still works but
habluetooth
ends up stuck trying to restart it - IMHO it should be more resilient to that, please create a Core issue for debugging it on that side. I don't see any apparent issues with the adapter, can you also checkdmesg | grep -i bluetooth
?
Do you have a suggestion on what hablueooth
should do in this case? Its going to try every time setup retry fires which is every few minutes.
@npasslick Does the problem go away if you turn on passive scanning
Its timing out on the dbus call
@npasslick Does the problem go away if you turn on passive scanning
I will try that
@npasslick Does the problem go away if you turn on passive scanning
I have upgraded my system back to HAOS 12.0 and activated passive scanning immediately.
The activation of passive scanning seems to have actually prevented the problem so far, as I already mentioned, the integration usually crashes within an hour of system startup, and this period has now elapsed. Seems to be a suitable workaround for now, but of course it won't solve the problem long-term.
I will have to wait and see if the Bluetooth integration does not crash over a longer period of time with passive scanning, but looks good so far.
[bluetooth]# scan off
Discovery stopped
[bluetooth]# scan on
Discovery started
[bluetooth]# scan on
Failed to start discovery: org.bluez.Error.InProgress
[bluetooth]#
If it happens again in adviceactive mode, can you try turning the scan off
with bluetoothctl
, pasting the output here, and seeing if it can recover?
If it happens again in advice mode, can you try turning the
scan off
withbluetoothctl
, pasting the output here, and seeing if it can recover?
Sure thing, I guess with advice mode you mean active / non-passive mode?
Sorry, flipping between too many things this morning: should have wrote: active mode
Sorry, flipping between too many things this morning: should have wrote: active mode
No worries, i will try that ^^
If it happens again in ~advice~active mode, can you try turning the
scan off
withbluetoothctl
, pasting the output here, and seeing if it can recover?
Unsurprisingly, the bluetooth integration failed again in active mode. It does not recover after scan off
or scan on
scan off
--> org.bluez.Error.Failed
scan on
---> scan off
--> org.bluez.Error.InProgress
It seems like there isn't much we can do in habluetooth
if its failing in bluetoothctl
which means its too far down the stack for any retries to work.
I expect passive is going to work fine because it doesn't hit the path where you get the bluez errors
It seems like there isn't much we can do in
habluetooth
if its failing inbluetoothctl
which means its too far down the stack for any retries to work.I expect passive is going to work fine because it doesn't hit the path where you get the bluez errors
Hmm I see, then something underlying must have changed after HAOS 11.0, but thanks for the tip with the passive mode, for my purposes this should be sufficient, but others will certainly have to deal with this problem. Maybe someone else can identify the underlying problem.
@bdraco Thank you much for your effort so far, at least I can use the current version of HAOS now ^^ Keep up the good work, I will make a small donation to your Food Bank as a gesture of my appreciation (y)
Having the same issue on my Raspberry Pi 4. Passive mode fixes the initialisation issue for the bluetooth integration but breaks my switchbot bots. Switchbot curtains do work in passive mode. If there is some additional stuff, I can test for you guys feel free to let me know and I will give it a shot.
I upgraded HA Core from 2023.12.3 to 2024.3.0 and experienced the similar issue. My Bluetooth sensors would periodically disconnect then reconnect sporadically. I downgraded to 2023.12.3 and Bluetooth devices work again:
I also upgraded to HA Core 2024.3.2 and within an hour I started getting sensor unavailable messages. Reverting back to 2024.1.5
Likewise, no improvement for me with the latest version of HA Core in Bluetooth active mode
Well, now I'm in a situation where I've got a new device and passive scanning is simply not enough to ensure reliable operation. I hope someone can take care of this soon, unfortunately my skills are currently not sufficient for hardware-oriented programming :(
On my end the bluetooth issue with raspberry Pi popped up in 12.1. Downgrading to 12.0 fixes the problem. In case others are searching for how to downgrade the OS version issue the following command in an SSH session:
ha os update --version 12.0
I found a weird way to temporarily fix the issue. Bluetooth isn't willing to initialize in active mode after a software reboot. When I unplug the power and replug the power Bluetooth initialises with no issues in active mode until the next software reboot.
I just tried 12.2 and the problem may be fixed.
Problem also is fixed here with the new 12.2 update.
I'm on 12.2 with a Homeassistant Yellow (CM4). Problem still persists. Or actually, I did not have this problem before, but now I got it.
Seems like this problem has been pending for a bit. Any progress?
I found a weird way to temporarily fix the issue. Bluetooth isn't willing to initialize in active mode after a software reboot. When I unplug the power and replug the power Bluetooth initialises with no issues in active mode until the next software reboot.
Sadly its pretty common that these chips will stop responding and need to be powered down to get them to work again.
The upcoming HAOS 12.3 uses the 6.6.x linux kernels which, at least for me, seems to be a bit more stable with the RPi Bluetooth hardware.
I have a rpi4-64. What gets me is 4 weeks ago and for at least a year before it all worked perfectly. Nothing in the hardware has changed. So it must be HAOS. What changed? Someone must know. I have tried the scan thing but makes no difference and tried the power off/power on thing and again no difference. The only thing that works is turning the mains power off and on again. This is not a solution in the long term.
[bluetooth]# scan off
Failed to stop discovery: org.bluez.Error.Failed
[bluetooth]# scan on
[bluetooth]#
The only thing that works is turning the mains power off and on again. This is not a solution in the long term.
Sad life now :-) :-) :-) :-(
I have a rpi4-64. What gets me is 4 weeks ago and for at least a year before it all worked perfectly. Nothing in the hardware has changed. So it must be HAOS. What changed? Someone must know. I have tried the scan thing but makes no difference and tried the power off/power on thing and again no difference. The only thing that works is turning the mains power off and on again. This is not a solution in the long term.
[bluetooth]# scan off Failed to stop discovery: org.bluez.Error.Failed [bluetooth]# scan on [bluetooth]#
The only thing that works is turning the mains power off and on again. This is not a solution in the long term.
Same for me on a rpi3. Only power cycling (manually taking away the power for some time) fixes the issue for a couple of hours/days.
@auditdata @StahlTim did you try HAOS 12.3? It comes with and updated Linux kernel which might change things. Also do you use active or passive mode?
Seems like HAOS 12.3 has finally fixed this problem at least for me. The Bluetooth integration has been working in active mode since this morning without crashing. We'll see how it works in the long run and what other affected users running HAOS report, but I have a good feeling.
@auditdata @StahlTim did you try HAOS 12.3? It comes with and updated Linux kernel which might change things. Also do you use active or passive mode?
Not sue as I cut my losses and bought an external Bluetooth adapter and all worked again. I guess I could unplug it and have a look but might wait for others to confirm now working again.
@auditdata @StahlTim did you try HAOS 12.3? It comes with and updated Linux kernel which might change things. Also do you use active or passive mode?
I am on 12.3 since its release and bluetooth is still not working in active mode (only for a couple of hours/days after power toggle).
Should I switch to passive mode?
@auditdata @StahlTim did you try HAOS 12.3? It comes with and updated Linux kernel which might change things. Also do you use active or passive mode?
I am on 12.3 since its release and bluetooth is still not working in active mode (only for a couple of hours/days after power toggle).
Should I switch to passive mode?
Passive mode should generally work even with the bug (at least that was my workaround until the recent HAOS update), but keep in mind that you will lose functionalities that require active Bluetooth scanning if you have devices that provide those
@agners @npasslick My sensors require me to stick with active mode. However, did another power-unplug 2d ago (I think the first time after upgrading to 12.3).
Maybe upgrading and rebooting to 12.3 alone did not fix the issue, but an additional power cycle (actual removing power physically) helped to complete the process.
Will monitor further and report if failing/dropping again.
Update: Was on vacation - Bluetooth devices did disconnect again during my absence. Issue still present.
Huh. I have two servers in two locations both running on Raspberry Pi. In one location the issue is fixed. In the other location it is not. Both on the same versions of HA OS and HA.
Just reviewed the logs once more, with the latest HAOS, the Bluetooth device is not listed as faulty within the homeassistant GUI, but in the logs, there are several:
hci0 (XX:XX:XX:XX:XX:XX): Successful fall-back to passive scanning mode after active scanning failed (4/4)
These warnings seem to be published every second minute.
There hasn't been any activity on this issue recently. To keep our backlog manageable we have to clean old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant OS 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.
Unfortunately, my Raspberry Pi 4 has very unstable Bluetooth even on the latest version of Home Assistant OS. Anything we can do to help debug the issue?
For me, this issue only went away after upgrading to a Pi 5 4gb from a Pi3 B 1gb
Had similiar issues, but I upgraded from 11.5. I finally got mad enough to do a full backup and rebuild the SD card with a new image, the bluetooth reappeared without issue. EMQX on the other hand took a beating, but that was quickly solved :). So might be something inherent of the upgrading process?
Describe the issue you are experiencing
On my Raspberry Pi 3B+ with Home Assistant OS 12.0 currently installed, I unfortunately experienced that the Bluetooth integration for HAOS regularly crashes/becomes unavailable with HAOS version greater 11.0. The Bluetooth integration is usually still available when HAOS is rebooted or started, but then becomes unavailable within a maximum of one hour (usually significantly faster). This is most noticeable for me in the fact that my BTHome sensors will no longer be available from this point on.
Currently I always have to downgrade to HAOS version 11.0 to have Bluetooth consistently available again and I had hoped that this problem would be solved with version 12.0 at the latest, but the problem persists.
I use onboard Bluetooth from my Raspberry Pi 3B+ board and no external adapter. Updates of Home Assistant Core / Supervisor have no influence, the problem only ever appears when upgrading HAOS to >11.0. Other components are up-to-date.
Similar issues: #3207 #3180 #3047 (solution approaches in these issues without effect)
What operating system image do you use?
rpi3-64 (Raspberry Pi 3 64-bit OS)
What version of Home Assistant Operating System is installed?
12.0
Did you upgrade the Operating System.
Yes
Steps to reproduce the issue
Anything in the Supervisor logs that might be useful for us?
Anything in the Host logs that might be useful for us?
System information
System Information
Home Assistant Community Store
GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4996 Installed Version | 1.33.0 Stage | running Available Repositories | 1399 Downloaded Repositories | 7Home Assistant Cloud
logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | okHome Assistant Supervisor
host_os | Home Assistant OS 12.0 -- | -- update_channel | stable supervisor_version | supervisor-2024.02.0 agent_version | 1.6.0 docker_version | 24.0.7 disk_total | 58.0 GB disk_used | 8.0 GB healthy | true supported | true board | rpi3-64 supervisor_api | ok version_api | ok installed_addons | Terminal & SSH (9.9.0), File editor (5.8.0), Cloudflared (5.1.4)Dashboards
dashboards | 1 -- | -- resources | 0 views | 4 mode | storageRecorder
oldest_recorder_run | February 19, 2024 at 3:01 AM -- | -- current_recorder_run | February 28, 2024 at 11:51 PM estimated_db_size | 705.62 MiB database_engine | sqlite database_version | 3.44.2Additional information
Other relevant logs
Logger: habluetooth.scanner, source: /usr/local/lib/python3.12/asyncio/events.py:84
Logger: habluetooth.scanner Source: /usr/local/lib/python3.12/asyncio/events.py:84 First occurred: 12:05:51 AM (48 occurrences) Last logged: 12:52:51 AM hci0 (B8:27:EB:3C:56:D2): Failed to restart Bluetooth scanner: hci0 (B8:27:EB:3C:56:D2): Timed out starting Bluetooth after 15 seconds; Try power cycling the Bluetooth hardware. Traceback (most recent call last): File "src/habluetooth/scanner.py", line 249, in habluetooth.scanner.HaScanner._async_start File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 198, in start await self._backend.start() File "/usr/local/lib/python3.12/site-packages/bleak/backends/bluezdbus/scanner.py", line 185, in start self._stop = await manager.active_scan( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/bleak/backends/bluezdbus/manager.py", line 408, in active_scan reply = await self._bus.call( ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/dbus_fast/aio/message_bus.py", line 384, in call await future asyncio.exceptions.CancelledError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "src/habluetooth/scanner.py", line 248, in habluetooth.scanner.HaScanner._async_start File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__ raise TimeoutError from exc_val TimeoutError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "src/habluetooth/scanner.py", line 380, in habluetooth.scanner.HaScanner._async_restart_scanner File "src/habluetooth/scanner.py", line 294, in _async_start habluetooth.scanner.ScannerStartError: hci0 (B8:27:EB:3C:56:D2): Timed out starting Bluetooth after 15 seconds; Try power cycling the Bluetooth hardware.Logger: habluetooth.scanner, source: runner.py:188
Logger: habluetooth.scanner Source: runner.py:188 First occurred: 12:03:16 AM (2 occurrences) Last logged: 12:05:16 AM hci0 (B8:27:EB:3C:56:D2): Error stopping scanner: [org.bluez.Error.InProgress] Operation already in progressFull Home Assistant Core log
[home-assistant_2024-02-29T00-33-26.162Z.log](https://github.com/home-assistant/operating-system/files/14441310/home-assistant_2024-02-29T00-33-26.162Z.log)