Skip to content

Commit

Permalink
improved logging for connect
Browse files Browse the repository at this point in the history
  • Loading branch information
zweckj committed Nov 18, 2023
1 parent c66745d commit a94f75a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions pyacaia_async/acaiascale.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,22 @@ async def connect(
if not self._client:
raise AcaiaError("Client not initialized")
try:
await self._client.connect()
try:
await self._client.connect()
except BleakError as ex:
_LOGGER.exception("Error during connecting to device: %s", ex)
raise AcaiaError("Error during connecting to device") from ex

self._connected = True
_LOGGER.debug("Connected to Acaia Scale")

if callback is not None:
await self._client.start_notify(self._notify_char_id, callback)
await asyncio.sleep(0.5)
try:
await self._client.start_notify(self._notify_char_id, callback)
await asyncio.sleep(0.5)
except BleakError as ex:
_LOGGER.exception("Error subscribing to notifications: %s", ex)
raise AcaiaError("Error subscribing to notifications") from ex

await self.auth()

Expand All @@ -175,8 +184,6 @@ async def connect(

except BleakDeviceNotFoundError as ex:
raise AcaiaDeviceNotFound("Device not found") from ex
except BleakError as ex:
raise AcaiaError("Error connecting to device") from ex

async def auth(self) -> None:
"""Send auth message to scale, if subscribed to notifications returns Settings object"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pyacaia_async",
version="0.0.10",
version="0.0.11b1",
description="An async implementation of PyAcaia",
long_description=readme,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit a94f75a

Please sign in to comment.