Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After update from 2023.2.5 to 2023.3.6 esphome bluetooth stack takes 25 to retry connecting after error (error not seen) #90265

Closed
KitHubek opened this issue Mar 25, 2023 · 101 comments · Fixed by #92741

Comments

@KitHubek
Copy link

The problem

As a topic. As we know, since 2023.3 update we had problem with error index array out of range. We have update HA 2023.3.6 and this problem was fixed, but, new problem happends.

Lock FW is newest

Iam using BT-proxy - just say this to know that BT connections and signal strength should be very fine. Hardware with High performance bt dongle, 3m USB cable, away from USB 3.0 ports. Till 2023.x HA everything working very well.

Now problem is, that lock goes offline. Not unavialable, just offline - this says log. Cant connect to it, via HA. BT proxy log, says this, HA logs too. Connection takes over 50 seconds.
I must say, that if i using Switchbot app - everything working ok, lock/unlock takes less than 1 sec.

And i have other devices from Switchbot and everyone working ok, without problem, without delay etc.

What version of Home Assistant Core has the issue?

2023.3.6

What was the last working version of Home Assistant Core?

2023.2.x

What type of installation are you running?

Home Assistant OS

Integration causing the issue

SwitchBot

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

C1:89:44:4B:2B:A5

From bbt proxy log:

[13:14:00][I][bluetooth_proxy:250]: [0] [lockmacaddress] Connecting v3 with cache
[13:14:00][D][esp32_ble_tracker:214]: Pausing scan to make connection...
[13:14:00][I][esp32_ble_client:064]: [0] [lockmacaddress] 0x01 Attempting BLE connection
......
[13:14:01][W][esp32_ble_client:134]: [0] [] Connection failed, status=133
.....
.....
[13:14:51][D][esp-idf:000]: W (60434078) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e

as You see, from unlock command to completed and lock unlock - 51sec



from HA logs:

Logger: homeassistant.core
Source: components/switchbot/lock.py:54
First occurred: 12:43:35 (1 occurrences)
Last logged: 12:43:35

