瀏覽代碼

Add translation placeholder support

- use it to translate number entities with names "Timer 1"...8

Issue #2514
Jason Rumney 1 年之前
父節點
當前提交
8c391a2902
共有 60 個文件被更改,包括 405 次插入221 次删除
  1. 6 4
      custom_components/tuya_local/devices/HCT-626_dual_water_timer.yaml
  2. 6 4
      custom_components/tuya_local/devices/aubess_2gang_switch.yaml
  3. 15 10
      custom_components/tuya_local/devices/bauhn_ap5w0624_powerstrip.yaml
  4. 6 4
      custom_components/tuya_local/devices/brilliant_double_switch.yaml
  5. 12 8
      custom_components/tuya_local/devices/brilliant_quad_switch.yaml
  6. 9 6
      custom_components/tuya_local/devices/brilliant_triple_switch.yaml
  7. 6 4
      custom_components/tuya_local/devices/digoo_dgsp202.yaml
  8. 6 4
      custom_components/tuya_local/devices/dual_power_monitor_smartplug.yaml
  9. 6 4
      custom_components/tuya_local/devices/dual_power_monitor_smartplugv2.yaml
  10. 9 6
      custom_components/tuya_local/devices/gosund_usb_triple_powerstrip.yaml
  11. 6 4
      custom_components/tuya_local/devices/grid_connect_usb_double_power_point.yaml
  12. 12 8
      custom_components/tuya_local/devices/logicom_powerstrip.yaml
  13. 6 4
      custom_components/tuya_local/devices/loratap_dual_switch.yaml
  14. 6 4
      custom_components/tuya_local/devices/loratap_wifi_curtain_switch_double.yaml
  15. 6 4
      custom_components/tuya_local/devices/makegood_double_power_point_with_energy.yaml
  16. 6 4
      custom_components/tuya_local/devices/makegood_switch_dual_timer-energy.yaml
  17. 3 2
      custom_components/tuya_local/devices/malmbergs_dual_dimmer.yaml
  18. 6 4
      custom_components/tuya_local/devices/moes_dual_dimmer.yaml
  19. 12 8
      custom_components/tuya_local/devices/moes_quad_switch.yaml
  20. 6 4
      custom_components/tuya_local/devices/moes_temp_humidity.yaml
  21. 9 6
      custom_components/tuya_local/devices/qnect_usb_powerstrip.yaml
  22. 12 8
      custom_components/tuya_local/devices/quad_power_timer.yaml
  23. 12 8
      custom_components/tuya_local/devices/quad_powerstrip.yaml
  24. 12 8
      custom_components/tuya_local/devices/quad_powerstrip_usb.yaml
  25. 21 14
      custom_components/tuya_local/devices/seven_channel_switch.yaml
  26. 6 4
      custom_components/tuya_local/devices/simple_dual_switch_timer.yaml
  27. 6 4
      custom_components/tuya_local/devices/simple_dual_switch_timer_v2.yaml
  28. 12 8
      custom_components/tuya_local/devices/smart_multi_plug_4t_4usb.yaml
  29. 12 8
      custom_components/tuya_local/devices/smart_powerstrip.yaml
  30. 9 6
      custom_components/tuya_local/devices/smart_powerstrip_3_outlet_energy.yaml
  31. 6 4
      custom_components/tuya_local/devices/smart_surge_protector_plug_2x2.yaml
  32. 6 4
      custom_components/tuya_local/devices/somgom_double_switch.yaml
  33. 6 4
      custom_components/tuya_local/devices/teckin_ss42_sockets.yaml
  34. 6 4
      custom_components/tuya_local/devices/treatlife_dual_plugin_dimmer.yaml
  35. 12 8
      custom_components/tuya_local/devices/usb_4way_powerstrip.yaml
  36. 9 6
      custom_components/tuya_local/devices/woox_r4028_powerstrip.yaml
  37. 24 16
      custom_components/tuya_local/devices/zemismart_dpwbs01_sprinklercontroller.yaml
  38. 12 1
      custom_components/tuya_local/helpers/device_config.py
  39. 2 0
      custom_components/tuya_local/helpers/mixin.py
  40. 3 0
      custom_components/tuya_local/icons.json
  41. 3 0
      custom_components/tuya_local/translations/bg.json
  42. 3 0
      custom_components/tuya_local/translations/cz.json
  43. 3 0
      custom_components/tuya_local/translations/de.json
  44. 3 0
      custom_components/tuya_local/translations/el.json
  45. 3 0
      custom_components/tuya_local/translations/en.json
  46. 3 0
      custom_components/tuya_local/translations/es.json
  47. 3 0
      custom_components/tuya_local/translations/fr.json
  48. 3 0
      custom_components/tuya_local/translations/hu.json
  49. 3 0
      custom_components/tuya_local/translations/id.json
  50. 3 0
      custom_components/tuya_local/translations/it.json
  51. 3 0
      custom_components/tuya_local/translations/ja.json
  52. 3 0
      custom_components/tuya_local/translations/no-NB.json
  53. 3 0
      custom_components/tuya_local/translations/pl.json
  54. 3 0
      custom_components/tuya_local/translations/pt-BR.json
  55. 3 0
      custom_components/tuya_local/translations/ru.json
  56. 3 0
      custom_components/tuya_local/translations/uk.json
  57. 3 0
      custom_components/tuya_local/translations/ur.json
  58. 3 0
      custom_components/tuya_local/translations/zh-Hans.json
  59. 3 0
      custom_components/tuya_local/translations/zh-Hant.json
  60. 1 0
      tests/test_device_config.py

+ 6 - 4
custom_components/tuya_local/devices/HCT-626_dual_water_timer.yaml

@@ -19,8 +19,9 @@ secondary_entities:
         type: boolean
         name: valve
   - entity: number
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     category: config
     dps:
       - id: 17
@@ -34,8 +35,9 @@ secondary_entities:
             step: 60
         unit: min
   - entity: number
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     category: config
     dps:
       - id: 18

+ 6 - 4
custom_components/tuya_local/devices/aubess_2gang_switch.yaml

@@ -30,8 +30,9 @@ secondary_entities:
         name: switch
         type: boolean
   - entity: number
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     category: config
     dps:
       - id: 9
@@ -44,9 +45,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         type: integer

+ 15 - 10
custom_components/tuya_local/devices/bauhn_ap5w0624_powerstrip.yaml

@@ -45,9 +45,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         type: integer
@@ -69,9 +70,10 @@ secondary_entities:
         type: string
         name: switch_inching
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         type: integer
@@ -84,9 +86,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         type: integer
@@ -99,9 +102,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 4
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 12
         type: integer
@@ -114,9 +118,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 5
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "5"
     dps:
       - id: 13
         type: integer

+ 6 - 4
custom_components/tuya_local/devices/brilliant_double_switch.yaml

@@ -19,9 +19,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 7
         type: integer
@@ -34,9 +35,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 8
         type: integer

+ 12 - 8
custom_components/tuya_local/devices/brilliant_quad_switch.yaml

@@ -33,9 +33,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 7
         type: integer
@@ -48,9 +49,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 8
         type: integer
@@ -63,9 +65,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 9
         type: integer
@@ -78,9 +81,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 4
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 10
         type: integer

+ 9 - 6
custom_components/tuya_local/devices/brilliant_triple_switch.yaml

@@ -26,9 +26,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 7
         type: integer
@@ -41,9 +42,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 8
         type: integer
@@ -56,9 +58,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 9
         type: integer

+ 6 - 4
custom_components/tuya_local/devices/digoo_dgsp202.yaml

@@ -51,8 +51,9 @@ secondary_entities:
           - scale: 10
   - entity: number
     category: config
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         name: value
@@ -66,8 +67,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         name: value

+ 6 - 4
custom_components/tuya_local/devices/dual_power_monitor_smartplug.yaml

@@ -56,9 +56,10 @@ secondary_entities:
         mapping:
           - scale: 10
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 10
         type: integer
@@ -71,9 +72,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 11
         type: integer

+ 6 - 4
custom_components/tuya_local/devices/dual_power_monitor_smartplugv2.yaml

@@ -37,9 +37,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         type: integer
@@ -52,9 +53,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         type: integer

+ 9 - 6
custom_components/tuya_local/devices/gosund_usb_triple_powerstrip.yaml

@@ -33,9 +33,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         type: integer
@@ -48,9 +49,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         type: integer
@@ -63,9 +65,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         type: integer

+ 6 - 4
custom_components/tuya_local/devices/grid_connect_usb_double_power_point.yaml

@@ -102,8 +102,9 @@ secondary_entities:
           - dps_val: memory
             value: memory
   - entity: number
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     category: config
     dps:
       - id: 9
@@ -114,8 +115,9 @@ secondary_entities:
           min: 0
           max: 86400
   - entity: number
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     category: config
     dps:
       - id: 10

+ 12 - 8
custom_components/tuya_local/devices/logicom_powerstrip.yaml

@@ -38,8 +38,9 @@ secondary_entities:
         name: switch
   - entity: number
     category: config
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         name: value
@@ -53,8 +54,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         name: value
@@ -68,8 +70,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 3
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         name: value
@@ -83,8 +86,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 4
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 12
         name: value

+ 6 - 4
custom_components/tuya_local/devices/loratap_dual_switch.yaml

@@ -17,8 +17,9 @@ secondary_entities:
         name: switch
         type: boolean
   - entity: number
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     category: config
     dps:
       - id: 9
@@ -38,8 +39,9 @@ secondary_entities:
         name: cycle_time
         type: string
   - entity: number
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     category: config
     dps:
       - id: 10

+ 6 - 4
custom_components/tuya_local/devices/loratap_wifi_curtain_switch_double.yaml

@@ -50,9 +50,10 @@ secondary_entities:
         name: current_position
         type: integer
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 10
         name: value
@@ -62,9 +63,10 @@ secondary_entities:
           max: 120
           min: 2
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 11
         name: value

+ 6 - 4
custom_components/tuya_local/devices/makegood_double_power_point_with_energy.yaml

@@ -51,8 +51,9 @@ secondary_entities:
           - scale: 10
   - entity: number
     category: config
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 2
         name: value
@@ -66,8 +67,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 14
         name: value

+ 6 - 4
custom_components/tuya_local/devices/makegood_switch_dual_timer-energy.yaml

@@ -17,8 +17,9 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     category: config
     dps:
       - id: 7
@@ -32,8 +33,9 @@ secondary_entities:
             step: 60
         unit: min
   - entity: number
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     category: config
     dps:
       - id: 8

+ 3 - 2
custom_components/tuya_local/devices/malmbergs_dual_dimmer.yaml

@@ -65,8 +65,9 @@ secondary_entities:
           min: 25
           max: 255
   - entity: number
-    translation_key: timer
-    name: Timer 2
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     category: config
     dps:
       - id: 12

+ 6 - 4
custom_components/tuya_local/devices/moes_dual_dimmer.yaml

@@ -113,8 +113,9 @@ secondary_entities:
             value: Halogen
             icon: "mdi:lightbulb-spot"
   - entity: number
-    translation_key: timer
-    name: Timer 1
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     category: config
     dps:
       - id: 6
@@ -128,8 +129,9 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    translation_key: timer
-    name: Timer 2
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     category: config
     dps:
       - id: 12

+ 12 - 8
custom_components/tuya_local/devices/moes_quad_switch.yaml

@@ -36,9 +36,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         type: integer
@@ -57,9 +58,10 @@ secondary_entities:
         type: string
         name: cycle_timer
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         type: integer
@@ -72,9 +74,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         type: integer
@@ -87,9 +90,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 4
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 12
         type: integer

+ 6 - 4
custom_components/tuya_local/devices/moes_temp_humidity.yaml

