From e80cecdf32a5c858c8f659cc5092ce7e89f1a5c0 Mon Sep 17 00:00:00 2001 From: mdeweerd Date: Mon, 4 Dec 2023 18:18:46 +0100 Subject: [PATCH] Catch unexpected exceptions during scan --- custom_components/zha_toolkit/scan_device.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/custom_components/zha_toolkit/scan_device.py b/custom_components/zha_toolkit/scan_device.py index 6f18a79..2bd81f2 100644 --- a/custom_components/zha_toolkit/scan_device.py +++ b/custom_components/zha_toolkit/scan_device.py @@ -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)