fix availability states

This commit is contained in:
Patrick762 committed 2024-05-30 19:56:23 +02:00
1 parent f5b8e09fb4
commit b2672ec302
5 files changed
+49 -10

No files matched your search

@@ -144,7 +144,7 @@ class DeviceReader:
_LOGGER.warning("Got a parse exception...")
except TimeoutError:
_LOGGER.error("Polling timed out")
_LOGGER.warning("Polling timed out. Trying again later")
return None
except BleakError as err:
_LOGGER.error("Bleak error: %s", err)
@@ -153,10 +153,18 @@ class DeviceReader:
# Disconnect if connection not persistant
if not self.persistent_conn:
if self.has_notifier:
await self.client.stop_notify(NOTIFY_UUID)
try:
await self.client.stop_notify(NOTIFY_UUID)
except:
# Ignore errors here
pass
self.has_notifier = False
await self.client.disconnect()
# Check if dict is empty
if not parsed_data:
return None
return parsed_data
async def _async_send_command(self, command: ReadHoldingRegisters) -> bytes:
@@ -187,10 +195,8 @@ class DeviceReader:
err,
)
except (BadConnectionError, BleakError) as err:
_LOGGER.warning(
"Needed to disconnect due to error: %s (This can also be the case if you used device controls)",
err,
)
# Ignore other errors
pass
# caught an exception, return empty bytes object
return bytes()