@@ -109,8 +109,9 @@ secondary_entities:
         mapping:
           - scale: 10
   - entity: number
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     category: config
     dps:
       - id: 103
@@ -121,8 +122,9 @@ secondary_entities:
           min: 0
           max: 86400
   - entity: number
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     category: config
     dps:
       - id: 104

+ 9 - 6
custom_components/tuya_local/devices/qnect_usb_powerstrip.yaml

@@ -34,8 +34,9 @@ secondary_entities:
         name: switch
   - entity: number
     category: config
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         name: value
@@ -49,8 +50,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         name: value
@@ -64,8 +66,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 3
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         name: value

+ 12 - 8
custom_components/tuya_local/devices/quad_power_timer.yaml

@@ -33,9 +33,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         type: integer
@@ -48,9 +49,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         type: integer
@@ -63,9 +65,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         type: integer
@@ -78,9 +81,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 4
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 12
         type: integer

+ 12 - 8
custom_components/tuya_local/devices/quad_powerstrip.yaml

@@ -41,9 +41,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         type: integer
@@ -56,9 +57,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         type: integer
@@ -71,9 +73,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         type: integer
@@ -86,9 +89,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 4
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 12
         type: integer

+ 12 - 8
custom_components/tuya_local/devices/quad_powerstrip_usb.yaml

@@ -44,9 +44,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         type: integer
@@ -59,9 +60,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         type: integer
@@ -74,9 +76,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         type: integer
@@ -89,9 +92,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 4
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 12
         type: integer

+ 21 - 14
custom_components/tuya_local/devices/seven_channel_switch.yaml

@@ -47,9 +47,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         type: integer
@@ -62,9 +63,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         type: integer
@@ -77,9 +79,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         type: integer
@@ -92,9 +95,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 4
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 12
         type: integer
@@ -107,9 +111,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 5
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "5"
     dps:
       - id: 13
         type: integer
@@ -122,9 +127,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 6
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "6"
     dps:
       - id: 14
         type: integer
@@ -137,9 +143,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 7
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "7"
     dps:
       - id: 15
         type: integer

+ 6 - 4
custom_components/tuya_local/devices/simple_dual_switch_timer.yaml

@@ -16,8 +16,9 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     category: config
     dps:
       - id: 7
@@ -31,8 +32,9 @@ secondary_entities:
             step: 60
         unit: min
   - entity: number
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     category: config
     dps:
       - id: 8

+ 6 - 4
custom_components/tuya_local/devices/simple_dual_switch_timer_v2.yaml

@@ -17,8 +17,9 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     category: config
     dps:
       - id: 9
@@ -32,8 +33,9 @@ secondary_entities:
             step: 60
         unit: min
   - entity: number
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     category: config
     dps:
       - id: 10

+ 12 - 8
custom_components/tuya_local/devices/smart_multi_plug_4t_4usb.yaml

@@ -44,9 +44,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         type: integer
@@ -59,9 +60,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         type: integer
@@ -74,9 +76,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         type: integer
@@ -89,9 +92,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 4
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 12
         type: integer

+ 12 - 8
custom_components/tuya_local/devices/smart_powerstrip.yaml

@@ -41,8 +41,9 @@ secondary_entities:
         name: switch
   - entity: number
     category: config
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         name: value
@@ -56,8 +57,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         name: value
@@ -71,8 +73,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 3
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         name: value
@@ -86,8 +89,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 4
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 12
         name: value

+ 9 - 6
custom_components/tuya_local/devices/smart_powerstrip_3_outlet_energy.yaml

@@ -35,8 +35,9 @@ secondary_entities:
         name: switch
   - entity: number
     category: config
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 9
         type: integer
@@ -50,8 +51,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 10
         type: integer
@@ -65,8 +67,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 3
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 11
         type: integer

+ 6 - 4
custom_components/tuya_local/devices/smart_surge_protector_plug_2x2.yaml

@@ -31,8 +31,9 @@ secondary_entities:
         name: switch
         type: boolean
   - entity: number
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     category: config
     dps:
       - id: 9
