Преглед изворни кода

Kerui cameras: make PTZ control into buttons.

Select is awkward in the UI, buttons are easier, and since the dp is
optional (null when idle), makes more sense, as the "(stopped)" dummy
value is needed if it is a select.

Issue #2410
Jason Rumney пре 1 година
родитељ
комит
bb2fa6fe66

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

@@ -170,6 +170,7 @@ secondary_entities:
         persist: false
         persist: false
   - entity: select
   - entity: select
     name: PTZ control
     name: PTZ control
+    deprecated: buttons
     icon: "mdi:camera-control"
     icon: "mdi:camera-control"
     category: config
     category: config
     dps:
     dps:
@@ -195,8 +196,110 @@ secondary_entities:
             value: left
             value: left
           - dps_val: "7"
           - dps_val: "7"
             value: left-up
             value: left-up
-          - dps_val: null
-            value: (stopped)
+  - entity: button
+    name: PTZ up
+    icon: "mdi:pan-up"
+    category: config
+    dps:
+      - id: 119
+        type: boolean
+        optional: true
+        name: button
+        mapping:
+          - dps_val: "0"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ right-up
+    icon: "mdi:top-right"
+    category: config
+    dps:
+      - id: 119
+        type: boolean
+        optional: true
+        name: button
+        mapping:
+          - dps_val: "1"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ right
+    icon: "mdi:pan-right"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "2"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ right-down
+    icon: "mdi:pan-bottom-right"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "3"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ down
+    icon: "mdi:pan-down"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "4"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ left-down
+    icon: "mdi:pan-bottom-left"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "5"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ left
+    icon: "mdi:pan-left"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "6"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ left-up
+    icon: "mdi:pan-top-left"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "7"
+            value: true
+          - value: false
   - entity: select
   - entity: select
     name: Recording mode
     name: Recording mode
     icon: "mdi:file-video"
     icon: "mdi:file-video"

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

@@ -176,6 +176,7 @@ secondary_entities:
         persist: false
         persist: false
   - entity: select
   - entity: select
     name: PTZ control
     name: PTZ control
+    deprecated: buttons
     icon: "mdi:camera-control"
     icon: "mdi:camera-control"
     category: config
     category: config
     dps:
     dps:
@@ -201,8 +202,110 @@ secondary_entities:
             value: left
             value: left
           - dps_val: "7"
           - dps_val: "7"
             value: left-up
             value: left-up
-          - dps_val: null
-            value: (stopped)
+  - entity: button
+    name: PTZ up
+    icon: "mdi:pan-up"
+    category: config
+    dps:
+      - id: 119
+        type: boolean
+        optional: true
+        name: button
+        mapping:
+          - dps_val: "0"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ right-up
+    icon: "mdi:top-right"
+    category: config
+    dps:
+      - id: 119
+        type: boolean
+        optional: true
+        name: button
+        mapping:
+          - dps_val: "1"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ right
+    icon: "mdi:pan-right"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "2"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ right-down
+    icon: "mdi:pan-bottom-right"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "3"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ down
+    icon: "mdi:pan-down"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "4"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ left-down
+    icon: "mdi:pan-bottom-left"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "5"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ left
+    icon: "mdi:pan-left"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "6"
+            value: true
+          - value: false
+  - entity: button
+    name: PTZ left-up
+    icon: "mdi:pan-top-left"
+    category: config
+    dps:
+      - id: 119
+        type: string
+        name: button
+        optional: true
+        mapping:
+          - dps_val: "7"
+            value: true
+          - value: false
   - entity: select
   - entity: select
     name: Recording mode
     name: Recording mode
     icon: "mdi:file-video"
     icon: "mdi:file-video"