Having an issue with Bluetooth Proxy with HomeKit Controller sensor

Hi all,

Running ha 2022.10.1 and ESPHome 2022.9.4. This is a new ESP32 (ESP-WROOM-32) device and it’s up to date as well.

I’m having an issue with some vocolinc vs1 contact sensors. These are BT open/close sensors I put on a couple closet doors to automate the light going on and off. Discovery and setup of the devices works as expected.

After setup the state of sensors never changes, a restart of ha does get the correct state of the device.

I’m seeing this in the ESP devices log:
[10:48:41][I][esp32_ble_client.service:057]: characteristic 00000023-0000-1000-8000-0026BB765291, handle 0x4b, properties 0xa
[10:48:41][I][esp32_ble_client:142]: Service UUID: 00000080-0000-1000-8000-0026BB765291
[10:48:41][I][esp32_ble_client:143]: start_handle: 0x4d end_handle: 0xffff
[10:48:41][I][esp32_ble_client.service:057]: characteristic E604E95D-A759-4817-87D3-AA005083A0D1, handle 0x4f, properties 0x2
[10:48:41][I][esp32_ble_client.service:057]: characteristic 000000A5-0000-1000-8000-0026BB765291, handle 0x51, properties 0xa
[10:48:41][I][esp32_ble_client.service:057]: characteristic 00000023-0000-1000-8000-0026BB765291, handle 0x54, properties 0xa
[10:48:41][W][bluetooth_proxy:336]: Cannot notify GATT characteristic, not found.
[10:48:41][W][bluetooth_proxy:257]: Cannot write GATT characteristic, not found.
[10:48:41][W][bluetooth_proxy:232]: Cannot read GATT characteristic, not found.
[10:49:11][W][bluetooth_proxy:257]: Cannot write GATT characteristic, not found.
[10:49:11][W][bluetooth_proxy:222]: Cannot read GATT characteristic, not connected.
[10:49:41][I][esp32_ble_client:058]: Attempting BLE connection to c1:a6:fe:84:08:f7

Device config:

substitutions:
  name: "btp-masterbath"
packages:
  esphome.bluetooth-proxy: github://esphome/bluetooth-proxies/esp32-generic.yaml@main
esphome:
  name: ${name}
  name_add_mac_suffix: false

# For Bluetooth Proxy
esp32_ble_tracker:

bluetooth_proxy: 
  active: true

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

Anyone have any suggestions on a fix for this?

Now seeing this in ha logs…

2022-10-07 11:07:59.450 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140687072054432] VOCOlinc-VS1-17623B [F7:3A:F0:C6:99:AC] (id=36:E0:C8:BB:8F:E9) - F7:3A:F0:C6:99:AC: Failed to connect: No backend with an available connection slot that can reach address F7:3A:F0:C6:99:AC was found
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 464, in establish_connection
await client.connect(
File "/usr/src/homeassistant/homeassistant/components/bluetooth/models.py", line 283, in connect
self._async_get_backend() or await self._async_get_fallback_backend()
File "/usr/src/homeassistant/homeassistant/components/bluetooth/models.py", line 347, in _async_get_fallback_backend
raise BleakError(
bleak.exc.BleakError: No backend with an available connection slot that can reach address F7:3A:F0:C6:99:AC was found
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/connection.py", line 47, in establish_connection
return await retry_establish_connection(
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 542, in establish_connection
_raise_if_needed(name, description, exc)
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 419, in _raise_if_needed
raise BleakConnectionError(msg) from exc
bleak_retry_connector.BleakConnectionError: VOCOlinc-VS1-17623B [F7:3A:F0:C6:99:AC] (id=36:E0:C8:BB:8F:E9) - F7:3A:F0:C6:99:AC: Failed to connect: No backend with an available connection slot that can reach address F7:3A:F0:C6:99:AC was found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 202, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1738, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1775, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 207, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 116, in _async_press_action
await self.async_press()
File "/usr/src/homeassistant/homeassistant/components/homekit_controller/button.py", line 118, in async_press
await self.async_put_characteristics({key: val})
File "/usr/src/homeassistant/homeassistant/components/homekit_controller/entity.py", line 91, in async_put_characteristics
return await self._accessory.put_characteristics(payload)
File "/usr/src/homeassistant/homeassistant/components/homekit_controller/connection.py", line 616, in put_characteristics
results = await self.pairing.put_characteristics(characteristics)
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 110, in _async_wrap
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/client.py", line 76, in _async_wrap
return await func(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 758, in put_characteristics
await self._populate_accessories_and_characteristics()
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 553, in _populate_accessories_and_characteristics
await self._ensure_connected()
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 296, in _ensure_connected
self.client = await establish_connection(
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/connection.py", line 57, in establish_connection
raise AccessoryDisconnectedError(ex) from ex
aiohomekit.exceptions.AccessoryDisconnectedError: VOCOlinc-VS1-17623B [F7:3A:F0:C6:99:AC] (id=36:E0:C8:BB:8F:E9) - F7:3A:F0:C6:99:AC: Failed to connect: No backend with an available connection slot that can reach address F7:3A:F0:C6:99:AC was found

I’m having the same issue with a HA lock. My proxy logs look similar, but homeassistant is showing a timeout when looking for a GATT read request?

HA logs:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/aioesphomeapi/connection.py", line 437, in send_message_await_response_complex
    await fut
asyncio.exceptions.CancelledError
....
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/homeassistant/components/esphome/bluetooth/client.py", line 64, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/esphome/bluetooth/client.py", line 317, in read_gatt_char
    return await self._client.bluetooth_gatt_read(
  File "/usr/lib/python3.10/site-packages/aioesphomeapi/client.py", line 538, in bluetooth_gatt_read
    resp = await self._connection.send_message_await_response_complex(
  File "/usr/lib/python3.10/site-packages/aioesphomeapi/connection.py", line 439, in send_message_await_response_complex
    raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for response for <class 'api_pb2.BluetoothGATTReadRequest'>

Proxy logs:

[10:33:49][I][esp32_ble_client:058]: Attempting BLE connection to e4:df:0e:fd:3e:a5
[10:33:58][I][esp32_ble_client:142]: Service UUID: 0x1800
[10:33:58][I][esp32_ble_client:143]:   start_handle: 0x1  end_handle: 0x9
[10:33:58][I][esp32_ble_client.service:057]:  characteristic 0x2A00, handle 0x3, properties 0xa
[10:33:58][I][esp32_ble_client.service:057]:  characteristic 0x2A01, handle 0x5, properties 0x2
[10:33:58][I][esp32_ble_client.service:057]:  characteristic 0x2A04, handle 0x7, properties 0x2
[10:33:58][I][esp32_ble_client.service:057]:  characteristic 0x2AA6, handle 0x9, properties 0x2
.........
[10:34:40][W][esp32_ble_client:153]: No descriptor found for notify of handle 0x5b
[10:34:40][W][bluetooth_proxy:336]: Cannot notify GATT characteristic, not found.
[10:34:40][W][bluetooth_proxy:257]: Cannot write GATT characteristic, not found.
[10:34:40][W][bluetooth_proxy:232]: Cannot read GATT characteristic, not found.

I found some bug reports on github. There was one that directly addressed the error you are getting:

Sounds like each esphome is only good for 1 BLE device at a time?

That explains it, thanks!

Thought I would update group on what I found - I had another bluetooth device that was interfering with the communication when I tried to pair my lock (Level) to Homekit integration in HA. I moved the bluetooth speaker (JBL) away from the device and bluetooth proxy and error went away and is now working fine. The speaker even interfered with the regular communication after being paired. This speaker was about 2-3 feet from the device and about the same from the ESP32 bluetooth proxy device. If I moved the speaker about 8 feet away or more, my device and pairing worked fine.