Просмотр исходного кода

config_flow: do not filter out devices from cloud list

Instead of filtering out known devices from the cloud list, filter them from
the list that is diplayed for selecting the new device.

This is because hubs can be already existing but still be a valid choice for a hub.

This issue was made worse by the recent change to cache parent devices for reuse
by other subdevices, as once cached the hub was being filtered out from future use.

Issue #1054
Jason Rumney 1 год назад
Родитель
Сommit
a1f15fa096
1 измененных файлов с 5 добавлено и 3 удалено
  1. 5 3
      custom_components/tuya_local/config_flow.py

+ 5 - 3
custom_components/tuya_local/config_flow.py

@@ -282,9 +282,9 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
             existing_uuid = (
                 domain_data.get(cloud_device["uuid"]) if domain_data else None
             )
-            if existing_id or existing_uuid:
-                _LOGGER.debug("Device is already registered.")
-                continue
+            existing = exisiton_id or existing_uuid
+            if existing and existing.get("device"):
+                cloud_device["exists"] = True
 
             _LOGGER.debug(f"Adding device: {cloud_device['id']}")
             cloud_devices[cloud_device["id"]] = cloud_device
@@ -324,6 +324,8 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
         device_list = []
         for key in self.__cloud_devices.keys():
             device_entry = self.__cloud_devices[key]
+            if device_entry["exists"]:
+                continue
             if device_entry[CONF_LOCAL_KEY] != "":
                 if device_entry["online"]:
                     device_list.append(