Pārlūkot izejas kodu

Add support for UanTii IR remote controller

Issue #847

Relax test for unmatchable configs to allow configs with all optional
dps but have product ids specified.
Jason Rumney 1 gadu atpakaļ
vecāks
revīzija
912636a623

+ 16 - 0
custom_components/tuya_local/devices/basic_ir_remote.yaml

@@ -0,0 +1,16 @@
+name: IR remote
+products:
+  - id: mjffeakbzlnfxpzt
+    name: UanTii S06/S18
+primary_entity:
+  entity: remote
+  dps:
+    - id: 201
+      name: send
+      type: string
+      optional: true
+    - id: 202
+      name: receive
+      type: string
+      optional: true
+      persist: false

+ 10 - 0
tests/test_device_config.py

@@ -534,6 +534,16 @@ class TestDeviceConfig(IsolatedAsyncioTestCase):
             optional = set()
             required = set()
             parsed = TuyaDeviceConfig(cfg)
+            products = parsed._config.get("products")
+            # Configs with a product list can be matched by product id
+            if products:
+                p_match = False
+                for p in products:
+                    if p.get("id"):
+                        p_match = True
+                if p_match:
+                    continue
+
             for entity in parsed.all_entities():
                 for dp in entity.dps():
                     if dp.optional: