diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d0963b8..6056a97 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/psf/black diff --git a/src/led_ble/led_ble.py b/src/led_ble/led_ble.py index 06e2e2e..02c695a 100644 --- a/src/led_ble/led_ble.py +++ b/src/led_ble/led_ble.py @@ -498,7 +498,13 @@ async def _execute_disconnect(self) -> None: self._read_char = None self._write_char = None if client and client.is_connected: - await client.stop_notify(read_char) + if read_char: + try: + await client.stop_notify(read_char) + except BleakError: + _LOGGER.debug( + "%s: Failed to stop notifications", self.name, exc_info=True + ) await client.disconnect() @retry_bluetooth_connection_error(DEFAULT_ATTEMPTS)