From 53ca8a087ed93221d138242a95a70e8339cd3972 Mon Sep 17 00:00:00 2001 From: Konstantin Vorobyev Date: Fri, 26 Aug 2022 09:22:56 +0200 Subject: [PATCH] Fix device enumeration during discovery --- custom_components/nuki_ng/config_flow.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/nuki_ng/config_flow.py b/custom_components/nuki_ng/config_flow.py index 813085e..e0e1d74 100644 --- a/custom_components/nuki_ng/config_flow.py +++ b/custom_components/nuki_ng/config_flow.py @@ -35,7 +35,10 @@ async def find_nuki_devices(self, config: dict): use_hashed_token = info.get("bridgeType") == 1 response = await nuki.bridge_list() _LOGGER.debug(f"bridge devices: {response}") - title = response[0]["name"] + first_device = next(iter(response.values()), {}) + title = first_device.get("name") + if not title: + return title, "invalid_bridge_token", None except Exception as err: _LOGGER.exception( f"Failed to get list of devices from bridge: {err}")