esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 35 forks source link

Failed to pair with Homekit Controller via bluetooth #4022

Open cburghardt opened 1 year ago

cburghardt commented 1 year ago

The problem

I am trying to pair HA with an Eve Light Switch through the Homekit integration. I have already successfully paired one device directly via the bluetooth adapter so I know that the device is supported. Since then I have disabled the bluetooth adapter and rely purely on bluetooth proxies via ESP32. The communication to the existing Eve switch works without problems through the proxies. When I try to pair a new device I get the following error:

`2023-01-10 17:50:50.122 ERROR (MainThread) [homeassistant.components.homekit_controller.config_flow] Pairing attempt failed with an unhandled exception Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 96, in _async_wrap_bluetooth_operation return await func(self, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 504, in read_gatt_char return await self._client.bluetooth_gatt_read( File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 636, in bluetooth_gatt_read resp = await self._send_bluetooth_message_await_response( File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 440, in _send_bluetooth_message_await_response raise BluetoothGATTAPIError(BluetoothGATTError.from_pb(resp[0])) aioesphomeapi.core.BluetoothGATTAPIError: Bluetooth GATT Error address=CF:7E:62:5C:7D:6F handle=54 error=133 description=Error

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

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 491, in async_step_pair self.finish_pairing = await discovery.async_start_pairing(self.hkid) File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/init.py", line 447, in _async_wrap_bluetooth_connection_error_retry return await func(*args, kwargs) File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/discovery.py", line 151, in async_start_pairing salt, pub_key = await self._async_start_pairing(alias) File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/discovery.py", line 141, in _async_start_pairing return await drive_pairing_state_machine( File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/client.py", line 232, in drive_pairing_state_machine decoded = await _pairing_char_write(client, char, iid, request) File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/client.py", line 186, in _pairing_char_write data = await char_write(client, None, None, handle, iid, next_write) File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/client.py", line 169, in char_write pdu_status, data = await ble_request( File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/client.py", line 73, in ble_request return await _read_pdu(client, decryption_key, handle, tid) File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/client.py", line 129, in _read_pdu next = await client.read_gatt_char(handle) File "/usr/local/lib/python3.10/site-packages/bleak/init.py", line 571, in read_gatt_char return await self._backend.read_gatt_char(char_specifier, kwargs) File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 79, in _async_wrap_bluetooth_connected_operation await task File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 118, in _async_wrap_bluetooth_operation raise BleakError(str(ex)) from ex bleak.exc.BleakError: Bluetooth GATT Error address=CF:7E:62:5C:7D:6F handle=54 error=133 description=Error `

Which version of ESPHome has the issue?

2022.12.3

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

core-2023.1.0

What platform are you using?

ESP32

Board

Espressif ESP32 ESP32-PICO-KIT V4.1SiP Development Board

Component causing the issue

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

I am not completely sure where this issue sits, so I have also raised it with HA: https://github.com/home-assistant/core/issues/85629

appleimperio commented 1 year ago

Hi i was having exactly the same issue with an eve outlet and this is what i change. All the changes are in the esphome device yaml, don't forget to change your board device . Basically I change the framework version and the interval. Hope this work for you.

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    version: 4.4.3
    platform_version: 5.3.0
# Bluetooth Proxy
esp32_ble_tracker:
  scan_parameters:
    interval: 2000ms
    window: 1100ms
    active: true

bluetooth_proxy:
  active: true