4
0
Эх сурвалжийг харах

fix (config_flow): revert restriction of list to matching product id

In a previous change, the list of matches was restricted to configs
matching the product id when there was a match.

This is undesirable, as reporters make mistakes and we cannot guarantee that
our product ids are correct, nor that manufacturers don't reuse product ids
for completely different products.

From comment on issue #4739
Jason Rumney 1 өдөр өмнө
parent
commit
f145f0ee2f

+ 2 - 7
custom_components/tuya_local/config_flow.py

@@ -444,15 +444,12 @@ class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
         best_match = 0
         best_match = 0
         best_matching_type = None
         best_matching_type = None
         best_matching_key = None
         best_matching_key = None
-        has_product_id_match = False
 
 
         for dev_type in await self.device.async_possible_types():
         for dev_type in await self.device.async_possible_types():
             q = dev_type.match_quality(
             q = dev_type.match_quality(
                 self.device._get_cached_state(),
                 self.device._get_cached_state(),
                 self.device._product_ids,
                 self.device._product_ids,
             )
             )
-            if q > 100:
-                has_product_id_match = True
             for manufacturer, model in dev_type.product_display_entries(
             for manufacturer, model in dev_type.product_display_entries(
                 self.device._product_ids
                 self.device._product_ids
             ):
             ):
@@ -468,10 +465,8 @@ class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
                     best_matching_type = dev_type.config_type
                     best_matching_type = dev_type.config_type
                     best_matching_key = key
                     best_matching_key = key
 
 
-        if has_product_id_match:
-            type_options = [opt for opt, q in all_matches if q > 100]
-        else:
-            type_options = [opt for opt, _ in all_matches]
+        all_matches.sort(key=lambda x: x[1], reverse=True)
+        type_options = [opt for opt, _ in all_matches]
 
 
         best_match = int(best_match)
         best_match = int(best_match)
         dps = self.device._get_cached_state()
         dps = self.device._get_cached_state()