Browse Source

Handle additional retry-able exceptions (#120)

J. Nick Koston 1 year ago
parent
commit
794b74e195
2 changed files with 3 additions and 8 deletions
  1. 1 1
      setup.py
  2. 2 7
      switchbot/devices/device.py

+ 1 - 1
setup.py

@@ -3,7 +3,7 @@ from setuptools import setup
 setup(
     name="PySwitchbot",
     packages=["switchbot", "switchbot.devices", "switchbot.adv_parsers"],
-    install_requires=["async_timeout>=4.0.1", "bleak>=0.17.0", "bleak-retry-connector>=1.15.0"],
+    install_requires=["async_timeout>=4.0.1", "bleak>=0.17.0", "bleak-retry-connector>=1.17.1"],
     version="0.19.8",
     description="A library to communicate with Switchbot",
     author="Daniel Hjelseth Hoyer",

+ 2 - 7
switchbot/devices/device.py

@@ -14,6 +14,7 @@ from bleak.backends.device import BLEDevice
 from bleak.backends.service import BleakGATTCharacteristic, BleakGATTServiceCollection
 from bleak.exc import BleakDBusError
 from bleak_retry_connector import (
+    BLEAK_RETRY_EXCEPTIONS,
     BleakClientWithServiceCache,
     BleakNotFoundError,
     ble_device_has_changed,
@@ -37,12 +38,6 @@ DEVICE_SET_EXTENDED_KEY = REQ_HEADER
 # Base key when encryption is set
 KEY_PASSWORD_PREFIX = "571"
 
-BLEAK_EXCEPTIONS = (
-    AttributeError,
-    BleakError,
-    EOFError,
-    asyncio.exceptions.TimeoutError,
-)
 
 # How long to hold the connection
 # to wait for additional commands for
@@ -181,7 +176,7 @@ class SwitchbotBaseDevice:
                         self.rssi,
                         exc_info=True,
                     )
-                except BLEAK_EXCEPTIONS:
+                except BLEAK_RETRY_EXCEPTIONS:
                     if attempt == retry:
                         _LOGGER.error(
                             "%s: communication failed; Stopping trying; RSSI: %s",