Просмотр исходного кода

translation: add motion_detection switch translations

Issue #1708
Jason Rumney 1 неделя назад
Родитель
Сommit
2df19480e0
47 измененных файлов с 75 добавлено и 83 удалено
  1. 29 0
      custom_components/tuya_local/__init__.py
  2. 1 1
      custom_components/tuya_local/config_flow.py
  3. 1 2
      custom_components/tuya_local/devices/advwin_6l_petfeeder.yaml
  4. 1 1
      custom_components/tuya_local/devices/ajxml_1080p_videodoorbell.yaml
  5. 1 2
      custom_components/tuya_local/devices/arlec_pfc002ha_petfeeder_camera.yaml
  6. 1 2
      custom_components/tuya_local/devices/ble_solar_light.yaml
  7. 1 2
      custom_components/tuya_local/devices/bneta_f1d_petfeeder.yaml
  8. 1 1
      custom_components/tuya_local/devices/camnsmart_e27_camera.yaml
  9. 1 1
      custom_components/tuya_local/devices/cleverio_cd200_doorbell.yaml
  10. 1 1
      custom_components/tuya_local/devices/door_peephole_camera.yaml
  11. 1 2
      custom_components/tuya_local/devices/emos_ip300_camera.yaml
  12. 1 2
      custom_components/tuya_local/devices/evergreen_birdfeeder.yaml
  13. 1 2
      custom_components/tuya_local/devices/faroro_pettreat_camera.yaml
  14. 1 2
      custom_components/tuya_local/devices/feelneedy_plfp01_petfeeder.yaml
  15. 1 2
      custom_components/tuya_local/devices/frienhund_acf180wa_dualfeeder.yaml
  16. 1 1
      custom_components/tuya_local/devices/furpipi_camera_petfeeder.yaml
  17. 1 2
      custom_components/tuya_local/devices/garage_door_camera.yaml
  18. 1 1
      custom_components/tuya_local/devices/homall_90l_litterbox.yaml
  19. 1 2
      custom_components/tuya_local/devices/homemate_ptzcamera.yaml
  20. 1 2
      custom_components/tuya_local/devices/huntertbk_hf6602t_doorbell.yaml
  21. 1 2
      custom_components/tuya_local/devices/kerui_200w_camera.yaml
  22. 1 2
      custom_components/tuya_local/devices/kerui_300w_camera.yaml
  23. 1 2
      custom_components/tuya_local/devices/kw02_video_doorbell.yaml
  24. 1 2
      custom_components/tuya_local/devices/lindasmart_7s_doorbell.yaml
  25. 1 2
      custom_components/tuya_local/devices/lsc_ptz_camera.yaml
  26. 1 2
      custom_components/tuya_local/devices/lscsmartconnect_camerapetfeeder.yaml
  27. 1 2
      custom_components/tuya_local/devices/lscsmartconnect_outdoorcamera.yaml
  28. 1 2
      custom_components/tuya_local/devices/lscsmartconnect_outdoorptzcamera.yaml
  29. 1 2
      custom_components/tuya_local/devices/moes_indoorptz_camera.yaml
  30. 1 1
      custom_components/tuya_local/devices/moes_motionsensor_switch.yaml
  31. 1 2
      custom_components/tuya_local/devices/moes_wcmp52_camera.yaml
  32. 1 2
      custom_components/tuya_local/devices/mypin_6l_videopetfeeder.yaml
  33. 1 2
      custom_components/tuya_local/devices/myq_td8_videodoorbell.yaml
  34. 1 2
      custom_components/tuya_local/devices/nedis_outdoor_camera.yaml
  35. 1 2
      custom_components/tuya_local/devices/nexsmart_air2_camera.yaml
  36. 1 2
      custom_components/tuya_local/devices/nexsmart_air3_camera.yaml
  37. 1 2
      custom_components/tuya_local/devices/nexsmart_watch2_camera.yaml
  38. 1 2
      custom_components/tuya_local/devices/ningbo_bf314a_petfeeder.yaml
  39. 1 2
      custom_components/tuya_local/devices/petlibro_camera_feeder.yaml
  40. 1 2
      custom_components/tuya_local/devices/pinelake_birdfeeder.yaml
  41. 1 2
      custom_components/tuya_local/devices/rhpd10_doorbell_camera.yaml
  42. 1 1
      custom_components/tuya_local/devices/rojeco_v200du3lvs_petfeeder.yaml
  43. 1 2
      custom_components/tuya_local/devices/sc116wz3a_camera.yaml
  44. 1 2
      custom_components/tuya_local/devices/scheeair_nova100_ventilationfan.yaml
  45. 1 2
      custom_components/tuya_local/devices/smcm_doorbellpro_camera.yaml
  46. 1 2
      custom_components/tuya_local/devices/v330l_petfeeder.yaml
  47. 1 2
      custom_components/tuya_local/devices/yakry_camera_petfeeder.yaml

+ 29 - 0
custom_components/tuya_local/__init__.py

@@ -960,6 +960,35 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
 
         await async_migrate_entries(hass, entry.entry_id, update_unique_id13_20)
         hass.config_entries.async_update_entry(entry, minor_version=20)
