diff --git a/homeassistant/components/esphome/bluetooth/device.py b/homeassistant/components/esphome/bluetooth/device.py index 8d060151dbf254..c76562a2145a3d 100644 --- a/homeassistant/components/esphome/bluetooth/device.py +++ b/homeassistant/components/esphome/bluetooth/device.py @@ -21,6 +21,7 @@ class ESPHomeBluetoothDevice: _ble_connection_free_futures: list[asyncio.Future[int]] = field( default_factory=list ) + loop: asyncio.AbstractEventLoop = field(default_factory=asyncio.get_running_loop) @callback def async_update_ble_connection_limits(self, free: int, limit: int) -> None: @@ -49,6 +50,6 @@ async def wait_for_ble_connections_free(self) -> int: """Wait until there are free BLE connections.""" if self.ble_connections_free > 0: return self.ble_connections_free - fut: asyncio.Future[int] = asyncio.Future() + fut: asyncio.Future[int] = self.loop.create_future() self._ble_connection_free_futures.append(fut) return await fut