Skip to content

Commit

Permalink
Catch unexpected exceptions during scan
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Dec 4, 2023
1 parent 48fbd76 commit e80cecd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion custom_components/zha_toolkit/scan_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,23 @@ async def discover_attributes_extended(cluster, manufacturer=None, tries=3):
except UnicodeDecodeError:
value = value.hex()
result[attr_id]["attribute_value"] = value
except (DeliveryError, asyncio.TimeoutError) as ex:
except (
DeliveryError,
asyncio.TimeoutError,
) as ex:
LOGGER.error(
"Couldn't read 0x%04x/0x%04x: %s",
cluster.cluster_id,
attr_id,
ex,
)
except Exception as ex_unexpected:
LOGGER.error(
"Unexpected Exception while reading 0x%04x/0x%04x: %s",
cluster.cluster_id,
attr_id,
ex_unexpected,
)
chunk, to_read = to_read[:4], to_read[4:]
await asyncio.sleep(0.2)

Expand Down

0 comments on commit e80cecd

Please sign in to comment.