diff --git a/custom_components/zha_toolkit/scan_device.py b/custom_components/zha_toolkit/scan_device.py index 12f2fb6..3ced0e0 100644 --- a/custom_components/zha_toolkit/scan_device.py +++ b/custom_components/zha_toolkit/scan_device.py @@ -2,7 +2,6 @@ import asyncio import logging -import re from zigpy import types as t from zigpy.exceptions import ControllerException, DeliveryError @@ -14,6 +13,9 @@ LOGGER = logging.getLogger(__name__) +ACCESS_CONTROL_MAP = {0x01: "READ", 0x02: "WRITE", 0x04: "REPORT"} + + @u.retryable( ( DeliveryError, @@ -231,13 +233,16 @@ async def discover_attributes_extended(cluster, manufacturer=None, tries=3): ] else: attr_type = attr_type_hex - try: - access = re.sub( - "^.*\\.", - "", - str(foundation.AttributeAccessControl(access_acl)), + + if access_acl != 0: + access = "|".join( + [ + s + for x, s in ACCESS_CONTROL_MAP.items() + if x & access_acl != 0 + ] ) - except ValueError: + else: access = "undefined" result[attr_id] = {