dbuezas / eq3btsmart

61 stars 9 forks source link

Cannot connect after updating to version 148 #119

Closed spamsave47 closed 3 hours ago

spamsave47 commented 5 hours ago

I made the mistake of updating some of my devices to newest firmware 148 using the calor BT app. Now Home Assistant cannot connect to them anymore. The not updated ones use firmware 146 and work. I use ESPHome Bluetooth proxies.

If I delete the devices from Home Assistant, I get the notification that a new device is found and I can add it via the integration but it seems like a proper connection is never established.

The only error messages I could gather via debug mode are as follows:

For the one I did reset completely:

2024-11-14 19:21:01.314 DEBUG (MainThread) [custom_components.dbuezas_eq3btsmart.python_eq3bt.eq3bt.bleakconnection] [radiator office] Broken connection [retry 12/14]: radiator office - 00:1A:22:10:B0:1A: Failed to connect after 2 attempt(s): Timeout waiting for connect response while connecting to 00:1A:22:10:B0:1A after 20.0s, disconnect timed out: True,  after 20.0s
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 584, in bluetooth_device_connect
    await connect_future
TimeoutError

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 77, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 297, in connect
    await self._client.bluetooth_device_connect(
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 604, in bluetooth_device_connect
    raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for connect response while connecting to 00:1A:22:10:B0:1A after 20.0s, disconnect timed out: True,  after 20.0s

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/bleak_retry_connector/__init__.py", line 363, in establish_connection
    await client.connect(
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 311, in connect
    connected = await super().connect(**kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 615, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 79, in _async_wrap_bluetooth_operation
    raise asyncio.TimeoutError(str(err)) from err
TimeoutError: Timeout waiting for connect response while connecting to 00:1A:22:10:B0:1A after 20.0s, disconnect timed out: True,  after 20.0s

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

Traceback (most recent call last):
  File "/config/custom_components/dbuezas_eq3btsmart/python_eq3bt/eq3bt/bleakconnection.py", line 176, in _async_make_request_try
    conn = await self.async_get_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dbuezas_eq3btsmart/python_eq3bt/eq3bt/bleakconnection.py", line 94, in async_get_connection
    self._conn = await establish_connection(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_retry_connector/__init__.py", line 387, in establish_connection
    _raise_if_needed(name, device.address, exc)
  File "/usr/local/lib/python3.12/site-packages/bleak_retry_connector/__init__.py", line 327, in _raise_if_needed
    raise BleakNotFoundError(msg) from exc
bleak_retry_connector.BleakNotFoundError: radiator office - 00:1A:22:10:B0:1A: Failed to connect after 2 attempt(s): Timeout waiting for connect response while connecting to 00:1A:22:10:B0:1A after 20.0s, disconnect timed out: True,  after 20.0s

For the one I did not reset:

2024-11-14 19:20:26.211 DEBUG (MainThread) [custom_components.dbuezas_eq3btsmart.python_eq3bt.eq3bt.bleakconnection] [radiator kitchen] Connected
2024-11-14 19:20:26.331 DEBUG (MainThread) [custom_components.dbuezas_eq3btsmart.python_eq3bt.eq3bt.bleakconnection] [radiator kitchen] Broken connection [retry 2/14]: bluetoothtracker1 [A0:B7:65:6A:64:24]: CC-RT-BLE - 00:1A:22:0F:4D:1D is not connected
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 77, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 663, in start_notify
    ] = await self._client.bluetooth_gatt_start_notify(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 896, in bluetooth_gatt_start_notify
    await self._send_bluetooth_message_await_response(
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 486, in _send_bluetooth_message_await_response
    self._raise_for_ble_connection_change(address, resp, msg_types)
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 714, in _raise_for_ble_connection_change
    raise BluetoothConnectionDroppedError(
aioesphomeapi.core.BluetoothConnectionDroppedError: Peripheral 00:1A:22:0F:4D:1D changed connection status while waiting for BluetoothGATTNotifyResponse, BluetoothGATTErrorResponse: Unlikely error (14)

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

Traceback (most recent call last):
  File "/config/custom_components/dbuezas_eq3btsmart/python_eq3bt/eq3bt/bleakconnection.py", line 180, in _async_make_request_try
    await conn.start_notify(PROP_NTFY_UUID, self.on_notification)
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 844, in start_notify
    await self._backend.start_notify(characteristic, wrapped_callback, **kwargs)
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 87, in _async_wrap_bluetooth_operation
    raise BleakError(str(ex)) from ex
bleak.exc.BleakError: Peripheral 00:1A:22:0F:4D:1D changed connection status while waiting for BluetoothGATTNotifyResponse, BluetoothGATTErrorResponse: Unlikely error (14)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/dbuezas_eq3btsmart/python_eq3bt/eq3bt/bleakconnection.py", line 187, in _async_make_request_try
    await conn.stop_notify(PROP_NTFY_UUID)
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 862, in stop_notify
    await self._backend.stop_notify(char_specifier)
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 77, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 713, in stop_notify
    self._raise_if_not_connected()
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 724, in _raise_if_not_connected
    raise BleakError(f"{self._description} is not connected")
bleak.exc.BleakError: bluetoothtracker1 [A0:B7:65:6A:64:24]: CC-RT-BLE - 00:1A:22:0F:4D:1D is not connected
dbuezas commented 5 hours ago

The BTProxy used to work without pairing due to a security flaw in the firmware. It would fail pairing but continue working as if paired, they may have fixed that.

If you have a Bluetooth dongle you could try that. Otherwise I think you could make the esp pair with the eq3 by hard coding the pass key like this: https://esphome.io/components/ble_client.html#ble-client-on-passkey-request

spamsave47 commented 4 hours ago

Ok, I setup a passkey request handling and it works again. Thank you!

EuleMitKeule commented 2 hours ago

Oh wow, I'll have to add that to the docs of the core integration then.

EuleMitKeule commented 1 hour ago

@spamsave47 Could you maybe look at the updated documentation and tell me if this reflects the changes you made to get it working again?

spamsave47 commented 1 hour ago

Yes, but as far as I understand the ESPHome documentation you also always need to add

esp32_ble:
  io_capability: keyboard_only

as otherwise the code cannot be entered, see the first example in ble_client