home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.11k stars 31.1k forks source link

Error stopping scanner - Bluetooth no longer reliable after migration to Home Assistant Yelllow #91326

Closed smartmatic closed 1 year ago

smartmatic commented 1 year ago

The problem

I've migrated from a RPI4 with internal Bluetooth to Home Assistant Yellow. I am using now a Bluetooth Adapter (CSR8510 A10) connected with a extension cable to the Yellow.

On the other USB port is a Conbee II Zigbee adapter connected without a extension cable. Zigbee runs solid.

I read somewhere that a extension cable is no longer needed with HA Yellow as the ports are USB 2.0. Is that correct?

What version of Home Assistant Core has the issue?

2023.4.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Bluetooth

Link to integration documentation on our website

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

Diagnostics information

config_entry-bluetooth-6d3b758e8abcb7ccb53d8c92b3e2c191.json.txt

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Error
Logger: homeassistant.components.bluetooth.scanner
Source: components/bluetooth/scanner.py:340
Integration: Bluetooth (documentation, issues)
First occurred: April 12, 2023 at 21:42:56 (26 occurrences)
Last logged: 07:40:03

hci0 (C0:FB:F9:61:A9:68): Error stopping scanner: [org.bluez.Error.Failed] No discovery started
hci0 (C0:FB:F9:61:A9:68): Error stopping scanner: [org.bluez.Error.InProgress] Operation already in progress

Warning:
Logger: bluetooth_auto_recovery.recover
Source: components/bluetooth/util.py:78
First occurred: 00:07:57 (5 occurrences)
Last logged: 07:40:08

Bluetooth adapter hci0 [C0:FB:F9:61:A9:68] successfully turned back ON
Bluetooth adapter hci0 [C0:FB:F9:61:A9:68] could not be reset due to timeout

ESPHome:
Logger: aioesphomeapi.connection
Source: runner.py:179
First occurred: April 12, 2023 at 21:44:45 (83 occurrences)
Last logged: 08:11:35

esp32-proxy-heizung @ 192.168.178.191: Connection error occurred: EOF received
esp32-bluetooth-proxy-cb78c8 @ 192.168.178.211: Connection error occurred: EOF received
esp32-bluetooth-proxy-cb78c8 @ 192.168.178.211: Connection error occurred: [Errno 104] Connection reset by peer
flexispot-ek5 @ 192.168.178.246: Connection error occurred: Ping response not received after 90.0 seconds
flexispot-ek5 @ 192.168.178.246: Connection error occurred: [Errno 104] Connection reset by peer

Switchbot:
Logger: homeassistant.components.switchbot
Source: components/bluetooth/active_update_coordinator.py:132
Integration: SwitchBot (documentation, issues)
First occurred: 05:16:09 (1 occurrences)
Last logged: 05:16:09

F2:75:CE:49:F2:F3: Bluetooth error whilst polling: (F2:75:CE:49:F2:F3) - F2:75:CE:49:F2:F3: Failed to connect: Timeout waiting for connect response while connecting to F2:75:CE:49:F2:F3 after 20.0s, disconnect timed out: True, after 5.0s

BLE Fibaro CO Sensor Error:
Logger: aiohomekit.controller.ble.pairing
Source: components/esphome/bluetooth/client.py:126
First occurred: 01:00:46 (1 occurrences)
Last logged: 01:00:46

