Integration Through HomeKit Looses Connection

Hi HA Community,

I have a level bolt smart lock integrated into the HA through the HomeKit, and for some reason, the HA is losing connection with an instance after like 30 minutes of being idle. I have to use level's native app to initiate a connection to the lock, after which the connection between the lock and HA is restored.

I was thinking to create an automation that will run every 25 minutes and make a lock.lock call against the lock. This should work but it will kill the device’s battery.

Any ideas or suggestions on how to fix it?

LOGS

[139725305258976] A14 [7D:A7:CA:BA:15:AE] (id=77:F6:B7:2A:CA:42) - /org/bluez/hci0/dev_7D_A7_CA_BA_15_AE: Failed to connect: No device found for address 7D:A7:CA:BA:15:AE
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 464, in establish_connection
    await client.connect(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/models.py", line 283, in connect
    self._async_get_backend() or await self._async_get_fallback_backend()
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/models.py", line 320, in _async_get_backend
    raise BleakError(f"No device found for address {address}")
bleak.exc.BleakError: No device found for address 7D:A7:CA:BA:15:AE

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/connection.py", line 47, in establish_connection
    return await retry_establish_connection(
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 542, in establish_connection
    _raise_if_needed(name, description, exc)
  File "/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py", line 419, in _raise_if_needed
    raise BleakConnectionError(msg) from exc
bleak_retry_connector.BleakConnectionError: A14 [7D:A7:CA:BA:15:AE] (id=77:F6:B7:2A:CA:42) - /org/bluez/hci0/dev_7D_A7_CA_BA_15_AE: Failed to connect: No device found for address 7D:A7:CA:BA:15:AE

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 202, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1738, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1775, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 207, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/lock.py", line 114, in async_unlock
    await self._set_lock_state(STATE_UNLOCKED)
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/lock.py", line 118, in _set_lock_state
    await self.async_put_characteristics(
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/entity.py", line 91, in async_put_characteristics
    return await self._accessory.put_characteristics(payload)
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/connection.py", line 616, in put_characteristics
    results = await self.pairing.put_characteristics(characteristics)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 110, in _async_wrap
    return await func(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/client.py", line 76, in _async_wrap
    return await func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 758, in put_characteristics
    await self._populate_accessories_and_characteristics()
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 553, in _populate_accessories_and_characteristics
    await self._ensure_connected()
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/pairing.py", line 296, in _ensure_connected
    self.client = await establish_connection(
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ble/connection.py", line 57, in establish_connection
    raise AccessoryDisconnectedError(ex) from ex
aiohomekit.exceptions.AccessoryDisconnectedError: A14 [7D:A7:CA:BA:15:AE] (id=77:F6:B7:2A:CA:42) - /org/bluez/hci0/dev_7D_A7_CA_BA_15_AE: Failed to connect: No device found for address 7D:A7:CA:BA:15:AE

Ended up replacing the Bluetooth adapter. So far works without any issues.