@@ -46,8 +47,9 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     category: config
     dps:
       - id: 10

+ 6 - 4
custom_components/tuya_local/devices/somgom_double_switch.yaml

@@ -14,8 +14,9 @@ secondary_entities:
         name: switch
         type: boolean
   - entity: number
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     category: config
     dps:
       - id: 7
@@ -28,8 +29,9 @@ secondary_entities:
           - scale: 60
         unit: min
   - entity: number
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     category: config
     dps:
       - id: 8

+ 6 - 4
custom_components/tuya_local/devices/teckin_ss42_sockets.yaml

@@ -17,8 +17,9 @@ secondary_entities:
         name: switch
   - entity: number
     category: config
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 101
         type: integer
@@ -32,8 +33,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 102
         type: integer

+ 6 - 4
custom_components/tuya_local/devices/treatlife_dual_plugin_dimmer.yaml

@@ -78,9 +78,10 @@ secondary_entities:
           - dps_val: halogen
             value: Halogen
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 6
         type: integer
@@ -93,9 +94,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 12
         type: integer

+ 12 - 8
custom_components/tuya_local/devices/usb_4way_powerstrip.yaml

@@ -39,9 +39,10 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 101
         type: integer
@@ -54,9 +55,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 102
         type: integer
@@ -69,9 +71,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 103
         type: integer
@@ -84,9 +87,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 4
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 104
         type: integer

+ 9 - 6
custom_components/tuya_local/devices/woox_r4028_powerstrip.yaml

@@ -31,8 +31,9 @@ secondary_entities:
         name: switch
   - entity: number
     category: config
-    name: Timer 1
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 101
         name: value
@@ -46,8 +47,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 2
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 102
         name: value
@@ -61,8 +63,9 @@ secondary_entities:
             step: 60
   - entity: number
     category: config
-    name: Timer 3
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 103
         name: value

+ 24 - 16
custom_components/tuya_local/devices/zemismart_dpwbs01_sprinklercontroller.yaml

@@ -79,9 +79,10 @@ secondary_entities:
         type: boolean
         name: valve
   - entity: number
-    name: Timer 1
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "1"
     dps:
       - id: 13
         type: integer
@@ -94,9 +95,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 2
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "2"
     dps:
       - id: 14
         type: integer
@@ -109,9 +111,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 3
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "3"
     dps:
       - id: 15
         type: integer
@@ -124,9 +127,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 4
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "4"
     dps:
       - id: 16
         type: integer
@@ -139,9 +143,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 5
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "5"
     dps:
       - id: 17
         type: integer
@@ -154,9 +159,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 6
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "6"
     dps:
       - id: 18
         type: integer
@@ -169,9 +175,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 7
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "7"
     dps:
       - id: 19
         type: integer
@@ -184,9 +191,10 @@ secondary_entities:
           - scale: 60
             step: 60
   - entity: number
-    name: Timer 8
     category: config
-    translation_key: timer
+    translation_key: timer_x
+    translation_placeholders:
+      x: "8"
     dps:
       - id: 20
         type: integer

+ 12 - 1
custom_components/tuya_local/helpers/device_config.py

@@ -244,6 +244,11 @@ class TuyaEntityConfig:
         """The translation key for this entity, not used for unique_id"""
         return self._config.get("translation_only_key")
 
+    @property
+    def translation_placeholders(self):
+        """The translation placeholders for this entity."""
+        return self._config.get("translation_placeholders", {})
+
     def unique_id(self, device_uid):
         """Return a suitable unique_id for this entity."""
         return f"{device_uid}-{slugify(self.config_id)}"
@@ -280,7 +285,13 @@ class TuyaEntityConfig:
         if own_name:
             return f"{self.entity}_{slugify(own_name)}"
         if self.translation_key:
-            return f"{self.entity}_{self.translation_key}"
+            slug = f"{self.entity}_{self.translation_key}"
+            for key, value in self.translation_placeholders.items():
+                if key in slug:
+                    slug = slug.replace(key, str(value))
+                else:
+                    slug = f"{slug}_{value}"
+            return slug
         return self.entity
 
     @property

