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
71.58k stars 29.91k forks source link

Unable to connect to Yale lock via active Bluetooth proxy #79685

Closed flacjacket closed 1 year ago

flacjacket commented 1 year ago

The problem

I am trying to connect to connect to a Yale Bluetooth lock via an active Bluetooth proxy (on ESPHome 2022.9.3). I am able to discover the device, and it is correctly associated with the lock that is pulled in from the August cloud integration (so the discovered device shows the name of the August integration lock). However, I am not able to include the device. When I click "Configure" then "Submit", the configuration errors out saying "Unknown error occurred". I do see some error coming from yalexs-ble in the Home Assistant logs, and I do see some connection attempt being made from the ESPHome device. Using a different computer (my laptop), I am able to start Home Assistant with the native Bluetooth integration, and I am able to configure the Yale Access Bluetooth connection to the lock after connecting it to the August cloud integration, so I believe the problem is somewhere in the new Bluetooth proxy functionality.

The ESPHome device is a TinyPico ESP32 board. The lock has a Yale/August bluetooth module.

What version of Home Assistant Core has the issue?

2022.10.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Yale Access Bluetooth

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

ESPHome configuration:

esp32_ble_tracker:
  scan_parameters:
    interval: 1100ms
    window: 1100ms
    active: true

bluetooth_proxy:
  active: true

Anything in the logs that might be useful for us?

From the Home Assistant logs:

Front (M105TDC): Auth error: key or slot (key index) is incorrect: Front (M105TDC): Characteristic None not found!

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/yalexs_ble/session.py", line 126, in _locked_write
    await self._start_notify(self._notify)
  File "/usr/local/lib/python3.10/site-packages/yalexs_ble/session.py", line 153, in _start_notify
    await self.client.start_notify(self.read_characteristic, callback)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 546, in start_notify
    raise BleakError(f"Characteristic {char_specifier} not found!")
bleak.exc.BleakError: Characteristic None not 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 104, in connect
    response = await self.secure_session.execute(self._disconnected_event, cmd)
  File "/usr/local/lib/python3.10/site-packages/yalexs_ble/session.py", line 190, in execute
    return write_task.result()
  File "/usr/local/lib/python3.10/site-packages/yalexs_ble/session.py", line 91, in _write
    return await self._locked_write(command)
  File "/usr/local/lib/python3.10/site-packages/yalexs_ble/session.py", line 130, in _locked_write
    raise AuthError(f"{self.name}: {err}") from err
yalexs_ble.session.AuthError: Front (M105TDC): Characteristic None not found!

From the redacted ESPHome logs:

[00:23:19][I][esp32_ble_client:058]: Attempting BLE connection to XX
[00:23:22][I][esp32_ble_client:142]: Service UUID: XX
[00:23:22][I][esp32_ble_client:143]:   start_handle: XX  end_handle: XX
[00:23:22][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:22][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:22][I][esp32_ble_client:142]: Service UUID: XX
[00:23:22][I][esp32_ble_client:143]:   start_handle: XX  end_handle: XX
[00:23:22][I][esp32_ble_client:142]: Service UUID: XX
[00:23:22][I][esp32_ble_client:143]:   start_handle: XX  end_handle: XX
[00:23:22][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:22][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:22][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client:143]:   start_handle: XX  end_handle: XX
[00:23:23][I][esp32_ble_client:142]: Service UUID: XX
[00:23:23][I][esp32_ble_client:143]:   start_handle: XX  end_handle: XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client:142]: Service UUID: XX
[00:23:23][I][esp32_ble_client:143]:   start_handle: XX  end_handle: XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client:142]: Service UUID: XX
[00:23:23][I][esp32_ble_client:143]:   start_handle: XX  end_handle: XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client:142]: Service UUID: XX
[00:23:23][I][esp32_ble_client:143]:   start_handle: XX  end_handle: XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client:142]: Service UUID: XX
[00:23:23][I][esp32_ble_client:143]:   start_handle: XX  end_handle: XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX
[00:23:23][I][esp32_ble_client.service:057]:  characteristic XX, handle XX, properties XX

