core: Bluetooth intragration crashes after some time (<1h)

The problem

I am running the new bluetooth integration together with BTHome to connect some devices.

This works fine for about 1h after HA has been started. After that time, the integration crashes/fails and can’t recover, I get 2 different error logs and 1 exception, see below.

If I restart HA, it works again for “some time”. That is ONLY HA itself, not the whole docker container.

What version of Home Assistant Core has the issue?

2022.9.0

What was the last working version of Home Assistant Core?

just started using the integration

What type of installation are you running?

Home Assistant Container

Integration causing the issue

bluetooth

Link to integration documentation on our website

https://www.home-assistant.io/integrations/bluetooth

Diagnostics information

config_entry-bluetooth-93965a9f3e7c5aba4a990940a064fe57.json.txt

Example YAML snippet

none

Anything in the logs that might be useful for us?

2022-09-08 11:13:33.970 ERROR (SyncWorker_3) [bluetooth_auto_recovery.recover] RF kill switch check failed - no data for hci0. Available data: {}
2022-09-08 11:13:34.049 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 360, in _async_scanner_watchdog
    await self._async_reset_adapter()
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 382, in _async_reset_adapter
    result = await async_reset_adapter(self.adapter)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/util.py", line 79, in async_reset_adapter
    return await recover_adapter(adapter_id)
  File "/usr/local/lib/python3.10/site-packages/bluetooth_auto_recovery/recover.py", line 236, in recover_adapter
    return await _reset_bluetooth(hci)
  File "/usr/local/lib/python3.10/site-packages/bluetooth_auto_recovery/recover.py", line 150, in _reset_bluetooth
    adapter: MGMTBluetoothCtl = await loop.run_in_executor(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/bluetooth_auto_recovery/recover.py", line 68, in __init__
    idxdata = btmgmt_sync.send("ReadControllerIndexList", None)
  File "/usr/local/lib/python3.10/site-packages/btsocket/btmgmt_sync.py", line 22, in send
    sock = btmgmt_socket.open()
  File "/usr/local/lib/python3.10/site-packages/btsocket/btmgmt_socket.py", line 58, in open
    raise BluetoothSocketError("Unable to open PF_BLUETOOTH socket")

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

See the section in the Bluetooth docs on switching to passive scanning.

I have the same “Unable to open PF_BLUETOOTH socket” exception. Note that I run HA inside a container, so PF_BLUETOOTH socket is expected to fail, because only dbus interface is available.

Similar problem, but not only BT integration crash, but all HA… I use Proxmox VM and my BT is a embedded Intel Wireless-AC 9260 Bluetooth Adapter.

I use USB passthrough to add this device to HA VM. (HASS.OS virtual machine)

If it happen i saw some error on HA VM console, that meen they can not access BT device.

It start with this log errors in HA, after follow on HA VM console error messages and after HA is crash…

2022-09-09 18:57:51.995 ERROR (SyncWorker_6) [homeassistant.components.bluetooth_tracker.device_tracker] Couldn't discover bluetooth devices: error communicating with local bluetooth adapter