From 4015d245097659cf6d95bb5b7aa7b9a606ff0c88 Mon Sep 17 00:00:00 2001 From: Aleksey Makarenko Date: Tue, 15 Dec 2020 22:26:27 +0300 Subject: [PATCH] fix for #197 --- custom_components/ble_monitor/config_flow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/ble_monitor/config_flow.py b/custom_components/ble_monitor/config_flow.py index 5836f0e21..7d0fb6fab 100644 --- a/custom_components/ble_monitor/config_flow.py +++ b/custom_components/ble_monitor/config_flow.py @@ -323,7 +323,7 @@ async def async_step_init(self, user_input=None): self._devices[idmac] = {CONF_MAC: idmac, CONF_NAME: name} # sort devices by name - sorteddev_tuples = sorted(self._devices.items(), key=lambda item: item[1]["name"]) + sorteddev_tuples = sorted(self._devices.items(), key=lambda item: item[1].get("name", item[1]["mac"])) self._devices = dict(sorteddev_tuples) self.hass.config_entries.async_update_entry( self.config_entry,