FIBARO CO Sensor [AC:17:02:24:C4:16] (id=1C:3C:B9:BB:1B:C1): Failed to fetch disconnected events: Connection not done for esp32-proxy-heizung @ 192.168.178.191; current state is ConnectionState.INITIALIZED!; rssi=-85
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 102, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 605, in write_gatt_char
    await self._client.bluetooth_gatt_write(
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 770, in bluetooth_gatt_write
    await self._send_bluetooth_message_await_response(
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 436, in _send_bluetooth_message_await_response
    self._check_authenticated()
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 297, in _check_authenticated
    self._check_connected()
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 291, in _check_connected
    raise APIConnectionError(
aioesphomeapi.core.APIConnectionError: Connection not done for esp32-proxy-heizung @ 192.168.178.191; current state is ConnectionState.INITIALIZED!

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 620, in _process_disconnected_events
    protocol_param = await self._process_disconnected_events_with_retry()
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 189, in _async_operation_lock_wrap
    return await func(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 454, in _async_wrap_bluetooth_connection_error_retry
    return await func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 205, in _async_disconnect_on_missing_services_wrap
    return await func(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 231, in _async_restore_and_resume
    return await func(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 652, in _process_disconnected_events_with_retry
    await self._get_characteristics_while_connected(
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 1399, in _get_characteristics_while_connected
    data = await self._async_request_under_lock(OpCode.CHAR_READ, char)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 447, in _async_request_under_lock
    pdu_status, result_data = await ble_request(
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/client.py", line 72, in ble_request
    await _write_pdu(client, encryption_key, opcode, handle, iid, data, tid)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/client.py", line 99, in _write_pdu
    await client.write_gatt_char(
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 90, in _async_wrap_bluetooth_connected_operation
    return action_task.result()
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 126, in _async_wrap_bluetooth_operation
    raise BleakError(str(err)) from err
bleak.exc.BleakError: Connection not done for esp32-proxy-heizung @ 192.168.178.191; current state is ConnectionState.INITIALIZED!

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (bluetooth) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `bluetooth` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign bluetooth` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


bluetooth documentation bluetooth source (message by IssueLinks)

thunder312 commented 1 year ago

Same with me. It looks like bluetooth gets stuck after about half a day of running. I recognized it only a half day later.

sudo systemctl status bluetooth.service ● bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2023-04-12 09:33:41 CEST; 1 day 9h ago Docs: man:bluetoothd Main PID: 761 (bluetoothd) Status: "Running" Tasks: 1 (limit: 9260) Memory: 2.7M CPU: 13min 45.246s CGroup: /system.slice/bluetooth.service └─761 /usr/lib/bluetooth/bluetoothd -d

Apr 13 19:04:49 homeassistant bluetoothd[761]: src/rfkill.c:rfkill_event() RFKILL event idx 17480 type 2 op 0 soft 0 hard 0 Apr 13 19:04:51 homeassistant bluetoothd[761]: src/rfkill.c:rfkill_event() RFKILL event idx 17480 type 2 op 1 soft 0 hard 0 Apr 13 19:04:51 homeassistant bluetoothd[761]: src/rfkill.c:rfkill_event() RFKILL event idx 17481 type 2 op 0 soft 0 hard 0 Apr 13 19:04:53 homeassistant bluetoothd[761]: src/rfkill.c:rfkill_event() RFKILL event idx 17481 type 2 op 1 soft 0 hard 0 Apr 13 19:04:53 homeassistant bluetoothd[761]: src/rfkill.c:rfkill_event() RFKILL event idx 17482 type 2 op 0 soft 0 hard 0 Apr 13 19:04:55 homeassistant bluetoothd[761]: src/rfkill.c:rfkill_event() RFKILL event idx 17482 type 2 op 1 soft 0 hard 0 Apr 13 19:04:56 homeassistant bluetoothd[761]: src/rfkill.c:rfkill_event() RFKILL event idx 17483 type 2 op 0 soft 0 hard 0 Apr 13 19:04:57 homeassistant bluetoothd[761]: src/rfkill.c:rfkill_event() RFKILL event idx 17483 type 2 op 1 soft 0 hard 0 Apr 13 19:04:58 homeassistant bluetoothd[761]: src/rfkill.c:rfkill_event() RFKILL event idx 17484 type 2 op 0 soft 0 hard 0 Apr 13 19:05:00 homeassistant bluetoothd[761]: src/rfkill.c:rfkill_event() RFKILL event idx 17484 type 2 op 1 soft 0 hard 0

Homeassistant Log Screenshot

By the way: Reboot of Linux server helps (for half a day). ;-)

smartmatic commented 1 year ago

@bdraco Do you have the chance to take a look at that issue as my bluetooth connection is really unreliable since HA Yellow migration and the above listed errors!

bdraco commented 1 year ago

Check the operating system issue queue. This is likely due to general problem with the HAOS 10 version that is being worked out

AseKarlsson commented 1 year ago

Same here on my Yellow. Even restart does not help, you need to powercycle the unit.

AseKarlsson commented 1 year ago

Still the same on 2023.5.2, OS 10.1

smartmatic commented 1 year ago

It would be nice when this issue gets more attention especially as it is a Home Assistant Device.

mboisson commented 1 year ago

I get bluetooth issues using a USB dongle on a Ubuntu 22.04 box with HA docker. I don't think it's related to HA Yellow... More details on what I get here https://github.com/home-assistant/core/issues/93036#issuecomment-1550315939

issue-triage-workflows[bot] commented 1 year ago

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.