Error executing service: <ServiceCall lock.unlock (c:01GWC96ENHARJM7KZGYPZCJM69): entity_id=['lock.zamek_switchbot']>
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 550, in bluetooth_device_connect
    await event.wait()
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 214, in wait
    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/aioesphomeapi/client.py", line 549, in bluetooth_device_connect
    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/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 100, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 314, in connect
    await self._client.bluetooth_device_connect(
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 575, in bluetooth_device_connect
    raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for connect response while connecting to lockmacaddress after 20.0s, disconnect timed out: True,  after 5.0s

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 342, in establish_connection
    await client.connect(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/wrappers.py", line 249, in connect
    connected = await super().connect(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 471, in connect
    return await self._backend.connect(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 102, in _async_wrap_bluetooth_operation
    raise asyncio.TimeoutError(str(err)) from err
asyncio.exceptions.TimeoutError: Timeout waiting for connect response while connecting to lockmacaddress after 20.0s, disconnect timed out: True,  after 5.0s

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1826, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 686, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 961, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 726, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/lock/__init__.py", line 106, in _async_unlock
    await entity.async_unlock(**remove_entity_service_fields(service_call))
  File "/usr/src/homeassistant/homeassistant/components/switchbot/lock.py", line 54, in async_unlock
    self._last_run_success = await self._device.unlock()
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 168, in unlock
    return await self._lock_unlock(
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 189, in _lock_unlock
    await self._enable_notifications()
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 255, in _enable_notifications
    result = await self._send_command(COMMAND_ENABLE_NOTIFICATIONS)
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 299, in _send_command
    result = await self._ensure_encryption_initialized()
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 314, in _ensure_encryption_initialized
    result = await self._send_command(
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 297, in _send_command
    return await super()._send_command(key[:2] + "000000" + key[2:], retry)
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 180, in _send_command
    return await self._send_command_locked(key, command)
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 397, in _send_command_locked
    await self._ensure_connected()
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 264, in _ensure_connected
    client: BleakClientWithServiceCache = await establish_connection(
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 359, in establish_connection
    _raise_if_needed(name, device.address, exc)
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 308, in _raise_if_needed
    raise BleakNotFoundError(msg) from exc
bleak_retry_connector.BleakNotFoundError:  (lockmacaddress) - lockmacaddress: Failed to connect: Timeout waiting for connect response while connecting to lockmacaddress after 20.0s, disconnect timed out: True,  after 5.0s



and



Logger: switchbot.devices.device
Source: /usr/local/lib/python3.10/site-packages/switchbot/devices/device.py:182
First occurred: 12:43:35 (1 occurrences)
Last logged: 12:43:35

(lockmacaddress): device not found, no longer in range, or poor RSSI: -73
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 550, in bluetooth_device_connect
    await event.wait()
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 214, in wait
    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/aioesphomeapi/client.py", line 549, in bluetooth_device_connect
    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/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 100, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 314, in connect
    await self._client.bluetooth_device_connect(
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 575, in bluetooth_device_connect
    raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for connect response while connecting to lockmacaddress after 20.0s, disconnect timed out: True,  after 5.0s

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 342, in establish_connection
    await client.connect(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/wrappers.py", line 249, in connect
    connected = await super().connect(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 471, in connect
    return await self._backend.connect(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 102, in _async_wrap_bluetooth_operation
    raise asyncio.TimeoutError(str(err)) from err
asyncio.exceptions.TimeoutError: Timeout waiting for connect response while connecting to lockmacaddress after 20.0s, disconnect timed out: True,  after 5.0s

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 180, in _send_command
    return await self._send_command_locked(key, command)
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 397, in _send_command_locked
    await self._ensure_connected()
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 264, in _ensure_connected
    client: BleakClientWithServiceCache = await establish_connection(
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 359, in establish_connection
    _raise_if_needed(name, device.address, exc)
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 308, in _raise_if_needed
    raise BleakNotFoundError(msg) from exc
bleak_retry_connector.BleakNotFoundError:  (lockmacaddress) - lockmacaddress: Failed to connect: Timeout waiting for connect response while connecting to lockmacaddress after 20.0s, disconnect timed out: True,  after 5.0s

Additional information

No response

@home-assistant
Copy link

Hey there @bdraco, @Danielhiversen, @RenierM26, @murtas, @Eloston, @dsypniewski, mind taking a look at this issue as it has been labeled with an integration (switchbot) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of switchbot can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign switchbot Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


switchbot documentation
switchbot source
(message by IssueLinks)

@KitHubek KitHubek changed the title After update from 2023.2.x to 2023.3.6 switchbot LOCK goes offline. Cant unlock, but lock working After update from 2023.2.x to 2023.3.6 switchbot LOCK goes offline. Lock/unlock takes over 50s and more Mar 25, 2023
@KitHubek
Copy link
Author

i downgrade HA to 2023.2.5 and problem non exsist. Lock and all other devices from SwitchBot workind excellent

@bdraco
Copy link
Member

bdraco commented Mar 25, 2023

I would try to solve your other issue first as it seems your instance is being overloaded by something which will make this very difficult to track down:

#90281

@KitHubek
Copy link
Author

@bdraco please look at this comment: #89061 (comment)

the same problem as mine

@bdraco
Copy link
Member

bdraco commented Mar 26, 2023

@bdraco please look at this comment: #89061 (comment)

the same problem as mine

There's no logs in that comment to indicate that the problem is the same so I think it's a bit premature to make that conclusion

Bluetooth devices have so many failure modes that it's best not to drawn conclusions too quickly especially without logs as we can end up spending months trying to solve the wrong problem

@KitHubek
Copy link
Author

ok, so what i should to do?
This is crazy, because when i downgrade to 2023.2.5 ha version problem was fixed and working till now without any errors.

@bdraco
Copy link
Member

bdraco commented Mar 26, 2023

ok, so what i should to do?

This is crazy, because when i downgrade to 2023.2.5 ha version problem was fixed and working till now without any errors.

If you mail me the lock and the Bluetooth proxy I'm sure I can figure out what's going wrong.

@KitHubek
Copy link
Author

thanks, but its impossible, because this devixes are on production and if i send You devices i and all users cant enter home.

@bdraco
Copy link
Member

bdraco commented Mar 26, 2023

Here are a few options

  • install a dev version and see if it's fixed

  • wait for 2023.4 and hope it's an underlying issue with the Bluetooth stack that's been fixed

  • wait for the 2023.4 beta on Wednesday and see if it's any better

  • wait for someone who uses the lock in production and has the same issue to hit the same issue, and figure out a solution

  • hope one of the other SwitchBot codeowners who actually uses the lock in production is interested in helping

@bdraco
Copy link
Member

bdraco commented Mar 26, 2023

You could also try posting the logs with debug for for switchbot enabled in case there is something more obvious going on there

@bdraco
Copy link
Member

bdraco commented Mar 26, 2023

I added some more debug logging as well in #90317 which will be in 2023.3.7

Note that this is not a fix. Its only to make it easier to track down the issue

@KitHubek
Copy link
Author

ok, when avialable 2023.3.7 will update and send logs here. For now stays on 2023.2.5 because its lastes ver. working ok

@KitHubek
Copy link
Author

KitHubek commented Apr 6, 2023

today updated to 2023.4 HA core and problem still exsist.
Lock seems to goes to something as sleep mode after some time. And then when i try to unlock via mobile app i must wait about 1 minutes or more to lock do action unlock. After this, lock workin ok, but if i not unlocking it some time, again must wait much time to response from lock.

Iam using bt proxy, and this problem NO exsist in version 2023.2.6 and lower, From version 2023.3 and higher this problem is all time

I turned on debug mode on SwitchBot integration, and here is log:

Logger: homeassistant.core
Source: components/switchbot/lock.py:54
First occurred: 12:41:24 (1 occurrences)
Last logged: 12:41:24

Error executing service: <ServiceCall lock.unlock (c:01GXB2D587KQ78QC6XK1EX8BH7): entity_id=['lock.switchbot']>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 555, in bluetooth_device_connect
await event.wait()
File "/usr/local/lib/python3.10/asyncio/locks.py", line 214, in wait
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/aioesphomeapi/client.py", line 554, in bluetooth_device_connect
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/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 102, in _async_wrap_bluetooth_operation
return await func(self, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 317, in connect
await self._client.bluetooth_device_connect(
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 580, in bluetooth_device_connect
raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for connect response while connecting to LOCKMACADDRESS after 20.0s, disconnect timed out: True, after 5.0s

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

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/init.py", line 344, in establish_connection
await client.connect(
File "/usr/src/homeassistant/homeassistant/components/bluetooth/wrappers.py", line 269, in connect
connected = await super().connect(**kwargs)
File "/usr/local/lib/python3.10/site-packages/bleak/init.py", line 531, in connect
return await self._backend.connect(**kwargs)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 104, in _async_wrap_bluetooth_operation
raise asyncio.TimeoutError(str(err)) from err
asyncio.exceptions.TimeoutError: Timeout waiting for connect response while connecting to LOCKMACADDRESS after 20.0s, disconnect timed out: True, after 5.0s

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

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1838, in catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1857, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 216, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 798, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 977, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 838, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/lock/init.py", line 106, in _async_unlock
await entity.async_unlock(**remove_entity_service_fields(service_call))
File "/usr/src/homeassistant/homeassistant/components/switchbot/lock.py", line 54, in async_unlock
self._last_run_success = await self._device.unlock()
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 168, in unlock
return await self._lock_unlock(
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 189, in _lock_unlock
await self._enable_notifications()
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 255, in _enable_notifications
result = await self._send_command(COMMAND_ENABLE_NOTIFICATIONS)
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 299, in _send_command
result = await self._ensure_encryption_initialized()
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 314, in _ensure_encryption_initialized
result = await self._send_command(
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 297, in _send_command
return await super()._send_command(key[:2] + "000000" + key[2:], retry)
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 180, in _send_command
return await self._send_command_locked(key, command)
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 414, in _send_command_locked
await self._ensure_connected()
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 274, in _ensure_connected
client: BleakClientWithServiceCache = await establish_connection(
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/init.py", line 361, in establish_connection
_raise_if_needed(name, device.address, exc)
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/init.py", line 310, in _raise_if_needed
raise BleakNotFoundError(msg) from exc
bleak_retry_connector.BleakNotFoundError: LOCKMACADDRESS (LOCKMACADDRESS) - LOCKMACADDRESS: Failed to connect: Timeout waiting for connect response while connecting to LOCKMACADDRESS after 20.0s, disconnect timed out: True, after 5.0s

and

Logger: switchbot.devices.device
Source: /usr/local/lib/python3.10/site-packages/switchbot/devices/device.py:182
First occurred: 12:41:24 (1 occurrences)
Last logged: 12:41:24

(LOCKMACADDRESS): device not found, no longer in range, or poor RSSI: -68
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 555, in bluetooth_device_connect
await event.wait()
File "/usr/local/lib/python3.10/asyncio/locks.py", line 214, in wait
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/aioesphomeapi/client.py", line 554, in bluetooth_device_connect
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/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 102, in _async_wrap_bluetooth_operation
return await func(self, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 317, in connect
await self._client.bluetooth_device_connect(
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 580, in bluetooth_device_connect
raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for connect response while connecting to LOCKMACADDRESS after 20.0s, disconnect timed out: True, after 5.0s

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

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/init.py", line 344, in establish_connection
await client.connect(
File "/usr/src/homeassistant/homeassistant/components/bluetooth/wrappers.py", line 269, in connect
connected = await super().connect(**kwargs)
File "/usr/local/lib/python3.10/site-packages/bleak/init.py", line 531, in connect
return await self._backend.connect(**kwargs)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 104, in _async_wrap_bluetooth_operation
raise asyncio.TimeoutError(str(err)) from err
asyncio.exceptions.TimeoutError: Timeout waiting for connect response while connecting to LOCKMACADDRESS after 20.0s, disconnect timed out: True, after 5.0s

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

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 180, in _send_command
return await self._send_command_locked(key, command)
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 414, in _send_command_locked
await self._ensure_connected()
File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 274, in _ensure_connected
client: BleakClientWithServiceCache = await establish_connection(
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/init.py", line 361, in establish_connection
_raise_if_needed(name, device.address, exc)
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/init.py", line 310, in _raise_if_needed
raise BleakNotFoundError(msg) from exc
bleak_retry_connector.BleakNotFoundError: LOCKMACADDRESS (LOCKMACADDRESS) - LOCKMACADDRESS: Failed to connect: Timeout waiting for connect response while connecting to LOCKMACADDRESS after 20.0s, disconnect timed out: True, after 5.0s

and

Logger: aioesphomeapi.connection
Source: runner.py:179
First occurred: 12:34:19 (1 occurrences)
Last logged: 12:34:19

bt-proxy-esp32 @ 192.168.10.206: Connection error occurred: [Errno 104] Connection reset by peer

@bdraco
Copy link
Member

bdraco commented Apr 6, 2023

bt-proxy-esp32 @ 192.168.10.206: Connection error occurred: [Errno 104] Connection reset by peer

Your esphome proxy is likely crashing.

Make sure you have the latest firmware and try reducing the config https://esphome.io/components/bluetooth_proxy.html

@KitHubek
Copy link
Author

KitHubek commented Apr 6, 2023

i have fw 2023.3.2 (Apr 6 2023, 10:49:32)
and i dont think that this is the main problem, because if i downgrade HA to 2023.2.x version problem NO exsist. And if i update to nevest HA fw - problem as i wrote.

@KitHubek
Copy link
Author

KitHubek commented Apr 6, 2023

INFO Reading configuration /config/esphome/bt-proxy-esp32.yaml...
INFO Starting log output from bt-proxy-esp32.local using esphome API
INFO Successfully connected to bt-proxy-esp32.local
[23:25:31][I][app:102]: ESPHome version 2023.3.2 compiled on Apr 6 2023, 10:49:32
[23:25:31][I][app:104]: Project esphome.bluetooth-proxy version 1.0
[23:25:31][C][wifi:504]: WiFi:
[23:25:31][C][wifi:362]: Local MAC: xx:xx:xx:xx:xx
[23:25:31][C][wifi:363]: SSID: [redacted]
[23:25:31][C][wifi:364]: IP Address: xxxxx
[23:25:31][C][wifi:366]: BSSID: [redacted]
[23:25:31][C][wifi:367]: Hostname: 'bt-proxy-esp32'
[23:25:31][C][wifi:369]: Signal strength: -51 dB ▂▄▆█
[23:25:31][C][wifi:373]: Channel: 6
[23:25:31][C][wifi:374]: Subnet: 255.255.255.0
[23:25:31][C][wifi:375]: Gateway: xxxxx
[23:25:31][C][wifi:376]: DNS1: xxxxx
[23:25:31][C][wifi:377]: DNS2: xxxxx
[23:25:31][C][logger:293]: Logger:
[23:25:31][C][logger:294]: Level: DEBUG
[23:25:31][C][esp32_ble:214]: ESP32 BLE:
[23:25:31][C][esp32_ble_tracker:591]: BLE Tracker:
[23:25:31][C][esp32_ble_tracker:592]: Scan Duration: 300 s
[23:25:31][C][esp32_ble_tracker:593]: Scan Interval: 320.0 ms
[23:25:31][C][esp32_ble_tracker:594]: Scan Window: 30.0 ms
[23:25:31][C][esp32_ble_tracker:595]: Scan Type: ACTIVE
[23:25:31][C][esp32_ble_tracker:596]: Continuous Scanning: True
[23:25:31][C][mdns:108]: mDNS:
[23:25:31][C][mdns:109]: Hostname: bt-proxy-esp32
[23:25:31][C][ota:093]: Over-The-Air Updates:
[23:25:31][C][ota:094]: Address: bt-proxy-esp32.local:3232
[23:25:31][C][api:138]: API Server:
[23:25:31][C][api:139]: Address: bt-proxy-esp32.local:6053
[23:25:31][C][api:143]: Using noise encryption: NO
[23:25:31][C][improv_serial:032]: Improv Serial:

@bdraco bdraco removed their assignment Apr 6, 2023
@KitHubek
Copy link
Author

KitHubek commented Apr 6, 2023

and here is my config:

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

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

@bdraco
Copy link
Member

bdraco commented Apr 6, 2023

Try doing a serial flash to make sure nvs is cleared (use a cable instead of ota)

@jpconfessor
Copy link

jpconfessor commented Apr 6, 2023

I've experienced the same problem today.. but now, after trying to collect diagnostics from both, HA and esphome bt proxy, the lock works every single time... I will let it sit for like, 1h, and try again.
Sometimes it takes waaay longer, like this in this one.. 24s:

[18:54:06][W][esp32_ble_client:134]: [0] [] Connection failed, status=133
[18:54:06][D][esp32_ble_tracker:246]: Starting scan...
[18:54:30][I][bluetooth_proxy:250]: [0] [F9:0B:22:xxxxxxxx] Connecting v3 with cache
[18:54:30][D][esp32_ble_tracker:214]: Pausing scan to make connection...
[18:54:30][I][esp32_ble_client:064]: [0] [F9:0B:22:xxxxxxxx] 0x01 Attempting BLE connection
[18:54:30][I][esp32_ble_client:144]: [0] [F9:0B:22:xxxxxxxx] Connected
[18:54:30][D][esp32_ble_tracker:246]: Starting scan...

This happened after upgrading HA from 2023.3.6 to 2023.4.0
ESPHome version 2023.3.2


udpate:
Even after a while, the lock is taking a long time to respond, between 20-40s
Rolling back to 2023.3.6 fixed the problem like others mentioned.

Logs from after the downgrade - it only takes 1s:
unlocking

[19:15:02][I][bluetooth_proxy:254]: [0] [F9:0B:22:xxxxxxxx] Connecting v3 without cache
[19:15:02][D][esp32_ble_tracker:214]: Pausing scan to make connection...
[19:15:02][I][esp32_ble_client:064]: [0] [F9:0B:22:xxxxxxxx] 0x01 Attempting BLE connection
[19:15:02][D][esp-idf:000]: W (886091) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e
[19:15:03][D][esp-idf:000]: W (886301) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e
[19:15:03][D][esp-idf:000]: W (886406) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e
[19:15:03][I][esp32_ble_client:196]: [0] [F9:0B:22:xxxxxxxx] Connected

locking:

[19:16:49][I][bluetooth_proxy:250]: [0] [F9:0B:22:xxxxxxxx] Connecting v3 with cache
[19:16:49][D][esp32_ble_tracker:214]: Pausing scan to make connection...
[19:16:49][I][esp32_ble_client:064]: [0] [F9:0B:22:xxxxxxxx] 0x01 Attempting BLE connection
[19:16:49][I][esp32_ble_client:144]: [0] [F9:0B:22:xxxxxxxx] Connected

@KitHubek
Copy link
Author

KitHubek commented Apr 7, 2023

ok, i do flash via PC and USB cable. Now has config near from here, as You posted: https://esphome.io/components/bluetooth_proxy.html#complete-sample-recommended-configuration

substitutions:
  name: bt-proxy
  friendly_name: BT-Proxy
  board: esp32dev
packages:
  esphome.bluetooth-proxy: github://esphome/bluetooth-proxies/esp32-generic.yaml@main
esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}
esp32:
  board: ${board}
  framework:
    type: esp-idf
api:
  encryption:
    key: somesecretkey
esp32_ble_tracker:
  scan_parameters:
    interval: 1100ms
    window: 1100ms
    active: true

bluetooth_proxy:
  active: true

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

and start log fro ESP HOME:

INFO Reading configuration /config/esphome/bt-proxy.yaml...
INFO Starting log output from bt-proxy.local using esphome API
INFO Successfully connected to bt-proxy.local
[02:35:40][I][app:102]: ESPHome version 2023.3.2 compiled on Apr  7 2023, 02:28:05
[02:35:40][I][app:104]: Project esphome.bluetooth-proxy version 1.0
[02:35:40][C][wifi:504]: WiFi:
[02:35:40][C][wifi:362]:   Local MAC: macaddr
[02:35:40][C][wifi:363]:   SSID: [redacted]
[02:35:40][C][wifi:364]:   IP Address: ipaddr
[02:35:40][C][wifi:366]:   BSSID: [redacted]
[02:35:40][C][wifi:367]:   Hostname: 'bt-proxy'
[02:35:40][C][wifi:369]:   Signal strength: -58 dB ▂▄▆█
[02:35:40][C][wifi:373]:   Channel: 1
[02:35:40][C][wifi:374]:   Subnet: cut
[02:35:40][C][wifi:375]:   Gateway: cut
[02:35:40][C][wifi:376]:   DNS1: cut
[02:35:40][C][wifi:377]:   DNS2: cut
[02:35:40][C][logger:293]: Logger:
[02:35:40][C][logger:294]:   Level: DEBUG
[02:35:40][C][logger:295]:   Log Baud Rate: 115200
[02:35:40][C][logger:296]:   Hardware UART: UART0
[02:35:40][C][bluetooth_proxy:065]: Bluetooth Proxy:
[02:35:40][C][bluetooth_proxy:066]:   Active: YES
[02:35:40][C][safe_mode.button:022]: Safe Mode Button 'Safe Mode Boot'
[02:35:40][C][safe_mode.button:022]:   Icon: 'mdi:restart-alert'
[02:35:40][C][esp32_ble:214]: ESP32 BLE:
[02:35:40][C][esp32_ble_tracker:591]: BLE Tracker:
[02:35:40][C][esp32_ble_tracker:592]:   Scan Duration: 300 s
[02:35:40][C][esp32_ble_tracker:593]:   Scan Interval: 1100.0 ms
[02:35:40][C][esp32_ble_tracker:594]:   Scan Window: 1100.0 ms
[02:35:40][C][esp32_ble_tracker:595]:   Scan Type: ACTIVE
[02:35:40][C][esp32_ble_tracker:596]:   Continuous Scanning: True
[02:35:41][C][mdns:108]: mDNS:
[02:35:41][C][mdns:109]:   Hostname: bt-proxy
[02:35:41][C][ota:093]: Over-The-Air Updates:
[02:35:41][C][ota:094]:   Address: bt-proxy.local:3232
[02:35:41][W][ota:103]: Last Boot was an unhandled reset, will proceed to safe mode in 7 restarts
[02:35:41][C][api:138]: API Server:
[02:35:41][C][api:139]:   Address: bt-proxy.local:6053
[02:35:41][C][api:141]:   Using noise encryption: YES
[02:35:41][C][improv_serial:032]: Improv Serial:

will check and report if this changed something or no.

@bdraco
Copy link
Member

bdraco commented Apr 7, 2023

Drop the

    interval: 1100ms
    window: 1100ms

and use the defaults

Those values are for ethernet proxies and will dedicate too much time to the bluetooth radio which may make the wifi unreliable.

@jpconfessor
Copy link

jpconfessor commented Apr 7, 2023

can someone check if this was fixed in 23.4.1?
there are some fixes linked to esphome

@KitHubek
Copy link
Author

KitHubek commented Apr 7, 2023

for me in ver 2023.4.1 still not working.

@bdraco I do config as You say, now is:

substitutions:
  name: bt-proxy-8cf3c8
  friendly_name: BT-Proxy
  board: esp32dev
packages:
  esphome.bluetooth-proxy: github://esphome/bluetooth-proxies/esp32-generic.yaml@main
esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}
esp32:
  board: ${board}
  framework:
    type: esp-idf
api:
  encryption:
    key: SY49gbpHZPhbK5xm0CQjVs60cywnRDFq23x9AM0Baeo=
esp32_ble_tracker:
  scan_parameters:
    active: true
bluetooth_proxy:
  active: true
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
INFO Reading configuration /config/esphome/bt-proxy.yaml...
INFO Starting log output from bt-proxy.local using esphome API
INFO Successfully connected to bt-proxy.local
[17:48:06][I][app:102]: ESPHome version 2023.3.2 compiled on Apr  7 2023, 09:16:41
[17:48:06][I][app:104]: Project esphome.bluetooth-proxy version 1.0
[17:48:06][C][wifi:504]: WiFi:
[17:48:06][C][wifi:362]:   Local MAC: macaddr
[17:48:06][C][wifi:363]:   SSID: [redacted]
[17:48:06][C][wifi:364]:   IP Address: ipaddr
[17:48:06][C][wifi:366]:   BSSID: [redacted]
[17:48:06][C][wifi:367]:   Hostname: 'bt-proxy'
[17:48:06][C][wifi:369]:   Signal strength: -63 dB ▂▄▆█
[17:48:06][C][wifi:373]:   Channel: 11
[17:48:06][C][wifi:374]:   Subnet: cut
[17:48:06][C][wifi:375]:   Gateway: cut
[17:48:06][C][wifi:376]:   DNS1: cut
[17:48:06][C][wifi:377]:   DNS2: cut
[17:48:06][C][logger:293]: Logger:
[17:48:06][C][logger:294]:   Level: DEBUG
[17:48:06][C][logger:295]:   Log Baud Rate: 115200
[17:48:06][C][logger:296]:   Hardware UART: UART0
[17:48:06][C][bluetooth_proxy:065]: Bluetooth Proxy:
[17:48:06][C][bluetooth_proxy:066]:   Active: YES
[17:48:06][C][safe_mode.button:022]: Safe Mode Button 'Safe Mode Boot'
[17:48:06][C][safe_mode.button:022]:   Icon: 'mdi:restart-alert'
[17:48:06][C][esp32_ble:214]: ESP32 BLE:
[17:48:06][C][esp32_ble_tracker:591]: BLE Tracker:
[17:48:06][C][esp32_ble_tracker:592]:   Scan Duration: 300 s
[17:48:06][C][esp32_ble_tracker:593]:   Scan Interval: 320.0 ms
[17:48:06][C][esp32_ble_tracker:594]:   Scan Window: 30.0 ms
[17:48:06][C][esp32_ble_tracker:595]:   Scan Type: ACTIVE
[17:48:06][C][esp32_ble_tracker:596]:   Continuous Scanning: True
[17:48:06][C][mdns:108]: mDNS:
[17:48:06][C][mdns:109]:   Hostname: bt-proxy
[17:48:06][C][ota:093]: Over-The-Air Updates:
[17:48:06][C][ota:094]:   Address: bt-proxy.local:3232
[17:48:06][C][api:138]: API Server:
[17:48:06][C][api:139]:   Address: bt-proxy.local:6053
[17:48:06][C][api:141]:   Using noise encryption: YES
[17:48:06][C][improv_serial:032]: Improv Serial:

tested with thic changes from mornig till now, and, i must say, that is worse than it was before. Before changing the BT proxy configuration, the lock performed the command after a long time, about a minute, and now the lock does not execute the opening command at all. I am sending logs from today.

Logger: homeassistant.core
Source: components/switchbot/lock.py:54
First occurred: 16:14:29 (1 occurrences)
Last logged: 16:14:29

Error executing service: <ServiceCall lock.unlock (c:01GXE103CBG0N8BM1VS7JWWD48): entity_id=['lock.zamek']>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 555, in bluetooth_device_connect
await event.wait()
File "/usr/local/lib/python3.10/asyncio/locks.py", line 214, in wait
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/aioesphomeapi/client.py", line 554, in bluetooth_device_connect
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/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 102, in _async_wrap_bluetooth_operation
return await func(self, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 317, in connect
await self._client.bluetooth_device_connect(
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 580, in bluetooth_device_connect
raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for connect response while connecting to macaddr after 20.0s, disconnect timed out: True, after 5.0s

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

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/init.py", line 344, in establish_connection
await client.connect(
File "/usr/src/homeassistant/homeassistant/components/bluetooth/wrappers.py", line 269, in connect
connected = await super().connect(**kwargs)
File "/usr/local/lib/python3.10/site-packages/bleak/init.py", line 531, in connect
return await self._backend.connect(**kwargs)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 104, in _async_wrap_bluetooth_operation
raise asyncio.TimeoutError(str(err)) from err
asyncio.exceptions.TimeoutError: Timeout waiting for connect response while connecting to macaddr after 20.0s, disconnect timed out: True, after 5.0s

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1838, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1857, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 216, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 798, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 977, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 838, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/lock/__init__.py", line 106, in _async_unlock
    await entity.async_unlock(**remove_entity_service_fields(service_call))
  File "/usr/src/homeassistant/homeassistant/components/switchbot/lock.py", line 54, in async_unlock
    self._last_run_success = await self._device.unlock()
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 168, in unlock
    return await self._lock_unlock(
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 189, in _lock_unlock
    await self._enable_notifications()
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 255, in _enable_notifications
    result = await self._send_command(COMMAND_ENABLE_NOTIFICATIONS)
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 299, in _send_command
    result = await self._ensure_encryption_initialized()
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 314, in _ensure_encryption_initialized
    result = await self._send_command(
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/lock.py", line 297, in _send_command
    return await super()._send_command(key[:2] + "000000" + key[2:], retry)
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 180, in _send_command
    return await self._send_command_locked(key, command)
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 414, in _send_command_locked
    await self._ensure_connected()
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 274, in _ensure_connected
    client: BleakClientWithServiceCache = await establish_connection(
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 361, in establish_connection
    _raise_if_needed(name, device.address, exc)
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 310, in _raise_if_needed
    raise BleakNotFoundError(msg) from exc
bleak_retry_connector.BleakNotFoundError:  (macaddr) - macaddr: Failed to connect: Timeout waiting for connect response while connecting to macaddr after 20.0s, disconnect timed out: True,  after 5.0s
Logger: switchbot.devices.device
Source: /usr/local/lib/python3.10/site-packages/switchbot/devices/device.py:182
First occurred: 16:14:29 (1 occurrences)
Last logged: 16:14:29

(macaddr): device not found, no longer in range, or poor RSSI: -69
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 555, in bluetooth_device_connect
    await event.wait()
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 214, in wait
    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/aioesphomeapi/client.py", line 554, in bluetooth_device_connect
    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/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 102, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 317, in connect
    await self._client.bluetooth_device_connect(
  File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 580, in bluetooth_device_connect
    raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for connect response while connecting to macaddr after 20.0s, disconnect timed out: True,  after 5.0s

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 344, in establish_connection
    await client.connect(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/wrappers.py", line 269, in connect
    connected = await super().connect(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 531, in connect
    return await self._backend.connect(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 104, in _async_wrap_bluetooth_operation
    raise asyncio.TimeoutError(str(err)) from err
asyncio.exceptions.TimeoutError: Timeout waiting for connect response while connecting to macaddr after 20.0s, disconnect timed out: True,  after 5.0s

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 180, in _send_command
    return await self._send_command_locked(key, command)
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 414, in _send_command_locked
    await self._ensure_connected()
  File "/usr/local/lib/python3.10/site-packages/switchbot/devices/device.py", line 274, in _ensure_connected
    client: BleakClientWithServiceCache = await establish_connection(
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 361, in establish_connection
    _raise_if_needed(name, device.address, exc)
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 310, in _raise_if_needed
    raise BleakNotFoundError(msg) from exc
bleak_retry_connector.BleakNotFoundError:  (macaddr) - macaddr: Failed to connect: Timeout waiting for connect response while connecting to macaddr after 20.0s, disconnect timed out: True,  after 5.0s

and if i want operate lock via switch bot app, response is very good. less than 1 sec.

And i have more Switch bot devices, for example door open/close sensor, and i see, that this sensor report ble rssi every some seconds, not more that every 60, and lock not report this value. Lock report this value only when operating (lock/unlock). If not locking/unlocking for example 10 hours, this value not change, rssi is the same, not changing, last report when last lock/unlock.

@jpconfessor
Copy link

jpconfessor commented Apr 7, 2023

Thank you for validating this bug in 23.4.1 @KitHubek

unless a lot was changed for esphome ble proxy stuff.. the interval and window parameters should not be part of this problem, since in both, old and new versions they have the same value and the behavior is completely different. So, something else changed in HA.

I will stay in the older version for now... wife didn't aprove having to wait 30s in front of our door last night... :(

@home-assistant
Copy link

home-assistant bot commented May 7, 2023

@home-assistant
Copy link

home-assistant bot commented May 7, 2023

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!

Code owner commands

Code owners of esphome can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign esphome Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


esphome documentation
esphome source
(message by IssueLinks)

@bdraco bdraco changed the title After update from 2023.2.x to 2023.3.6 Bluetooth stack takes 25 to retry connecting after error (error not seen) After update from 2023.2.5 to 2023.3.6 Bluetooth stack takes 25 to retry connecting after error (error not seen) May 7, 2023
@bdraco
Copy link
Member

bdraco commented May 7, 2023

related PRs during that timeframe

esphome/aioesphomeapi#391

@bdraco
Copy link
Member

bdraco commented May 7, 2023

So I suspect what is happening is the connection is initially successful that than we get a follow message that the connection has failed and since esphome/aioesphomeapi#391 now resolves the connect right away we never see the error and we have to wait the full timeout

@bdraco
Copy link
Member

bdraco commented May 7, 2023

# grep -A 2 BluetoothDeviceConnectionResponse home-assistant.log
2023-05-07 13:27:01.625 DEBUG (MainThread) [aioesphomeapi.connection] master_tvcabinet_32 @ 192.168.106.86: Got message of type <class 'api_pb2.BluetoothDeviceConnectionResponse'>: address: 132613642173324
connected: true
mtu: 512

@bdraco
Copy link
Member

bdraco commented May 7, 2023

esphome/aioesphomeapi#391 is definitely the cause of the breakage

@bdraco
Copy link
Member

bdraco commented May 7, 2023

https://github.com/home-assistant/core/pull/new/ble_retry_fix

The fix is in this branch.

Github is having problems at the moment so I can't create a PR to fix it

@bdraco
Copy link
Member

bdraco commented May 7, 2023

@KitHubek I've confident the linked PR will fix the issue, but it would be great to get a test

cd /config
curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d esphome -p 92741
cat /config/custom_components/esphome/manifest.json

Verify that the version displayed above is "aioesphomeapi==13.7.4" and NOT 3.7.3

Restart HA

Test

Delete /config/custom_components/esphome and restart after testing is completed to restore the core version

@bdraco
Copy link
Member

bdraco commented May 7, 2023

Helps to be looking in the right place.

Thanks @KitHubek for all the debugging and logs 👍

@KitHubek
Copy link
Author

KitHubek commented May 7, 2023

@bdraco
Ok, done this commands. Version is aioesphomeapi==13.7.4
restarted and HA not starting, here error:

2023-05-07 21:01:07.680 ERROR (MainThread) [homeassistant.loader] Unable to resolve dependencies for esphome:  we are unable to resolve (sub)dependency assist_pipeline
2023-05-07 21:01:07.693 ERROR (MainThread) [root] Uncaught exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 226, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 214, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 128, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/usr/src/homeassistant/homeassistant/runner.py", line 109, in setup_and_run_hass
    hass = await bootstrap.async_setup_hass(runtime_config)
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 151, in async_setup_hass
    await async_from_config_dict(config_dict, hass) is not None
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 291, in async_from_config_dict
    await _async_set_up_integrations(hass, config)
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 562, in _async_set_up_integrations
    for dep in itg.all_dependencies:
  File "/usr/src/homeassistant/homeassistant/loader.py", line 678, in all_dependencies
    raise RuntimeError("Dependencies not resolved!")
RuntimeError: Dependencies not resolved!

ok iam on 2023.2.5, updating to 2023..5.2

@bdraco
Copy link
Member

bdraco commented May 7, 2023

It looks like it won't work because of the conflict with the sub dep. Thats a shame as I would really have liked to get a good test but I'm 99% sure I've solved it so go ahead and remove the custom version and let's see if 2023.5.3 does the trick

@KitHubek
Copy link
Author

KitHubek commented May 7, 2023

Yes i updated to 2023.5.2 and HA starting ok.
Now i will do test with loock.

I understand correctly that in the bt-proxy log there should no longer be a delay of 25 seconds, but there should be a reconnection right away? Should I pay attention to that?

@bdraco
Copy link
Member

bdraco commented May 7, 2023

Yes i updated to 2023.5.2 and HA starting ok.

I didn't realize you were trying on the old version. It will only work on 2023.5.x

I understand correctly that in the bt-proxy log there should no longer be a delay of 25 seconds, but there should be a reconnection right away? Should I pay attention to that?

Yes thats the goal.

@KitHubek
Copy link
Author

KitHubek commented May 7, 2023

ok iam for 99% sure that problem solved. Even if first time connection failes, reconnect is right away and finally second time lock opened. Its takes about 2 sec and its very ok.

[21:26:35][I][bluetooth_proxy:254]: [0] [C1:89:44:4B:2B:A5] Connecting v3 without cache
[21:26:35][D][esp32_ble_tracker:214]: Pausing scan to make connection...
[21:26:35][I][esp32_ble_client:064]: [0] [C1:89:44:4B:2B:A5] 0x01 Attempting BLE connection
[21:26:35][D][esp-idf:000]: W (33716892) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e
[21:26:35][D][esp-idf:000]: W (33716994) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e
[21:26:35][D][esp-idf:000]: W (33717102) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e
[21:26:35][D][esp-idf:000]: W (33717204) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e
[21:26:35][D][esp-idf:000]: W (33717209) BT_APPL: gattc_conn_cb: if=3 st=0 id=3 rsn=0x3e
[21:26:35][D][esp-idf:000]: W (33717211) BT_APPL: gattc_conn_cb: if=4 st=0 id=4 rsn=0x3e
[21:26:35][D][esp-idf:000]: W (33717212) BT_APPL: gattc_conn_cb: if=5 st=0 id=5 rsn=0x3e
[21:26:35][W][esp32_ble_client:134]: [0] [] Connection failed, status=133
[21:26:35][D][esp32_ble_tracker:246]: Starting scan...
[21:26:36][I][bluetooth_proxy:254]: [0] [C1:89:44:4B:2B:A5] Connecting v3 without cache
[21:26:36][D][esp32_ble_tracker:214]: Pausing scan to make connection...
[21:26:36][I][esp32_ble_client:064]: [0] [C1:89:44:4B:2B:A5] 0x01 Attempting BLE connection
[21:26:36][D][esp-idf:000]: W (33718482) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x3e
[21:26:37][I][esp32_ble_client:196]: [0] [C1:89:44:4B:2B:A5] Connected
[21:26:37][D][esp32_ble_tracker:246]: Starting scan...
[21:26:51][I][esp32_ble_client:081]: [0] [C1:89:44:4B:2B:A5] Disconnecting.
[21:26:51][D][esp-idf:000]: W (33733344) BT_HCI: hci cmd send: disconnect: hdl 0x0, rsn:0x13
[21:26:51][D][esp-idf:000]: W (33733353) BT_APPL: gattc_conn_cb: if=3 st=0 id=3 rsn=0x16
[21:26:51][D][esp-idf:000]: W (33733356) BT_APPL: gattc_conn_cb: if=4 st=0 id=4 rsn=0x16
[21:26:51][D][esp-idf:000]: W (33733359) BT_APPL: gattc_conn_cb: if=5 st=0 id=5 rsn=0x16
[21:26:51][D][esp-idf:000]: W (33733383) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x16

@bdraco
Copy link
Member

bdraco commented May 7, 2023

I also fixed the disconnection race while I reworked that esphome code so it should be a bit more reliable as well

@KitHubek
Copy link
Author

KitHubek commented May 7, 2023

:)
big thanks for Your support and time.

@KitHubek
Copy link
Author

KitHubek commented May 16, 2023

@bdraco

Iam using HA with Yours fix esphome folder in dir custom component and all as i wrote in this thread worked fine.

BUT

When i see new verison 2023.5.3 HA included this fix i delete esphome dir from custom component dir and update HA. This was 14 may. Today is 16 may, i tested many scenario, and i have to say that something is wrong. Something another than before.

Now problem is, that connection not go via bt-proxy and this make another delay. I not made any change in my config, only one change was: delete esphome folder from custom component and update HA to 2023.5.3. When connection is via bt-proxy all is ok and without delay. But i dont know why, not every connection going via bt-proxy. Before update to 2023.5.3 everyome lock connection go via bt-proxy

what to do? Below log (via app: tap unlock and when unlocked tap lock and lock locked)


2023-05-16 17:52:40.318 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Scheduling command 570000000f210381
2023-05-16 17:52:40.319 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Connecting; RSSI: -79
2023-05-16 17:52:40.319 DEBUG (MainThread) [bleak_retry_connector]  (LOCKMACADDR) - LOCKMACADDR: Connection attempt: 1
2023-05-16 17:52:40.742 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Disconnected from device; RSSI: -79
2023-05-16 17:52:46.404 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Disconnected from device; RSSI: -79
2023-05-16 17:52:52.166 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Connected; RSSI: -79
2023-05-16 17:52:52.167 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Starting notify and disconnect timer; RSSI: -79
2023-05-16 17:52:52.167 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Subscribe to notifications; RSSI: -79
2023-05-16 17:52:52.661 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Sending command: 570000000f210381
2023-05-16 17:52:52.760 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Notification received: 010000007cd70c72c1e596bbb70fe0bc0b8709b7
2023-05-16 17:52:52.761 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Scheduling command 57817cd79796c03693e48941
2023-05-16 17:52:52.762 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Already connected before obtaining lock, resetting timer; RSSI: -79
2023-05-16 17:52:52.762 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Sending command: 57817cd79796c03693e48941
2023-05-16 17:52:52.860 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Notification received: 01817cd7
2023-05-16 17:52:52.861 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Scheduling command 57817cd796d9c1298364
2023-05-16 17:52:52.861 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Already connected before obtaining lock, resetting timer; RSSI: -79
2023-05-16 17:52:52.862 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Sending command: 57817cd796d9c1298364
2023-05-16 17:52:53.060 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Notification received: 01817cd72b0254bf93
2023-05-16 17:52:53.062 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Scheduling command 57817cd79b
2023-05-16 17:52:53.063 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Already connected before obtaining lock, resetting timer; RSSI: -79
2023-05-16 17:52:53.063 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Sending command: 57817cd79b
2023-05-16 17:52:53.111 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 17:52:53.160 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Notification received: 01817cd7fbd6c42893e4
2023-05-16 17:52:53.162 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 17:52:54.419 DEBUG (MainThread) [switchbot.adv_parsers.lock] mfr_data: c189444b2ba5ebb30820
2023-05-16 17:52:54.419 DEBUG (MainThread) [switchbot.adv_parsers.lock] data: 6f8062
2023-05-16 17:52:58.261 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 17:52:59.012 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Scheduling command 57817cd796d9c12983e4
2023-05-16 17:52:59.012 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Already connected before obtaining lock, resetting timer; RSSI: -79
2023-05-16 17:52:59.012 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Sending command: 57817cd796d9c12983e4
2023-05-16 17:52:59.160 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Notification received: 01817cd7390a54bf93
2023-05-16 17:52:59.162 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Scheduling command 57817cd79b
2023-05-16 17:52:59.162 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Already connected before obtaining lock, resetting timer; RSSI: -79
2023-05-16 17:52:59.162 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Sending command: 57817cd79b
2023-05-16 17:52:59.163 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 17:52:59.260 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Notification received: 01817cd7fbd6c42893e4
2023-05-16 17:52:59.261 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 17:53:02.103 DEBUG (MainThread) [switchbot.adv_parsers.lock] mfr_data: c189444b2ba5eda30820
2023-05-16 17:53:02.103 DEBUG (MainThread) [switchbot.adv_parsers.lock] data: 6f8062
2023-05-16 17:53:03.961 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 17:53:07.219 DEBUG (MainThread) [switchbot.adv_parsers.lock] mfr_data: c189444b2ba5ee830820
2023-05-16 17:53:07.219 DEBUG (MainThread) [switchbot.adv_parsers.lock] data: 6f8062
2023-05-16 17:53:12.462 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Executing timed disconnect after timeout of 8.5
2023-05-16 17:53:12.462 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Executing disconnect
2023-05-16 17:53:12.462 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Executing disconnect with lock
2023-05-16 17:53:12.462 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Disconnecting
2023-05-16 17:53:14.912 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Disconnected from device; RSSI: -79
2023-05-16 17:53:14.913 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Disconnect completed successfully

at bt proxy nothing:

[17:43:20][D][esp32_ble_tracker:246]: Starting scan...
[17:48:20][D][esp32_ble_tracker:246]: Starting scan...
[17:53:20][D][esp32_ble_tracker:246]: Starting scan...
[17:58:20][D][esp32_ble_tracker:246]: Starting scan...
[18:03:20][D][esp32_ble_tracker:246]: Starting scan...

--EDIT--

HERE below log when connection goes via bt=proxy and all working ok

2023-05-16 18:07:46.336 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Scheduling command 570000000f210381
2023-05-16 18:07:46.336 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Connecting; RSSI: -79
2023-05-16 18:07:46.336 DEBUG (MainThread) [bleak_retry_connector]  (LOCKMACADDR) - LOCKMACADDR: Connection attempt: 1
2023-05-16 18:07:46.684 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Connected; RSSI: -79
2023-05-16 18:07:46.684 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Starting notify and disconnect timer; RSSI: -79
2023-05-16 18:07:46.685 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Subscribe to notifications; RSSI: -79
2023-05-16 18:07:46.726 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Sending command: 570000000f210381
2023-05-16 18:07:46.850 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Notification received: 010000007dc0bc8cdf3f6be57f426f0a88c23050
2023-05-16 18:07:46.851 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Scheduling command 57817dc0f7349d19fac6837e
2023-05-16 18:07:46.851 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Already connected before obtaining lock, resetting timer; RSSI: -79
2023-05-16 18:07:46.851 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Sending command: 57817dc0f7349d19fac6837e
2023-05-16 18:07:46.992 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Received unsolicited notification: bytearray(b'\x0f\x81}\xc0{<\x12\x93m\xc6\x02\x7f?\xb0E=\xc3\xb0')
2023-05-16 18:07:46.993 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Notification received: 01817dc0
2023-05-16 18:07:46.994 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Scheduling command 57817dc0f67b9c06ea46
2023-05-16 18:07:46.994 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Already connected before obtaining lock, resetting timer; RSSI: -79
2023-05-16 18:07:46.994 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Sending command: 57817dc0f67b9c06ea46
2023-05-16 18:07:47.163 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Notification received: 01817dc04ba00990fa
2023-05-16 18:07:47.166 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Scheduling command 57817dc0fb
2023-05-16 18:07:47.166 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Already connected before obtaining lock, resetting timer; RSSI: -79
2023-05-16 18:07:47.166 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Sending command: 57817dc0fb
2023-05-16 18:07:47.254 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 18:07:47.348 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Notification received: 01817dc09b749907fac6
2023-05-16 18:07:47.350 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 18:07:47.562 DEBUG (MainThread) [switchbot.devices.device] WoLock (LOCKMACADDR): Fire callbacks
2023-05-16 18:07:47.591 DEBUG (MainThread) [switchbot.adv_parsers.lock] mfr_data: c189444b2ba5efb30820
2023-05-16 18:07:47.592 DEBUG (MainThread) [switchbot.adv_parsers.lock] data: 6f8062
2023-05-16 18:07:53.317 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 18:07:54.888 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Scheduling command 57817dc0f67b9c06eac6
2023-05-16 18:07:54.889 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Already connected before obtaining lock, resetting timer; RSSI: -79
2023-05-16 18:07:54.889 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Sending command: 57817dc0f67b9c06eac6
2023-05-16 18:07:55.028 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Notification received: 01817dc059a80990fa
2023-05-16 18:07:55.029 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Scheduling command 57817dc0fb
2023-05-16 18:07:55.029 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Already connected before obtaining lock, resetting timer; RSSI: -79
2023-05-16 18:07:55.030 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Sending command: 57817dc0fb
2023-05-16 18:07:55.078 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 18:07:55.138 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Notification received: 01817dc09b749907fac6
2023-05-16 18:07:55.139 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 18:08:00.166 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Fire callbacks
2023-05-16 18:08:01.787 DEBUG (MainThread) [switchbot.adv_parsers.lock] mfr_data: c189444b2ba5f2830820
2023-05-16 18:08:01.787 DEBUG (MainThread) [switchbot.adv_parsers.lock] data: 6f8062
2023-05-16 18:08:08.666 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Executing timed disconnect after timeout of 8.5
2023-05-16 18:08:08.666 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Executing disconnect
2023-05-16 18:08:08.667 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Executing disconnect with lock
2023-05-16 18:08:08.667 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Disconnecting
2023-05-16 18:08:08.758 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Disconnected from device; RSSI: -79
2023-05-16 18:08:08.760 DEBUG (MainThread) [switchbot.devices.device]  (LOCKMACADDR): Disconnect completed successfully

@bdraco
Copy link
Member

bdraco commented May 16, 2023

Please continue in a new issue since it’s a new problem

@KitHubek
Copy link
Author

ok, will open new issue. thanks

@bdraco bdraco changed the title After update from 2023.2.5 to 2023.3.6 Bluetooth stack takes 25 to retry connecting after error (error not seen) After update from 2023.2.5 to 2023.3.6 esphome bluetooth stack takes 25 to retry connecting after error (error not seen) May 16, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.