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

Add support for a smartplug with USB (Gosund SP112)

As it follows standard outlet+USB, timer and energy monitoring layout,
there is a good chance of it matching others, so added as generic.

Issue #448
Jason Rumney 3 лет назад
Родитель
Сommit
c5dcccdd03
3 измененных файлов с 158 добавлено и 1 удалено
  1. 2 0
      ACKNOWLEDGEMENTS.md
  2. 15 1
      DEVICES.md
  3. 141 0
      custom_components/tuya_local/devices/smartplug_usb.yaml

+ 2 - 0
ACKNOWLEDGEMENTS.md

@@ -197,3 +197,5 @@ Further device support has been made with the assistance of users.  Please consi
 - [elninosi](https://github.com/elninosi) for assisting with support for LoraTap curtain switches.
 - [mrulke](https://github.com/mrulke) for assisting with support for CCB-11 blind controllers.
 - [Codeazure](https://github.com/Codeazure) for assisting with support for 4-way power monitoring powerstrips (via Kogan 3-way + USB powerstrip).
+- [hebenon](https://github.com/hebenon) for contributing support for Breville Smart Air Connect purifiers.
+- [pvillanyi](https://github.com/pvillanyi) for contributing support for smartplugs with USB (Gosund SP112).

+ 15 - 1
DEVICES.md

@@ -182,6 +182,16 @@
 
 ### SmartPlugs/Wall sockets/Wall switches
 
+Most smartplugs follow a fairly standard template from Tuya, so many
+will work with other brands configs.  However there are many
+permutations of features enabled, and some manufacturers move
+datapoints around so smartplugs take up a lot more configurations than
+such simple devices should.  A future release will look at
+consolidating these into a smaller number of configs.  When you add a device,
+the default selected option for the device type has the most matching
+datapoints, so provided it looks like the same  type of device, it is probably
+the best option.
+
 - Arlec PB88UHA 4 way powerstrip with child lock
 - Aubess 1-gang switch with energy monitoring
 - Aubess 2-gang switch
@@ -206,7 +216,9 @@
 - Woox R4028/DIGOO DG-PS01 3 outlet + USB powerstrip with individual timers
 
 Other brands may work with the above configurations, or the below are
-generic configurations known to work with multiple brands of device.
+generic configurations that basically follow Tuya's templates with
+different features enabled, so are known to work with multiple brands
+of device.
 
 - 4 way power monitoring strip (2 types)
   _confirmed as working with Kogan KASPS10A3P3UA 3 socket + USB powerstrip
@@ -216,6 +228,8 @@ generic configurations known to work with multiple brands of device.
   _confirmed as working with Kogan and Blitzwolf single smartplugs_
 - Generic smartplug with energy monitoring (newer models)
   _confirmed as working with Kogan single smartplug with USB and Rillpac smartplugs_
+- Generic smartplug with energy monitoring and USB ports
+  _confirmed as working with Gosund SP112 smartplugs_
 - Generic smartplug with more advanced energy monitoring
   _confirmed working with CBE smartplugs, another variant with child lock, backlight and inching switch confirmed with Aubess and Elivco_
 - Generic smartplug with some additional encoded schedule info.

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

@@ -0,0 +1,141 @@
+name: Smartplug with USB
+products:
+  - id: zmql6aexy8ua5rox
+    name: Gosund SP112
+primary_entity:
+  entity: switch
+  class: outlet
+  dps:
+    - id: 1
+      type: boolean
+      name: switch
+    - id: 21
+      type: bitfield
+      name: factory_test
+      optional: true
+    - id: 26
+      type: integer
+      name: fault_code
+      optional: true
+secondary_entities:
+  - entity: switch
+    name: USB
+    icon: "mdi:usb"
+    dps:
+      - id: 7
+        type: boolean
+        name: switch
+  - entity: sensor
+    category: diagnostic
+    class: voltage
+    name: Voltage
+    dps:
+      - id: 20
+        name: sensor
+        type: integer
+        class: measurement
+        force: true
+        unit: V
+        mapping:
+          - scale: 10
+      - id: 22
+        type: integer
+        name: calibration
+        optional: true
+  - entity: sensor
+    category: diagnostic
+    class: current
+    name: Current
+    dps:
+      - id: 18
+        name: sensor
+        type: integer
+        class: measurement
+        force: true
+        unit: mA
+      - id: 23
+        type: integer
+        name: calibration
+        optional: true
+  - entity: sensor
+    category: diagnostic
+    class: power
+    name: Power
+    dps:
+      - id: 19
+        name: sensor
+        type: integer
+        class: measurement
+        force: true
+        unit: W
+        mapping:
+          - scale: 10
+      - id: 24
+        type: integer
+        name: calibration
+        optional: true
+  - entity: number
+    category: config
+    name: Outlet Timer
+    icon: "mdi:timer"
+    dps:
+      - id: 9
+        type: integer
+        name: value
+        unit: min
+        range:
+          min: 0
+          max: 86400
+        mapping:
+          - scale: 60
+            step: 60
+  - entity: number
+    name: USB Timer
+    category: config
+    icon: "mdi:timer"
+    dps:
+      - id: 15
+        type: integer
+        name: value
+        unit: min
+        range:
+          min: 0
+          max: 86400
+        mapping:
+          - scale: 60
+            step: 60
+  - entity: select
+    name: Initial state
+    icon: "mdi:toggle-switch"
+    category: config
+    dps:
+      - id: 38
+        type: string
+        name: option
+        mapping:
+          - dps_val: power_on
+            value: "On"
+          - dps_val: power_off
+            value: "Off"
+          - dps_val: last
+            value: Last state
+  - entity: select
+    name: Indicator
+    icon: "mdi:led-on"
+    category: config
+    dps:
+      - id: 39
+        type: string
+        name: option
+        mapping:
+          - dps_val: relay
+            value: State
+          - dps_val: pos
+            value: Position
+          - dps_val: none
+            value: "Off"
+
+            
+
+
+