Procházet zdrojové kódy

feat (smartplug_usb): cover plugs without timers

- Mark timers optional so plugs with just switches match also
- Hide missing entities by default

Issue #4499, PR #4504
Jason Rumney před 2 týdny
rodič
revize
3d483471f2

+ 64 - 0
custom_components/tuya_local/devices/smartplug_usb.yaml

@@ -24,6 +24,7 @@ entities:
   - entity: sensor
   - entity: sensor
     category: diagnostic
     category: diagnostic
     class: voltage
     class: voltage
+    hidden: unavailable
     dps:
     dps:
       - id: 20
       - id: 20
         name: sensor
         name: sensor
@@ -38,9 +39,18 @@ entities:
         type: integer
         type: integer
         name: calibration
         name: calibration
         optional: true
         optional: true
+      - id: 20
+        type: integer
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
   - entity: sensor
   - entity: sensor
     category: diagnostic
     category: diagnostic
     class: current
     class: current
+    hidden: unavailable
     dps:
     dps:
       - id: 18
       - id: 18
         name: sensor
         name: sensor
@@ -53,9 +63,18 @@ entities:
         type: integer
         type: integer
         name: calibration
         name: calibration
         optional: true
         optional: true
+      - id: 18
+        type: integer
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
   - entity: sensor
   - entity: sensor
     category: diagnostic
     category: diagnostic
     class: power
     class: power
+    hidden: unavailable
     dps:
     dps:
       - id: 19
       - id: 19
         name: sensor
         name: sensor
@@ -70,21 +89,40 @@ entities:
         type: integer
         type: integer
         name: calibration
         name: calibration
         optional: true
         optional: true
+      - id: 19
+        type: integer
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
   - entity: time
   - entity: time
     category: config
     category: config
     translation_key: timer
     translation_key: timer
+    hidden: unavailable
     dps:
     dps:
       - id: 9
       - id: 9
         type: integer
         type: integer
+        optional: true
         name: second
         name: second
         range:
         range:
           min: 0
           min: 0
           max: 86400
           max: 86400
+      - id: 9
+        type: integer
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
   - entity: time
   - entity: time
     category: config
     category: config
     translation_key: timer_x
     translation_key: timer_x
     translation_placeholders:
     translation_placeholders:
       x: USB
       x: USB
+    hidden: unavailable
     dps:
     dps:
       - id: 15
       - id: 15
         type: integer
         type: integer
@@ -92,9 +130,18 @@ entities:
         range:
         range:
           min: 0
           min: 0
           max: 86400
           max: 86400
+      - id: 15
+        type: integer
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
   - entity: select
   - entity: select
     translation_key: initial_state
     translation_key: initial_state
     category: config
     category: config
+    hidden: unavailable
     dps:
     dps:
       - id: 38
       - id: 38
         type: string
         type: string
@@ -107,9 +154,18 @@ entities:
             value: "off"
             value: "off"
           - dps_val: last
           - dps_val: last
             value: memory
             value: memory
+      - id: 38
+        type: integer
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
   - entity: select
   - entity: select
     translation_key: light_mode
     translation_key: light_mode
     category: config
     category: config
+    hidden: unavailable
     dps:
     dps:
       - id: 39
       - id: 39
         type: string
         type: string
@@ -122,6 +178,14 @@ entities:
             value: locator
             value: locator
           - dps_val: none
           - dps_val: none
             value: "off"
             value: "off"
+      - id: 39
+        type: integer
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
   - entity: binary_sensor
   - entity: binary_sensor
     class: problem
     class: problem
     category: diagnostic
     category: diagnostic