From 6e8735f3ba9efcb462f7280d8c5f06564c346343 Mon Sep 17 00:00:00 2001 From: timniklas Date: Sat, 28 Dec 2024 15:41:29 +0100 Subject: [PATCH] Improved connection stability --- custom_components/govee_light_ble/api.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/custom_components/govee_light_ble/api.py b/custom_components/govee_light_ble/api.py index 82b5e8b..c6cbd2e 100644 --- a/custom_components/govee_light_ble/api.py +++ b/custom_components/govee_light_ble/api.py @@ -41,9 +41,11 @@ def _responseExpected(self): async def _ensureConnected(self): """ connects to a bluetooth device """ - if self._client == None or not self._client.is_connected: - self.receiving_in_progress = False - self._client = await bleak_retry_connector.establish_connection(BleakClient, self._ble_device, self.address) + if self._client != None and self._client.is_connected: + return None + if self.receiving_in_progress: + self._stopReceiving() + self._client = await bleak_retry_connector.establish_connection(BleakClient, self._ble_device, self.address) async def _transmitPacket(self, packet: LedPacket): """ transmit the actiual packet """