+
+    if entry.version == 13 and entry.minor_version < 21:
+        # Migrate unique ids of existing entities to new id taking into
+        # account translation_key, and standardising naming
+        device_id = get_device_unique_id(entry)
+        conf_file = await hass.async_add_executor_job(
+            get_config,
+            entry.data[CONF_TYPE],
+        )
+        if conf_file is None:
+            _LOGGER.error(
+                NOT_FOUND,
+                entry.data[CONF_TYPE],
+            )
+            return False
+
+        @callback
+        def update_unique_id13_21(entity_entry):
+            """Update the unique id of an entity entry."""
+            # Standardistion of entity naming to use translation_key
+            replacements = {
+                "switch_motion_enable": "switch_motion_detection",
+                "switch_motion_sensing": "switch_motion_detection",
+                "swtich_motion_notification": "switch_motion_detection",
+            }
+            return replace_unique_ids(entity_entry, device_id, conf_file, replacements)
+
+        await async_migrate_entries(hass, entry.entry_id, update_unique_id13_21)
+        hass.config_entries.async_update_entry(entry, minor_version=21)
     return True
 
 

+ 1 - 1
custom_components/tuya_local/config_flow.py

@@ -53,7 +53,7 @@ DEVICE_DETAILS_URL = (
 
 class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
     VERSION = 13
-    MINOR_VERSION = 20
+    MINOR_VERSION = 21
     CONNECTION_CLASS = CONN_CLASS_LOCAL_PUSH
     device = None
     data = {}

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

@@ -8,8 +8,7 @@ products:
     model: 7L camera 202301
 entities:
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -58,7 +58,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -27,8 +27,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -169,8 +169,7 @@ entities:
           max: 3600
         unit: s
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 56

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

@@ -94,8 +94,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -24,7 +24,7 @@ entities:
         name: log_message
         optional: true
   - entity: switch
-    name: Motion detection
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -44,7 +44,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
+    translation_key: motion_detection
     category: config
     dps:
       - id: 240

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

@@ -15,7 +15,7 @@ entities:
         optional: true
         name: switch
   - entity: switch
-    name: Motion detection
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -28,8 +28,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -14,8 +14,7 @@ entities:
         optional: true
         name: switch
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -35,8 +35,7 @@ entities:
           - dps_val: 2
             value: "off"
   - entity: switch
-    name: Motion sensing
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -19,8 +19,7 @@ entities:
         type: boolean
         name: switch
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -42,8 +42,7 @@ entities:
         optional: true
         name: switch
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -81,7 +81,7 @@ entities:
         name: snapshot
         optional: true
   - entity: switch
-    name: Motion detection
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -11,8 +11,7 @@ entities:
         optional: true
         name: switch
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -226,7 +226,7 @@ entities:
         type: boolean
         name: sensor
   - entity: switch
-    name: Motion detection
+    translation_key: motion_detection
     category: diagnostic
     dps:
       - id: 110

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

@@ -13,8 +13,7 @@ entities:
         optional: true
         name: switch
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -44,8 +44,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 113

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

@@ -43,8 +43,7 @@ entities:
         optional: true
         name: message
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -32,8 +32,7 @@ entities:
         optional: true
         name: message
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -131,8 +131,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -39,8 +39,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 240

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

@@ -34,8 +34,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -29,8 +29,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -28,8 +28,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -29,8 +29,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -14,8 +14,7 @@ entities:
         optional: true
         name: switch
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -80,7 +80,7 @@ entities:
           - dps_val: now
             value: Set current
   - entity: switch
-    name: Motion enable
+    translation_key: motion_detection
     dps:
       - id: 46
         name: switch

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

@@ -40,8 +40,7 @@ entities:
         type: boolean
         name: switch
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -13,8 +13,7 @@ entities:
         optional: true
         name: switch
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 113

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

@@ -44,8 +44,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -28,8 +28,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -122,8 +122,7 @@ entities:
   # 4. Detection & Alarm
   # ------------------------------------
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     # PIR Switch (matches ipc_pir_switch: 240)
     dps:

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

@@ -127,8 +127,7 @@ entities:
   # 4. Detection & Alarm
   # ------------------------------------
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     # PIR Switch (matches ipc_pir_switch: 240)
     dps:

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

@@ -9,8 +9,7 @@ entities:
   # 1. Main Camera & Snapshot
   # ------------------------------------
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     # Motion Detection Switch (matches motion_switch: 134)
     dps:

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

@@ -49,8 +49,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -85,8 +85,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 113

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

@@ -13,8 +13,7 @@ entities:
         optional: true
         name: switch
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -44,8 +44,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 113

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

@@ -78,7 +78,7 @@ entities:
         name: snapshot
         optional: true
   - entity: switch
-    name: Motion detection
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -12,8 +12,7 @@ entities:
         optional: true
         name: switch
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -81,8 +81,7 @@ entities:
             value: true
           - value: false
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 107

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

@@ -14,8 +14,7 @@ entities:
         optional: true
         name: switch
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -77,8 +77,7 @@ entities:
         name: switch
         optional: true
   - entity: switch
-    name: Motion notification
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134

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

@@ -52,8 +52,7 @@ entities:
         optional: true
         name: snapshot
   - entity: switch
-    name: Motion detection
-    icon: "mdi:motion-sensor"
+    translation_key: motion_detection
     category: config
     dps:
       - id: 134