I am happy to more provide information from the ESPHome logs as well, but I'm not sure what information there is sensitive.

Additional information

No response

aeozyalcin commented 1 year ago

There is another bug report on here for using BLE Proxy with August BT integration. I can confirm that I am seeing the same issue.

Jc2k commented 1 year ago

FWIW, the Service UUID's are not private, and the characteristic UUID and handles are not sensitive.

flacjacket commented 1 year ago

@bdraco This seems similar to #79692 / #79735, but I do not think ESPHome is crashing, as it will continue to report uptime values in the log after failing to connect (and the values reporting aren't resetting to 0), and occasionally continue to show Attempting BLE connection to ... messages.

bdraco commented 1 year ago

bleak.exc.BleakError: No backend with an available connection slot that can reach address 78:9C:85:16:EF:9A was found

For those issues, That one indicates that there are no free connection slots. The esphome devices can only hold one BLE connection at a time.

homeassistant commented 1 year ago

Hey there @ottowinter, @jesserockz, mind taking a look at this issue as it has been labeled with an integration (esphome) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)


esphome documentation esphome source (message by IssueLinks)

homeassistant commented 1 year ago

yalexs_ble documentation yalexs_ble source

flacjacket commented 1 year ago

bleak.exc.BleakError: No backend with an available connection slot that can reach address 78:9C:85:16:EF:9A was found

For those issues, That one indicates that there are no free connection slots. The esphome devices can only hold one BLE connection at a time.

Interesting! I just have 1 ESPHome device that I setup as a ble proxy, and there is no other Bluetooth devices that I have connected, so I'd imagine this should be able to connect.

bdraco commented 1 year ago

Check the serial console log on the esp. If its stuck, crashed, or failing to disconnect it won't make the slot available again.

liquidbear99 commented 1 year ago

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

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

sarabveer commented 1 year ago

I logged the ESP32 via serial and it seems it is crashing while trying to connect to the August lock. Logs here: https://github.com/esphome/issues/issues/3687

austwhite commented 1 year ago

I have noticed the same issue. Thought it was just me.... The Yale Access Bluetooth Integration reports:

Failed to connect.  
No backend with an available connection slot that can reach address (mac address) can be found.

This happens with various different ESP32 boards and is consistent and repeatable.

My 5 MiFlora devices work fine with it, and MiFlora will keep working, even when Yale Access fails, so the ESP32 is not fully crashing, but Yale Access is just blocked out of it.
Even if I disable the Mi Flora devices it still happens, and the lock and MiFlora are the only things using Bluetooth connections.

austwhite commented 1 year ago

Just bumping this so it doesn't go stale. Still an issue with ESPHome 2022.10 and latest HA

duckmavis commented 1 year ago

Wish I had seen this before bashing my head against a wall for several hours. I am having the same issue with august g4

bdraco commented 1 year ago

Please try refreshing with the 2022.10.0 release which has this fix: https://github.com/esphome/esphome/pull/3905

flacjacket commented 1 year ago

I have updated my ESPHome to 2022.10.0 and continue to have the exact same problem and symptoms.

bdraco commented 1 year ago

Thanks for confirming, please continue at https://github.com/esphome/issues/issues/3687

austwhite commented 1 year ago

Confirming this issue is still present in ESPHome 2022.10.2 also I only have August lock with the Yale integration, so unsure if other bluetooth locks are affected

dahlbergc commented 1 year ago

I'm still encountering this issue in 2022.10.2

On Wed, Nov 2, 2022, 2:11 AM austwhite @.***> wrote:

Confirming this issue is still present in ESPHome 2022.10.2 also

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/79685#issuecomment-1299910245, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVIIHDWGE3AKLJOI47DWLCDWGIV4NANCNFSM6AAAAAAQ6BW62Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

bdraco commented 1 year ago

This issue is resolved in 2022.11.0 or later and an esp flashed with https://github.com/esphome/esphome/pull/3971

Make sure all if your esps are flashed with the new code. If only one of them is running the old code and has Bluetooth proxy enabled it will still fail.

Watch for the official esphome release later this month.

I’m closing this issue as there aren’t any changes to be made on the Hass side for this that won’t be in todays release.

