소스 검색

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 개월 전
부모
커밋
f145f0ee2f
1개의 변경된 파일2개의 추가작업 그리고 7개의 파일을 삭제
  1. 2 7
      custom_components/tuya_local/config_flow.py

+ 2 - 7
custom_components/tuya_local/config_flow.py

@@ -444,15 +444,12 @@ class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
         best_match = 0
         best_matching_type = None
         best_matching_key = None
-        has_product_id_match = False
 
         for dev_type in await self.device.async_possible_types():
             q = dev_type.match_quality(
                 self.device._get_cached_state(),
                 self.device._product_ids,
             )
-            if q > 100:
-                has_product_id_match = True
             for manufacturer, model in dev_type.product_display_entries(
                 self.device._product_ids
             ):
@@ -468,10 +465,8 @@ class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
                     best_matching_type = dev_type.config_type
                     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)
         dps = self.device._get_cached_state()