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

feat (devices): add generic multi-switch

Tuya seems to reserve dps 1-8 for switches in all their standard
multi-switch devices, with timers starting at 7.

Create a generic config for switch-only devices using up to 8 switches
that takes advantage of this convention.

Inspired by eMylo US-08e3 dual+USB wall outlet, which uses dps 1 and 2
for mains outlets and 4 for USB (instead of the usual 7, or next in
series 3) in issue #4521
Jason Rumney 2 дней назад
Родитель
Сommit
763bc3e999
3 измененных файлов с 144 добавлено и 2 удалено
  1. 1 0
      ACKNOWLEDGEMENTS.md
  2. 3 2
      DEVICES.md
  3. 140 0
      custom_components/tuya_local/devices/simple_multi_switch.yaml

+ 1 - 0
ACKNOWLEDGEMENTS.md

@@ -1316,3 +1316,4 @@ Further device support has been made with the assistance of users. Please consid
 - [tfmm](https://github.com/tfmm) for assisting with support for ComfortZone AP100 air purifier.
 - [subpanel0576](https://github.com/subpanel0576) for assisting with support for V Jules.V SK17 galaxy projector.
 - [camcamnz](https://github.com/camcamnz) for contributing support for KRain KRX6 irrigation controller, which was merged with KRX8.
+- [nonamelee1003](https://github.com/nonamelee1003) for assisting with support for eMylo US-08e3 dual outlet + USB wall outlet (implemented as a generic multiswitch).

+ 3 - 2
DEVICES.md

@@ -785,9 +785,10 @@ of device.
 - Generic smartplug without power monitoring but with most other features (initial state setting, light options, child lock)
   _confirmed working with SX1 relay socket_
 - Generic double switch with timers (confirmed with Living dual switch and another v2 variant with Avatto dual switch)
+- Generic multi switches (up to 8-gang in any combination - confirmed with non-standard eMylo US-083e dual outlet+USB switches)
 - Generic triple and quad switches (confirmed with Songam wall switches)
-- Generic triple and quad switches with timers (confirmed with Pearl Xystec USB hub).
-- Generic quad powerstrip with uSB and power monitoring (confirmed with EKF Connect Pro)
+- Generic triple and quad switches with timers (confirmed with Pearl Xystec USB hub)
+- Generic quad powerstrip with USB and power monitoring (confirmed with EKF Connect Pro)
 - Simple switch - a switch only, can be a fallback for many other unsupported devices, to allow just power to be switched on/off.
 - Simple switch with timer - a single switch and timer, will probably work for a lot of smart switches that are not covered by the more advanced configs above.
 - Simple switch with timer v2 - the above with timer moved from dp 11 to 9, confirmed with a Nexxt 220V smart switch.

+ 140 - 0
custom_components/tuya_local/devices/simple_multi_switch.yaml

@@ -0,0 +1,140 @@
+name: Multi switch
+products:
+  - id: iHRCXog1Au8bh7XG
+    manufacturer: eMylo
+    model: US-08e3 2 gang+USB wall outlet
+entities:
+  - entity: switch
+    translation_key: switch_x
+    translation_placeholders:
+      x: "1"
+    dps:
+      - id: 1
+        type: boolean
+        name: switch
+  - entity: switch
+    hidden: unavailable
+    translation_key: switch_x
+    translation_placeholders:
+      x: "2"
+    dps:
+      - id: 2
+        type: boolean
+        optional: true
+        name: switch
+      - id: 2
+        type: boolean
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
+  - entity: switch
+    hidden: unavailable
+    translation_key: switch_x
+    translation_placeholders:
+      x: "3"
+    dps:
+      - id: 3
+        type: boolean
+        optional: true
+        name: switch
+      - id: 3
+        type: boolean
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
+  - entity: switch
+    hidden: unavailable
+    translation_key: switch_x
+    translation_placeholders:
+      x: "4"
+    dps:
+      - id: 4
+        type: boolean
+        optional: true
+        name: switch
+      - id: 4
+        type: boolean
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
+  - entity: switch
+    hidden: unavailable
+    translation_key: switch_x
+    translation_placeholders:
+      x: "5"
+    dps:
+      - id: 5
+        type: boolean
+        optional: true
+        name: switch
+      - id: 5
+        type: boolean
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
+  - entity: switch
+    hidden: unavailable
+    translation_key: switch_x
+    translation_placeholders:
+      x: "6"
+    dps:
+      - id: 6
+        type: boolean
+        optional: true
+        name: switch
+      - id: 6
+        type: boolean
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
+  - entity: switch
+    hidden: unavailable
+    translation_key: switch_x
+    translation_placeholders:
+      x: "7"
+    dps:
+      - id: 7
+        type: boolean
+        optional: true
+        name: switch
+      - id: 7
+        type: boolean
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
+  - entity: switch
+    hidden: unavailable
+    translation_key: switch_x
+    translation_placeholders:
+      x: "8"
+    dps:
+      - id: 8
+        type: boolean
+        optional: true
+        name: switch
+      - id: 8
+        type: boolean
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true