+ 2 - 0
custom_components/tuya_local/helpers/mixin.py

@@ -24,6 +24,8 @@ class TuyaLocalEntity:
         self._attr_translation_key = (
             config.translation_key or config.translation_only_key
         )
+        self._attr_translation_placeholders = config.translation_placeholders
+
         return {c.name: c for c in config.dps()}
 
     def _init_end(self, dps):

+ 3 - 0
custom_components/tuya_local/icons.json

@@ -128,6 +128,9 @@
         "number": {
             "timer": {
                 "default": "mdi:timer"
+            },
+            "timer_x": {
+                "default": "mdi:timer"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/bg.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "Таймер"
+            },
+            "timer_x": {
+                "name": "Таймер {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/cz.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "Časovač"
+            },
+            "timer_x": {
+                "name": "Časovač {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/de.json

@@ -377,6 +377,9 @@
         "number": {
             "timer": {
                 "name": "Timer"
+            },
+            "timer_x": {
+                "name": "Timer {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/el.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "Χρονοδιακόπτης"
+            },
+            "timer_x": {
+                "name": "Χρονοδιακόπτης {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/en.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "Timer"
+            },
+            "timer_x": {
+                "name": "Timer {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/es.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "Temporizador"
+            },
+            "timer_x": {
+                "name": "Temporizador {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/fr.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "Minuteur"
+            },
+            "timer_x": {
+                "name": "Minuteur {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/hu.json

@@ -379,6 +379,9 @@
         "number": {
             "timer": {
                 "name": "Időzítő"
+            },
+            "timer_x": {
+                "name": "Időzítő {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/id.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "Pengatur waktu"
+            },
+            "timer_x": {
+                "name": "Pengatur waktu {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/it.json

@@ -379,6 +379,9 @@
         "number": {
             "timer": {
                 "name": "Timer"
+            },
+            "timer_x": {
+                "name": "Timer {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/ja.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "タイマー"
+            },
+            "timer_x": {
+                "name": "タイマー{x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/no-NB.json

@@ -379,6 +379,9 @@
         "number": {
             "timer": {
                 "name": "Timer"
+            },
+            "timer_x": {
+                "name": "Timer {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/pl.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "Regulator czasowy"
+            },
+            "timer_x": {
+                "name": "Regulator czasowy {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/pt-BR.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "Cronômetro"
+            },
+            "timer_x": {
+                "name": "Cronômetro {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/ru.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "Таймер"
+            },
+            "timer_x": {
+                "name": "Таймер {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/uk.json

@@ -381,6 +381,9 @@
         "number": {
             "timer": {
                 "name": "Таймер"
+            },
+            "timer_x": {
+                "name": "Таймер {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/ur.json

@@ -381,6 +381,9 @@
         "number": {
             "timer": {
                 "name": "ٹائمر"
+            },
+            "timer_x": {
+                "name": "ٹائمر {x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/zh-Hans.json

@@ -378,6 +378,9 @@
         "number": {
             "timer": {
                 "name": "计时器"
+            },
+            "timer_x": {
+                "name": "计时器{x}"
             }
         },
         "select": {

+ 3 - 0
custom_components/tuya_local/translations/zh-Hant.json

@@ -379,6 +379,9 @@
         "number": {
             "timer": {
                 "name": "計時器"
+            },
+            "timer_x": {
+                "name": "計時器{x}"
             }
         },
         "select": {

+ 1 - 0
tests/test_device_config.py

@@ -148,6 +148,7 @@ ENTITY_SCHEMA = vol.Schema(
         vol.Optional("name"): str,
         vol.Optional("class"): str,
         vol.Optional(vol.Or("translation_key", "translation_only_key")): str,
+        vol.Optional("translation_placeholders"): dict[str, str],
         vol.Optional("category"): vol.In(["config", "diagnostic"]),
         vol.Optional("icon"): vol.Match(r"^mdi:"),
         vol.Optional("icon_priority"): int,