austwhite commented 1 year ago

@bdraco I have flashed my ESP's with the latet version of ESPHome in Home Assistant, which is labeled as 2022.10.2 and Home Assistant is still on 2022.10.5, 2022.11.x HA is not available yet for me. This issue stilll is present.

I'll check it in the next version, but it may be a bit premature to close this given the current production/official releases still have this bug

bdraco commented 1 year ago

We use github for tracking development issues. This isn't a ticket or support system. Issues get closed when the the code is fixed, not when its released.

austwhite commented 1 year ago

@bdraco Any chance this could be reopened?
Home Assistant 2022.11.0, ESPHome 2022.10.2 and using the Yale Bluetooth integration, which is the one that matches August Bluetooth, still gives doesn't connect. The error is different this time. It just says "Could not connect, Try moving the Bluetooth adapter closer to the August Lock, even though the ESP is less than 50cm away from the August lock during testing.

Logger: yalexs_ble.lock Source: runner.py:119 First occurred: 9:55:35 PM (19 occurrences) Last logged: 10:00:52 PM

FRONT DOOR (AugSW38): Failed to connect to the lock: FRONT DOOR (AugSW38) - 78:9C:85:01:CB:3D -> kitchen-ble-proxy: Failed to connect: No backend with an available connection slot that can reach address 78:9C:85:01:CB:3D was found: The proxy/adapter is out of connection slots; Add additional proxies near this device FRONT DOOR (78:9C:85:01:CB:3D): Failed to connect to the lock: FRONT DOOR (78:9C:85:01:CB:3D) - 78:9C:85:01:CB:3D -> kitchen-ble-proxy: Failed to connect: No backend with an available connection slot that can reach address 78:9C:85:01:CB:3D was found: The proxy/adapter is out of connection slots; Add additional proxies near this device FRONT DOOR (78:9C:85:01:CB:3D): Failed to connect to the lock: FRONT DOOR (78:9C:85:01:CB:3D) - 78:9C:85:01:CB:3D -> kitchen-ble-proxy: Failed to connect: Error ESP_GATT_CONN_FAIL_ESTABLISH while connecting: Connection failed to establish: Interference/range; External Bluetooth adapter w/extension may help; Extension cables reduce USB 3 port interference

austwhite commented 1 year ago

Also had this in the logs

Logger: yalexs_ble.push Source: /usr/local/lib/python3.10/site-packages/yalexs_ble/push.py:604 First occurred: 9:57:46 PM (1 occurrences) Last logged: 9:57:46 PM

FRONT DOOR (78:9C:85:01:CB:3D): Error updating Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/init.py", line 543, in establish_connection await client.connect( File "/usr/src/homeassistant/homeassistant/components/bluetooth/models.py", line 294, in connect self._async_get_backend() or self._async_get_fallback_backend() File "/usr/src/homeassistant/homeassistant/components/bluetooth/models.py", line 370, in _async_get_fallback_backend raise BleakError( bleak.exc.BleakError: No backend with an available connection slot that can reach address 78:9C:85:01:CB:3D 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 573, in _queue_update await self._update_task File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 87, in _async_wrap_operation_lock return await func(self, *args, *kwargs) File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 108, 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 384, 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 616, in establish_connection _raise_if_needed(name, description, exc) File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/init.py", line 487, in _raise_if_needed raise BleakOutOfConnectionSlotsError( bleak_retry_connector.BleakOutOfConnectionSlotsError: FRONT DOOR (78:9C:85:01:CB:3D) - 78:9C:85:01:CB:3D -> kitchen-ble-proxy: Failed to connect: No backend with an available connection slot that can reach address 78:9C:85:01:CB:3D was found: The proxy/adapter is out of connection slots; Add additional proxies near this device

bdraco commented 1 year ago

If there is still a problem please open a new issue.

austwhite commented 1 year ago

@bdraco I will open a new issue, but note it is the same issue that is not resolved.... I can reference this one in the new issue.....

bdraco commented 1 year ago

Its not the same issue. The op's issue was yalexs_ble.session.AuthError: Front (M105TDC): Characteristic None not found!