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

feat (circuit breakers): use breaker_trigger_action translations

- Replaces manually configured select with names "... action" with the
  breaker_trigger_action translation key with trigger replaced by "..."
- Standardises the actions to "ignore", "alarm" and "trip_breaker".
- Translations were provided for the above in the previous release
Jason Rumney 4 месяцев назад
Родитель
Сommit
15613104be

+ 12 - 14
custom_components/tuya_local/devices/cnc_ycb9zf_breaker.yaml

@@ -68,7 +68,9 @@ entities:
           min: 150
           max: 300
   - entity: select
-    name: Overvoltage action
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Overvoltage
     category: config
     dps:
       - id: 105
@@ -76,16 +78,15 @@ entities:
         name: option
         mapping:
           - dps_val: Shut
-            value: Remain closed
-            icon: "mdi:electric-switch-closed"
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
-            icon: "mdi:bell-alert"
+            value: alarm
           - dps_val: Trip
-            value: Trip
-            icon: "mdi:electric-switch"
+            value: trip_breaker
   - entity: select
-    name: Undervoltage action
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Undervoltage
     category: config
     dps:
       - id: 106
@@ -93,14 +94,11 @@ entities:
         name: option
         mapping:
           - dps_val: Shut
-            value: Remain closed
-            icon: "mdi:electric-switch-closed"
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
-            icon: "mdi:bell-alert"
+            value: alarm
           - dps_val: Trip
-            value: Trip
-            icon: "mdi:electric-switch"
+            value: trip_breaker
   - entity: number
     name: Overvoltage delay
     class: duration

+ 36 - 42
custom_components/tuya_local/devices/tongou_qcb2_circuitbreaker.yaml

@@ -165,7 +165,9 @@ entities:
         mapping:
           - scale: 1000
   - entity: select
-    name: Overvoltage action
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Overvoltage
     category: config
     dps:
       - id: 102
@@ -173,16 +175,15 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Remain closed
-            icon: "mdi:electric-switch-closed"
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
-            icon: "mdi:bell-alert"
+            value: alarm
           - dps_val: Trip
-            value: Trip
-            icon: "mdi:electric-switch"
+            value: trip_breaker
   - entity: select
-    name: Undervoltage action
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Undervoltage
     category: config
     dps:
       - id: 103
@@ -190,16 +191,15 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Remain closed
-            icon: "mdi:electric-switch-closed"
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
-            icon: "mdi:bell-alert"
+            value: alarm
           - dps_val: Trip
-            value: Trip
-            icon: "mdi:electric-switch"
+            value: trip_breaker
   - entity: select
-    name: Overcurrent action
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Overcurrent
     category: config
     dps:
       - id: 104
@@ -207,16 +207,15 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Remain closed
-            icon: "mdi:electric-switch-closed"
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
-            icon: "mdi:bell-alert"
+            value: alarm
           - dps_val: Trip
-            value: Trip
-            icon: "mdi:electric-switch"
+            value: trip_breaker
   - entity: select
-    name: Overpower action
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Overpower
     category: config
     dps:
       - id: 105
@@ -224,16 +223,15 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Remain closed
-            icon: "mdi:electric-switch-closed"
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
-            icon: "mdi:bell-alert"
+            value: alarm
           - dps_val: Trip
-            value: Trip
-            icon: "mdi:electric-switch"
+            value: trip_breaker
   - entity: select
-    name: Temperature action
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Temperature
     category: config
     dps:
       - id: 107
@@ -241,16 +239,15 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Remain closed
-            icon: "mdi:electric-switch-closed"
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
-            icon: "mdi:bell-alert"
+            value: alarm
           - dps_val: Trip
-            value: Trip
-            icon: "mdi:electric-switch"
+            value: trip_breaker
   - entity: select
-    name: Earth leakage action
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Earth leakage
     category: config
     dps:
       - id: 108
@@ -259,14 +256,11 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Remain closed
-            icon: "mdi:electric-switch-closed"
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
-            icon: "mdi:bell-alert"
+            value: alarm
           - dps_val: Trip
-            value: Trip
-            icon: "mdi:electric-switch"
+            value: trip_breaker
       - id: 117
         type: integer
         optional: true

