Sfoglia il codice sorgente

cleanup (translations): correct translations of select options

where a translation is already provided, but options are different
from translations, but meaning the same, use the translation.

Some of these were obvious typos, others just missed a bulk update.
Jason Rumney 3 settimane fa
parent
commit
cd0c3e3dae

+ 2 - 2
custom_components/tuya_local/devices/atorch_s1tw_thermostat.yaml

@@ -323,9 +323,9 @@ entities:
         name: option
         mapping:
           - dps_val: c
-            value: Celsius
+            value: celsius
           - dps_val: f
-            value: Fahrenheit
+            value: fahrenheit
   - entity: sensor
     name: Cost
     icon: mdi:cash-multiple

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

@@ -59,7 +59,7 @@ entities:
           - dps_val: cancel
             value: cancel
           - dps_val: "1h"
-            value: "1"
+            value: "1h"
           - dps_val: "2h"
             value: "2h"
           - dps_val: "3h"

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

@@ -54,7 +54,7 @@ entities:
         name: option
         mapping:
           - dps_val: cancel
-            value: no timer active
+            value: cancel
           - dps_val: 1h
             value: 1h
           - dps_val: 2h

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

@@ -82,7 +82,7 @@ entities:
         force: true
   - entity: select
     name: Night vision
-    translation_key: mode
+    translation_key: light_mode
     category: config
     icon: "mdi:theme-light-dark"
     dps:

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

@@ -22,7 +22,7 @@ entities:
           - dps_val: "F1"
             value: low
           - dps_val: "F2"
-            value: meduim
+            value: medium
           - dps_val: "F3"
             value: high
   - entity: light

+ 2 - 2
custom_components/tuya_local/devices/kogan_vacuum_lx15.yaml

@@ -367,9 +367,9 @@ entities:
           - dps_val: "0"
             value: korean
           - dps_val: "1"
-            value: English Female
+            value: english
           - dps_val: "2"
-            value: English Child
+            value: english_child
           - dps_val: "3"
             value: chinese
   - name: Pause

+ 9 - 9
custom_components/tuya_local/devices/orion_ptc2000_heater.yaml

@@ -50,23 +50,23 @@ entities:
         name: option
         mapping:
           - dps_val: "cancel"
-            value: "none"
+            value: "cancel"
           - dps_val: "1h"
-            value: "1 Hour"
+            value: "1h"
           - dps_val: "2h"
-            value: "2 Hours"
+            value: "2h"
           - dps_val: "3h"
-            value: "3 Hours"
+            value: "3h"
           - dps_val: "4h"
-            value: "4 Hours"
+            value: "4h"
           - dps_val: "5h"
-            value: "5 Hours"
+            value: "5h"
           - dps_val: "6h"
-            value: "6 Hours"
+            value: "6h"
           - dps_val: "7h"
-            value: "7 Hours"
+            value: "7h"
           - dps_val: "8h"
-            value: "8 Hours"
+            value: "8h"
   - entity: switch
     name: Window detection
     icon: "mdi:window-open-variant"

+ 9 - 9
custom_components/tuya_local/devices/prosto_ptc2000_heater.yaml

@@ -68,23 +68,23 @@ entities:
         name: option
         mapping:
           - dps_val: "cancel"
-            value: "none"
+            value: "cancel"
           - dps_val: "1h"
-            value: "1 Hour"
+            value: "1h"
           - dps_val: "2h"
-            value: "2 Hours"
+            value: "2h"
           - dps_val: "3h"
-            value: "3 Hours"
+            value: "3h"
           - dps_val: "4h"
-            value: "4 Hours"
+            value: "4h"
           - dps_val: "5h"
-            value: "5 Hours"
+            value: "5h"
           - dps_val: "6h"
-            value: "6 Hours"
+            value: "6h"
           - dps_val: "7h"
-            value: "7 Hours"
+            value: "7h"
           - dps_val: "8h"
-            value: "8 Hours"
+            value: "8h"
   - entity: switch
     name: Window detection
     icon: "mdi:window-open-variant"

+ 37 - 0
util/untranslated_select.py

@@ -0,0 +1,37 @@
+"""Find translated selects with untranslated mappings in config files."""
+
+import json
+import sys
+from common_funcs import FakeDevice
+from custom_components.tuya_local.helpers.device_config import (
+    TuyaDeviceConfig,
+    available_configs,
+)
+
+
+def main() -> int:
+    with open("custom_components/tuya_local/translations/en.json", "r") as f:
+        english = json.load(f)
+    select = english["entity"]["select"]
+    dev = FakeDevice({})
+    for config in available_configs():
+        device = TuyaDeviceConfig(config)
+        for entity in device.all_entities():
+            if entity.entity == "select" and entity.translation_key:
+                d = entity.find_dps("option")
+                translations = select.get(entity.translation_key)
+                if translations is None:
+                    print(
+                        f"{config}:{entity._config.__line__}: MISSING {entity.translation_key}"
+                    )
+                    continue
+                for v in d.values(dev):
+                    if v not in translations["state"]:
+                        print(
+                            f"{config}:{v.__line__}: {v} missing from {entity.translation_key}"
+                        )
+    return 0
+
+
+if __name__ == "__main__":
+    sys.exit(main())