From e85755fbda15973c6c63eac826597fd2db65b9e2 Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Sat, 24 Aug 2024 15:52:27 -0400 Subject: [PATCH] Fix ZHA device lookup when ZHA devices are shared with additional integrations (#124429) * Fix ZHA device lookup when ZHA devices are shared with additional integrations * clean up except error types * remove impossible to create exceptions --- homeassistant/components/zha/helpers.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/zha/helpers.py b/homeassistant/components/zha/helpers.py index 35a794e8631..a5446af7e76 100644 --- a/homeassistant/components/zha/helpers.py +++ b/homeassistant/components/zha/helpers.py @@ -1012,16 +1012,12 @@ def async_get_zha_device_proxy(hass: HomeAssistant, device_id: str) -> ZHADevice _LOGGER.error("Device id `%s` not found in registry", device_id) raise KeyError(f"Device id `{device_id}` not found in registry.") zha_gateway_proxy = get_zha_gateway_proxy(hass) - try: - ieee_address = list(registry_device.identifiers)[0][1] - ieee = EUI64.convert(ieee_address) - except (IndexError, ValueError) as ex: - _LOGGER.error( - "Unable to determine device IEEE for device with device id `%s`", device_id - ) - raise KeyError( - f"Unable to determine device IEEE for device with device id `{device_id}`." - ) from ex + ieee_address = next( + identifier + for domain, identifier in registry_device.identifiers + if domain == DOMAIN + ) + ieee = EUI64.convert(ieee_address) return zha_gateway_proxy.device_proxies[ieee]