+ 36 - 30
custom_components/tuya_local/devices/tongou_qcb2wb_breaker.yaml

@@ -152,8 +152,9 @@ entities:
           min: -400
           max: 1000
   - entity: select
-    name: Overvoltage action
-    icon: "mdi:fuse-alert"
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Overvoltage
     category: config
     dps:
       - id: 111
@@ -161,14 +162,15 @@ entities:
         name: option
         mapping:
           - dps_val: Close
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
           - dps_val: Trip
-            value: Trip
+            value: trip_breaker
   - entity: select
-    name: Undervoltage action
-    icon: "mdi:fuse-alert"
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Undervoltage
     category: config
     dps:
       - id: 112
@@ -176,14 +178,15 @@ entities:
         name: option
         mapping:
           - dps_val: Close
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
           - dps_val: Trip
-            value: Trip
+            value: trip_breaker
   - entity: select
-    name: Over current action
-    icon: "mdi:fuse-alert"
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Over current
     category: config
     dps:
       - id: 113
@@ -191,14 +194,15 @@ entities:
         name: option
         mapping:
           - dps_val: Close
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
           - dps_val: Trip
-            value: Trip
+            value: trip_breaker
   - entity: select
-    name: Over power action
-    icon: "mdi:fuse-alert"
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Over power
     category: config
     dps:
       - id: 114
@@ -206,14 +210,15 @@ entities:
         name: option
         mapping:
           - dps_val: Close
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
           - dps_val: Trip
-            value: Trip
+            value: trip_breaker
   - entity: select
-    name: Over temperature action
-    icon: "mdi:fuse-alert"
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Over temperature
     category: config
     dps:
       - id: 115
@@ -221,14 +226,15 @@ entities:
         name: option
         mapping:
           - dps_val: Close
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
           - dps_val: Trip
-            value: Trip
+            value: trip_breaker
   - entity: select
-    name: Earth leakage action
-    icon: "mdi:fuse-alert"
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Earth leakage
     category: config
     dps:
       - id: 116
@@ -236,11 +242,11 @@ entities:
         name: option
         mapping:
           - dps_val: Close
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
           - dps_val: Trip
-            value: Trip
+            value: trip_breaker
   - entity: sensor
     class: power
     category: diagnostic

+ 35 - 28
custom_components/tuya_local/devices/tongou_toqsyswt_breaker.yaml

@@ -111,7 +111,9 @@ entities:
         type: boolean
         name: switch
   - entity: select
-    name: Prepay shortage action
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Prepay shortage
     icon: "mdi:cash"
     category: config
     dps:
@@ -120,12 +122,13 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
   - entity: select
-    name: Over voltage action
-    icon: "mdi:flash-triangle"
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Over voltage
     category: config
     dps:
       - id: 102
@@ -133,14 +136,15 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
           - dps_val: Trip
-            value: Trip
+            value: trip_breaker
   - entity: select
-    name: Undervoltage action
-    icon: "mdi:flash-triangle"
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Undervoltage
     category: config
     dps:
       - id: 103
@@ -148,14 +152,15 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
           - dps_val: Trip
-            value: Trip
+            value: trip_breaker
   - entity: select
-    name: Over current action
-    icon: "mdi:flash-triangle"
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Over current
     category: config
     dps:
       - id: 104
@@ -163,14 +168,15 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
           - dps_val: Trip
-            value: Trip
+            value: trip_breaker
   - entity: select
-    name: Over power action
-    icon: "mdi:flash-triangle"
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: Over power
     category: config
     dps:
       - id: 105
@@ -178,14 +184,15 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
           - dps_val: Trip
-            value: Trip
+            value: trip_breaker
   - entity: select
-    name: High temperature action
-    icon: "mdi:fire"
+    translation_key: breaker_trigger_action
+    translation_placeholders:
+      trigger: High temperature
     category: config
     dps:
       - id: 107
@@ -193,11 +200,11 @@ entities:
         name: option
         mapping:
           - dps_val: Closed
-            value: Ignore
+            value: ignore
           - dps_val: Alarm
-            value: Alarm
+            value: alarm
           - dps_val: Trip
-            value: Trip
+            value: trip_breaker
   - entity: binary_sensor
     class: connectivity
     category: diagnostic