فهرست منبع

Dev: add a util to find issues with product listings

Convert some missed product names to manufacturer and model
Jason Rumney 1 سال پیش
والد
کامیت
b7cf1f2bf7

+ 1 - 1
custom_components/tuya_local/devices/airquality6in1.yaml

@@ -1,7 +1,7 @@
 name: Air quality monitor
 products:
   - id: ugjbnqj2mffaexp5
-    name: Air Housekeeper 6-in-1
+    model: Air Housekeeper 6-in-1
 entities:
   - entity: sensor
     class: pm25

+ 2 - 1
custom_components/tuya_local/devices/beca_bht002_thermostat_c.yaml

@@ -2,7 +2,8 @@ name: Thermostat
 legacy_type: beca_bht6000_thermostat_c
 products:
   - id: IAYz2WK1th0cMLmL
-    name: Beca BHT-002 / MJZM 16A-3000BH
+    manufacturer: Beca / MJZM
+    model: BHT-002 / 16A-3000BH
 entities:
   - entity: climate
     dps:

+ 1 - 1
custom_components/tuya_local/devices/dimming_1ch_switch.yaml

@@ -1,7 +1,7 @@
 name: Dimmer
 products:
   - id: 5zsarybcltypoeaa
-    name: Single channel module
+    model: Single channel module
 entities:
   - entity: light
     dps:

+ 1 - 1
custom_components/tuya_local/devices/door_peephole_camera.yaml

@@ -1,7 +1,7 @@
 name: Camera
 products:
   - id: fzsbulp3wg64l8vx
-    name: TY-W160D
+    model: TY-W160D
 entities:
   - entity: camera
     dps:

+ 1 - 1
custom_components/tuya_local/devices/dual_clamp_energymeter.yaml

@@ -1,7 +1,7 @@
 name: Dual energy meter
 products:
   - id: jbarpbsikxovmxeg
-    name: Bidirectional 2-way CT clamp
+    model: Bidirectional 2-way CT clamp
 entities:
   - entity: sensor
     class: energy

+ 1 - 1
custom_components/tuya_local/manifest.json

@@ -15,5 +15,5 @@
         "tinytuya==1.16.1",
         "tuya-device-sharing-sdk~=0.2.1"
     ],
-    "version": "2025.1.2"
+    "version": "2025.2.0"
 }

+ 53 - 0
util/products.py

@@ -0,0 +1,53 @@
+"""Check products info"""
+
+import sys
+
+from common_funcs import load_config
+
+from custom_components.tuya_local.helpers.device_config import (
+    available_configs,
+    TuyaDeviceConfig,
+)
+
+
+def main():
+    missing = False
+    nameonly = False
+    arg_supplied = False
+
+    for arg in sys.argv[1:]:
+        arg_supplied = True
+        if arg == "--missing":
+            missing = True
+        elif arg == "--nameonly":
+            nameonly = True
+        else:
+            printf("List potential issues with products listings")
+            printf("")
+            print(f"Usage: {sys.argv[0]} [--missing] [--nameonly]")
+
+    # default to nameonly if no arguments supplied
+    if not arg_supplied:
+        nameonly = True
+
+    for config in available_configs():
+        device = TuyaDeviceConfig(config)
+        products = device._config.get("products", None)
+        if products:
+            for product in products:
+                if (
+                    product.get("name")
+                    and not product.get("manufacturer")
+                    and not product.get("model")
+                ):
+                    if nameonly:
+                        print(
+                            f"{config}: {product['name']} may need splitting to manufacturer and model"
+                        )
+        else:
+            if missing:
+                print(f"{config}: No products")
+
+
+if __name__ == "__main__":
+    sys.exit(main())