Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After update to 2023.9.1 bluetooth adapter can no longer be auto reset when it fails #99977

Closed
shirou93 opened this issue Sep 9, 2023 · 9 comments · Fixed by #99979
Closed

Comments

@shirou93
Copy link

shirou93 commented Sep 9, 2023

The problem

After update to 2023.9.1 bluetooth integration stop working. Downgrade to 9.0 fix this issue.

What version of Home Assistant Core has the issue?

2023.9.1

What was the last working version of Home Assistant Core?

2023.9.0

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Bluetooth

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?

Logger: homeassistant.config_entries
Source: components/bluetooth/util.py:78
First occurred: 14:54:44 (1 occurrences)
Last logged: 14:54:44

Error setting up entry 8C:88:4B:65:2F:A1 for bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 223, in _async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bleak/__init__.py", line 198, in start
    await self._backend.start()
  File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/scanner.py", line 185, in start
    self._stop = await manager.active_scan(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/manager.py", line 416, in active_scan
    assert_reply(reply)
  File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] Operation already in progress

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 286, in async_setup_entry
    await scanner.async_start()
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 210, in async_start
    await self._async_start()
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 279, in _async_start
    await self._async_reset_adapter()
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 364, in _async_reset_adapter
    result = await async_reset_adapter(self.adapter, self.mac_address)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/util.py", line 78, in async_reset_adapter
    return await recover_adapter(adapter_id, mac_address)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bluetooth_auto_recovery/recover.py", line 393, in recover_adapter
    if adapter and await _power_cycle_adapter(adapter):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bluetooth_auto_recovery/recover.py", line 468, in _power_cycle_adapter
    return await _execute_reset(adapter)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bluetooth_auto_recovery/recover.py", line 554, in _execute_reset
    power_state_before_reset = await adapter.get_powered()
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bluetooth_auto_recovery/recover.py", line 265, in get_powered
    response = await self.protocol.send("ReadControllerInformation", self.idx)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bluetooth_auto_recovery/recover.py", line 153, in send
    with asyncio_timeout(self.timeout):
TypeError: 'Timeout' object does not support the context manager protocol

Additional information

No response

@bdraco
Copy link
Member

bdraco commented Sep 9, 2023

looks like a bug in the reset process. missing async keyword

Bluetooth-Devices/bluetooth-auto-recovery#42

@home-assistant
Copy link

home-assistant bot commented Sep 9, 2023

@bdraco
Copy link
Member

bdraco commented Sep 9, 2023

This also means your bluetooth adapter is unstable and is having to be reset. We will get the reset process fixed for 2023.9.2

I'd recommend switching to a high performance one from:
https://www.home-assistant.io/integrations/bluetooth#known-working-high-performance-adapters

or and ESPHome proxy
https://esphome.github.io/bluetooth-proxies/

bdraco added a commit that referenced this issue Sep 9, 2023
@bdraco bdraco changed the title After update to 2023.9.1 bluetooth stop working After update to 2023.9.1 bluetooth adapter can no longer be auto reset when it fails Sep 9, 2023
@thatslolo
Copy link

I do have two high performance adapters (Feasycom FSC-BP119 and Asus BT-400) and the same issue.

@bdraco
Copy link
Member

bdraco commented Sep 9, 2023

I wouldn't expect the Feasycom FSC-BP119 to ever need a reset (at least mine never do), but I've seen the BT-400s need one if the patch files are missing

Regardless, reset bug will be fixed in 2023.9.2

@Samywamy10
Copy link

Samywamy10 commented Sep 10, 2023

+1 having issue with BTA-403, which is on the high performance list. The onboard rpi 4 bluetooth adapter also fails to start

Logger: homeassistant.config_entries
Source: components/bluetooth/util.py:78
First occurred: 7:56:31 PM (5 occurrences)
Last logged: 8:08:51 PM

Error setting up entry 00:1A:7D:DA:71:13 for bluetooth
Error setting up entry D8:3A:DD:23:19:A1 for bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 223, in _async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bleak/__init__.py", line 198, in start
    await self._backend.start()
  File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/scanner.py", line 185, in start
    self._stop = await manager.active_scan(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/manager.py", line 405, in active_scan
    assert_reply(reply)
  File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.NotReady] Resource Not Ready

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 286, in async_setup_entry
    await scanner.async_start()
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 210, in async_start
    await self._async_start()
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 279, in _async_start
    await self._async_reset_adapter()
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 364, in _async_reset_adapter
    result = await async_reset_adapter(self.adapter, self.mac_address)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/util.py", line 78, in async_reset_adapter
    return await recover_adapter(adapter_id, mac_address)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bluetooth_auto_recovery/recover.py", line 393, in recover_adapter
    if adapter and await _power_cycle_adapter(adapter):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bluetooth_auto_recovery/recover.py", line 468, in _power_cycle_adapter
    return await _execute_reset(adapter)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bluetooth_auto_recovery/recover.py", line 554, in _execute_reset
    power_state_before_reset = await adapter.get_powered()
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bluetooth_auto_recovery/recover.py", line 265, in get_powered
    response = await self.protocol.send("ReadControllerInformation", self.idx)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bluetooth_auto_recovery/recover.py", line 153, in send
    with asyncio_timeout(self.timeout):
TypeError: 'Timeout' object does not support the context manager protocol

@balilu91
Copy link

Adding it for the record, same issue on an Intel NUC's inbuilt Bluetooth

@asdfghjkai
Copy link

Likewise, adding for Plugable USB-BT4LE.

@federicosantolini
Copy link

Same issue on the built-in for the Bmax mini pc

@home-assistant home-assistant locked as resolved and limited conversation to collaborators Sep 11, 2023
balloob pushed a commit that referenced this issue Sep 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants