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

fix: wait for connection made #45

Merged
merged 2 commits into from
Apr 18, 2024
Merged

fix: wait for connection made #45

merged 2 commits into from
Apr 18, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Apr 17, 2024

There is a race here so we need a future in case the connection takes a while to be made

fixes

Apr 17 23:41:29 homeassistant homeassistant[518]: 2024-04-17 18:41:29.974 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Realtek Bluetooth 5.1 Radio (0bda:8771) (00:E0:43:86:0B:03) for bluetooth
Apr 17 23:41:29 homeassistant homeassistant[518]: Traceback (most recent call last):
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "/usr/src/homeassistant/homeassistant/config_entries.py", line 575, in async_setup
Apr 17 23:41:29 homeassistant homeassistant[518]:     result = await component.async_setup_entry(hass, self)
Apr 17 23:41:29 homeassistant homeassistant[518]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 301, in async_setup_entry
Apr 17 23:41:29 homeassistant homeassistant[518]:     adapter = await manager.async_get_adapter_from_address_or_recover(address)
Apr 17 23:41:29 homeassistant homeassistant[518]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "src/habluetooth/manager.py", line 240, in async_get_adapter_from_address_or_recover
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "src/habluetooth/manager.py", line 249, in _async_recover_failed_adapters
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "src/habluetooth/manager.py", line 256, in habluetooth.manager.BluetoothManager._async_recover_failed_adapters
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "/usr/local/lib/python3.12/site-packages/habluetooth/util.py", line 13, in async_reset_adapter
Apr 17 23:41:29 homeassistant homeassistant[518]:     return await recover_adapter(adapter_id, mac_address)
Apr 17 23:41:29 homeassistant homeassistant[518]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/__init__.py", line 31, in recover_adapter
Apr 17 23:41:29 homeassistant homeassistant[518]:     return await recover_module.recover_adapter(hci, mac)  # type: ignore
Apr 17 23:41:29 homeassistant homeassistant[518]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 400, in recover_adapter
Apr 17 23:41:29 homeassistant homeassistant[518]:     if adapter and await _power_cycle_adapter(adapter):
Apr 17 23:41:29 homeassistant homeassistant[518]:                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 475, in _power_cycle_adapter
Apr 17 23:41:29 homeassistant homeassistant[518]:     return await _execute_reset(adapter)
Apr 17 23:41:29 homeassistant homeassistant[518]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 594, in _execute_reset
Apr 17 23:41:29 homeassistant homeassistant[518]:     return await _execute_power_on(adapter, name, power_state_before_reset)
Apr 17 23:41:29 homeassistant homeassistant[518]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 602, in _execute_power_on
Apr 17 23:41:29 homeassistant homeassistant[518]:     await adapter.set_powered(True)
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 281, in set_powered
Apr 17 23:41:29 homeassistant homeassistant[518]:     response = await self.protocol.send(
Apr 17 23:41:29 homeassistant homeassistant[518]:                ^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 17 23:41:29 homeassistant homeassistant[518]:   File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 158, in send
Apr 17 23:41:29 homeassistant homeassistant[518]:     assert self.transport is not None  # nosec
Apr 17 23:41:29 homeassistant homeassistant[518]:     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 17 23:41:29 homeassistant homeassistant[518]: AssertionError

@bdraco bdraco marked this pull request as ready for review April 18, 2024 00:10
@bdraco bdraco merged commit 70aa8df into main Apr 18, 2024
9 checks passed
@bdraco bdraco deleted the connection_made_future branch April 18, 2024 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant