core: August Lock Fails to Connect to Bluetooth With ESP32 Bluetooth Proxy

The problem

The August Wi-Fi Smart Lock (Gen 4) fails to connect to Home Assistant via Bluetooth when using an ESP32 Bluetooth Proxy. The lock is able to connect via WiFi with the August integration, and via a USB Bluetooth Adapter with the Yale Access Bluetooth integration.

What version of Home Assistant Core has the issue?

2022.10.0

What was the last working version of Home Assistant Core?

NA

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Yale Access Bluetooth

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

These errors, initially:

2022-10-06 00:36:00.659 ERROR (MainThread) [yalexs_ble.lock] FRONT DOOR (L500321): Failed to connect to the lock: FRONT DOOR (L500321) - 78:9C:85:16:EF:9A: Failed to connect:
2022-10-06 00:36:00.661 ERROR (MainThread) [yalexs_ble.push] FRONT DOOR (L500321): Error updating
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 205, in _wait_for_free_connection_slot
await self.entry_data.wait_for_ble_connections_free()
File "/usr/src/homeassistant/homeassistant/components/esphome/entry_data.py", line 114, in wait_for_ble_connections_free
return await fut
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
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 272, in connect
return await super().connect(**kwargs)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 392, in connect
return await self._backend.connect(**kwargs)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 64, in _async_wrap_bluetooth_operation
return await func(self, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 143, in connect
await self._wait_for_free_connection_slot(CONNECT_FREE_SLOT_TIMEOUT)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 204, in _wait_for_free_connection_slot
async with async_timeout.timeout(timeout):
File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 129, in __aexit__
self._do_exit(exc_type)
File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 212, in _do_exit
raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 552, in _queue_update
await self._update_task
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 86, in _async_wrap_operation_lock
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 107, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 370, in _update
async with lock:
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 61, in __aenter__
await self.connect()
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 90, in connect
raise err
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 80, in connect
self.client = await establish_connection(
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 479, in establish_connection
_raise_if_needed(name, description, exc)
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 410, in _raise_if_needed
raise BleakNotFoundError(msg) from exc
bleak_retry_connector.BleakNotFoundError: FRONT DOOR (L500321) - 78:9C:85:16:EF:9A: Failed to connect:
2022-10-06 00:36:28.501 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: yalexs_ble
2022-10-06 00:36:28.626 WARNING (MainThread) [homeassistant.config_entries] Config entry 'FRONT DOOR' for yalexs_ble integration not ready yet: FRONT DOOR (L500321) - 78:9C:85:16:EF:9A: Failed to connect: ; Try moving the Bluetooth adapter closer to L500321; Retrying in background
2022-10-06 00:36:30.102 ERROR (MainThread) [yalexs_ble.push] FRONT DOOR (L500321): Error updating
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 552, in _queue_update
await self._update_task
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 86, in _async_wrap_operation_lock
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 107, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 370, in _update
async with lock:
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 61, in __aenter__
await self.connect()
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 80, in connect
self.client = await establish_connection(
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 264, in connect
self._async_get_backend() or await self._async_get_fallback_backend()
File "/usr/src/homeassistant/homeassistant/components/bluetooth/models.py", line 303, in _async_get_backend
if backend := self._async_get_backend_for_ble_device(ble_device):
File "/usr/src/homeassistant/homeassistant/components/bluetooth/models.py", line 289, in _async_get_backend_for_ble_device
if not connector.can_connect():
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/__init__.py", line 66, in <lambda>
can_connect=lambda: async_can_connect(source),
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/__init__.py", line 33, in async_can_connect
entry = domain_data.get_by_unique_id(source)
File "/usr/src/homeassistant/homeassistant/components/esphome/domain_data.py", line 50, in get_by_unique_id
return self._entry_by_unique_id[unique_id]
KeyError: 'foyer-ble'
2022-10-06 00:36:43.102 ERROR (MainThread) [yalexs_ble.push] FRONT DOOR (L500321): Error updating
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 552, in _queue_update
await self._update_task
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 86, in _async_wrap_operation_lock
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 107, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 370, in _update
async with lock:
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 61, in __aenter__
await self.connect()
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 80, in connect
self.client = await establish_connection(
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 264, in connect
self._async_get_backend() or await self._async_get_fallback_backend()
File "/usr/src/homeassistant/homeassistant/components/bluetooth/models.py", line 303, in _async_get_backend
if backend := self._async_get_backend_for_ble_device(ble_device):
File "/usr/src/homeassistant/homeassistant/components/bluetooth/models.py", line 289, in _async_get_backend_for_ble_device
if not connector.can_connect():
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/__init__.py", line 66, in <lambda>
can_connect=lambda: async_can_connect(source),
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/__init__.py", line 33, in async_can_connect
entry = domain_data.get_by_unique_id(source)
File "/usr/src/homeassistant/homeassistant/components/esphome/domain_data.py", line 50, in get_by_unique_id
return self._entry_by_unique_id[unique_id]
KeyError: 'foyer-ble'
2022-10-06 00:36:52.845 ERROR (MainThread) [homeassistant] Error doing job: Task was destroyed but it is pending!
2022-10-06 00:37:37.601 WARNING (MainThread) [homeassistant.config_entries] Config entry 'FRONT DOOR' for yalexs_ble integration not ready yet: 'foyer-ble'; Try moving the Bluetooth adapter closer to L500321; Retrying in background
2022-10-06 00:37:43.030 ERROR (MainThread) [yalexs_ble.lock] FRONT DOOR (L500321): Failed to connect to the lock: FRONT DOOR (L500321) - /org/bluez/hci0/dev_78_9C_85_16_EF_9A: Failed to connect: [org.bluez.Error.Failed] Operation already in progress
2022-10-06 00:37:43.287 ERROR (MainThread) [yalexs_ble.lock] FRONT DOOR (L500321): Failed to connect to the lock: FRONT DOOR (L500321) - /org/bluez/hci0/dev_78_9C_85_16_EF_9A: Failed to connect: [org.bluez.Error.Failed] Operation already in progress
2022-10-06 00:37:45.070 ERROR (MainThread) [yalexs_ble.lock] FRONT DOOR (L500321): Failed to connect to the lock: FRONT DOOR (L500321) - /org/bluez/hci0/dev_78_9C_85_16_EF_9A: Failed to connect: [org.bluez.Error.Failed] Operation already in progress
2022-10-06 00:37:45.578 ERROR (MainThread) [yalexs_ble.lock] FRONT DOOR (L500321): Failed to connect to the lock: FRONT DOOR (L500321) - /org/bluez/hci0/dev_78_9C_85_16_EF_9A: Failed to connect: [org.bluez.Error.Failed] Operation already in progress
2022-10-06 00:37:46.848 ERROR (MainThread) [yalexs_ble.lock] FRONT DOOR (L500321): Failed to connect to the lock: FRONT DOOR (L500321) - /org/bluez/hci0/dev_78_9C_85_16_EF_9A: Failed to connect: [org.bluez.Error.Failed] Operation already in progress
2022-10-06 00:37:46.849 ERROR (MainThread) [yalexs_ble.push] FRONT DOOR (L500321): Error updating
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 272, in connect
return await super().connect(**kwargs)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 392, in connect
return await self._backend.connect(**kwargs)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 179, in connect
assert_reply(reply)
File "/usr/local/lib/python3.10/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.Failed] Operation already in progress
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 552, in _queue_update
await self._update_task
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 86, in _async_wrap_operation_lock
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 107, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 370, in _update
async with lock:
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 61, in __aenter__
await self.connect()
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 90, in connect
raise err
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 80, in connect
self.client = await 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: FRONT DOOR (L500321) - /org/bluez/hci0/dev_78_9C_85_16_EF_9A: Failed to connect: [org.bluez.Error.Failed] Operation already in progress
2022-10-06 00:38:55.518 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform yalexs_ble does not generate unique IDs. ID 78:9C:85:16:EF:9A already exists - ignoring binary_sensor.front_door_ble
2022-10-06 00:38:55.519 ERROR (MainThread) [homeassistant.components.lock] Platform yalexs_ble does not generate unique IDs. ID 78:9C:85:16:EF:9A already exists - ignoring lock.front_door_ble
2022-10-06 00:39:07.128 ERROR (MainThread) [homeassistant.components.sensor] Platform yalexs_ble does not generate unique IDs. ID 78:9C:85:16:EF:9A already exists - ignoring sensor.front_door_ble_signal_strength

This error, repeating:

2022-10-06 00:45:32.422 ERROR (MainThread) [yalexs_ble.lock] FRONT DOOR (L500321): Failed to connect to the lock: FRONT DOOR (L500321) - 78:9C:85:16:EF:9A: Failed to connect: No backend with an available connection slot that can reach address 78:9C:85:16:EF:9A was found
2022-10-06 00:45:32.424 ERROR (MainThread) [yalexs_ble.lock] FRONT DOOR (L500321): Failed to connect to the lock: FRONT DOOR (L500321) - 78:9C:85:16:EF:9A: Failed to connect: No backend with an available connection slot that can reach address 78:9C:85:16:EF:9A was found
2022-10-06 00:45:32.424 ERROR (MainThread) [yalexs_ble.lock] FRONT DOOR (L500321): Failed to connect to the lock: FRONT DOOR (L500321) - 78:9C:85:16:EF:9A: Failed to connect: No backend with an available connection slot that can reach address 78:9C:85:16:EF:9A was found
2022-10-06 00:45:32.425 ERROR (MainThread) [yalexs_ble.push] FRONT DOOR (L500321): Error updating
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 264, in connect
self._async_get_backend() or await self._async_get_fallback_backend()
File "/usr/src/homeassistant/homeassistant/components/bluetooth/models.py", line 328, in _async_get_fallback_backend
raise BleakError(
bleak.exc.BleakError: No backend with an available connection slot that can reach address 78:9C:85:16:EF:9A 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/yalexs_ble/push.py", line 552, in _queue_update
await self._update_task
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 86, in _async_wrap_operation_lock
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 107, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 370, in _update
async with lock:
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 61, in __aenter__
await self.connect()
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 90, in connect
raise err
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 80, in connect
self.client = await 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: FRONT DOOR (L500321) - 78:9C:85:16:EF:9A: Failed to connect: No backend with an available connection slot that can reach address 78:9C:85:16:EF:9A was found

Additional information

  • The ESP32 Bluetooth Proxy was created using the Generic ESP32 option on this website
  • The ESP32 Bluetooth Proxy is able to detect the lock, as it is discovered.
  • I’m able to integrate the lock again via Yale Access Bluetooth by re-enabling my Bluetooth adapter and disabling my ESP32 Bluetooth Proxy, but not the other way around (so at least I’m not completely stuck without a locally controlled lock 😁).
  • Trying to configure directly via the Yale Access Bluetooth integration discovered window results in the above errors in the log and the device being stuck in initiliazing indefinitely.
  • Trying to integrate via August Bluetooth option instead does nothing.
  • Trying to integrate via the Yale Access Bluetooth option creates a popup window asking for the offline key, which Home Assistant should already have (and seems to since using the USB Bluetooth dongle works)

Based on these three lines from the log:

2022-10-06 00:38:55.518 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform yalexs_ble does not generate unique IDs. ID 78:9C:85:16:EF:9A already exists - ignoring binary_sensor.front_door_ble
2022-10-06 00:38:55.519 ERROR (MainThread) [homeassistant.components.lock] Platform yalexs_ble does not generate unique IDs. ID 78:9C:85:16:EF:9A already exists - ignoring lock.front_door_ble
2022-10-06 00:39:07.128 ERROR (MainThread) [homeassistant.components.sensor] Platform yalexs_ble does not generate unique IDs. ID 78:9C:85:16:EF:9A already exists - ignoring sensor.front_door_ble_signal_strength

Could this be because I previously configured this lock via the USB Bluetooth adapter, and that information exists somewhere in Home Assistant despite deleting the device and trying to reconfigure using the ESP32 Bluetooth Proxy? Or could it be because it is trying to configure it multiple times and somehow interfering with itself?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 20 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Here is the issue I submitted for ESPhome devs to take a look at:

https://github.com/esphome/issues/issues/3687

Can confirm I have the same issue; you beat me to it! I have an August Lock Gen3, and trying to leverage the new ESPHome BLE Proxy does not work. Only way I am able to get it to work is by bringing the lock near my HA server, so that it connects directly via the BT adapter.

I tried deleting the device, and readding it via the BLE proxy, but that didn’t work at all either.

Just tried again and it works! Updated to Home Assistant 2022.12.0, unplugged the Bluetooth dongle, installed the Generic ESP32 ESPHome Bluetooth Proxy via the website (v 2022.12.0b2) onto an ESP32 devkit v1, added it to HA and restarted HA. I mounted the proxy 3 feet from my lock and it takes 5-10 seconds to lock and unlock over WiFi between HA and the proxy. Thanks @bdraco!

You’ll need Home Assistant 2022.12.0 and esphome 2022.12.0 or later for this to work.

Additional details here: https://github.com/esphome/issues/issues/3761

Hi!

I also have the problem. Is there any fix for it on the way or some kind of workaround?

We can probably give a better error when that happens but it’s not going to fix the esp crashing. That needs to be pursued on the esphome issue queue

It looks like the esp is crashing in the middle of the connection attempt and disconnecting from home assistant. Which is why you get the key error.

Im seeing this as well trying to setup a August Gen4. What ive noticed as well is that there are some issues with the esphome bluetooth proxy node as well. Seems to be doing a reset of the esp32.

78:9c:85:0d:1a:7e is my august lock. This is on a standard ESP32 ESP-32S.

[10:09:00][I][esp32_ble_client:058]: Attempting BLE connection to 78:9c:85:0d:1a:7e
[10:09:04][I][esp32_ble_client:142]: Service UUID: 0x1800
[10:09:04][I][esp32_ble_client:143]:   start_handle: 0x1  end_handle: 0x7
[10:09:04][I][esp32_ble_client.service:057]:  characteristic 0x2A00, handle 0x3, properties 0x2
[10:09:04][I][esp32_ble_client.service:057]:  characteristic 0x2A01, handle 0x5, properties 0x2
[10:09:04][I][esp32_ble_client.service:057]:  characteristic 0x2A04, handle 0x7, properties 0x2
[10:09:04][I][esp32_ble_client:142]: Service UUID: 0x1801
[10:09:04][I][esp32_ble_client:143]:   start_handle: 0x8  end_handle: 0xa
[10:09:04][I][esp32_ble_client.service:057]:  characteristic 0x2A05, handle 0xa, properties 0x20
[10:09:04][I][esp32_ble_client:142]: Service UUID: 0x180A
[10:09:04][I][esp32_ble_client:143]:   start_handle: 0xb  end_handle: 0x17
[10:09:04][I][esp32_ble_client.service:057]:  characteristic 0x2A29, handle 0xd, properties 0x2
[10:09:05][I][esp32_ble_client.service:057]:  characteristic 0x2A26, handle 0x15, properties 0x2
[10:09:05][W][esp32_ble_client:153]: No descriptor found for notify of handle 0x21
[10:09:14][I][esp32_ble_client:058]: Attempting BLE connection to 78:9c:85:0d:1a:7e
[10:09:14][I][esp32_ble_client:058]: Attempting BLE connection to 78:9c:85:0d:1a:7e
[10:09:19][I][esp32_ble_client:058]: Attempting BLE connection to 78:9c:85:0d:1a:7e
[10:09:25][I][esp32_ble_client:142]: Service UUID: 0x1800
[10:09:25][I][esp32_ble_client:143]:   start_handle: 0x1  end_handle: 0x7
[10:09:25][I][esp32_ble_client.service:057]:  characteristic 0x2A00, handle 0x3, properties 0x2
[10:09:25][I][esp32_ble_client.service:057]:  characteristic 0x2A01, handle 0x5, properties 0x2
[10:09:25][I][esp32_ble_client.service:057]:  characteristic 0x2A04, handle 0x7, properties 0x2
[10:09:25][I][esp32_ble_client:142]: Service UUID: 0x1801
[10:09:25][I][esp32_ble_client:143]:   start_handle: 0x8  end_handle: 0xa
INFO bluetooth-proxy-1.local: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO bluetooth-proxy-1.local: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for bluetooth-proxy-1.local
WARNING Disconnected from API
INFO Successfully connected to bluetooth-proxy-1.local
[10:09:37][D][api:102]: Accepted ::FFFF:C0A8:D
[10:09:38][D][api.connection:917]: Home Assistant 2022.10.0 (::FFFF:C0A8:D): Connected successfully
[10:09:38][D][time:042]: Synchronized time: 2022-10-06 10:09:38