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

Add support for BlitzWolf SHP6 Pro smartplug

Issue #421

Very similar of smartplugv2_energyv3, but some dps are offset by 1.
Jason Rumney пре 3 година
родитељ
комит
ae68db1814

+ 1 - 1
ACKNOWLEDGEMENTS.md

@@ -192,6 +192,6 @@ Further device support has been made with the assistance of users.  Please consi
 - [Saentist](https://github.com/Saentist) for contributing Bulgarian translations.
 - [drudgebg](https://github.com/drudgebg) for contributing support for Teckin SS42 outdoor double smartplug.
 - [saotthon](https://github.com/saotthon) for assisting with support for BVF CP1 heaters.
-- [MarciPain](https://github.com/MarciPain) for contributing support for PGST temperature and humidity sensors and Orion OWH-PTC2000 heaters.
+- [MarciPain](https://github.com/MarciPain) for contributing support for PGST temperature and humidity sensors, Orion OWH-PTC2000 heaters and BlitzWolf SHP6 smartplugs.
 - [fischrobi](https://github.com/fischrobi) for assisting with support for Blitzwolf BW-SH2 humidifiers.
 - [elninosi](https://github.com/elninosi) for assisting with support for LoraTap curtain switches.

+ 1 - 0
DEVICES.md

@@ -185,6 +185,7 @@
 - Arlec PB88UHA 4 way powerstrip with child lock
 - Aubess 1-gang switch with energy monitoring
 - Aubess 2-gang switch
+- Blitzwolf BW-SHP6 PRO smartplug with child lock
 - DIGOO DG-SP202 dual smartplug with energy monitoring and timers
 - DIGOO DG-SP01 USB smartplug with night light
 - Dual power monitoring smartplug (Geex)

+ 139 - 0
custom_components/tuya_local/devices/blitzwolf_bwshp6_smartplug.yaml

@@ -0,0 +1,139 @@
+name: Smartplug
+primary_entity:
+  entity: switch
+  class: outlet
+  dps:
+    - id: 1
+      name: switch
+      type: boolean
+    - id: 21
+      name: factory_test
+      type: bitfield
+    - id: 41
+      name: cycle_time
+      type: base64
+    - id: 42
+      name: random_time
+      type: base64
+    - id: 43
+      name: inching
+      type: base64
+secondary_entities:
+  - entity: sensor
+    name: Energy
+    category: diagnostic
+    dps:
+      - id: 17
+        type: integer
+        name: sensor
+        unit: Wh
+        optional: true
+      - id: 25
+        type: integer
+        name: calibration
+        optional: true
+  - entity: sensor
+    name: Current
+    class: current
+    category: diagnostic
+    dps:
+      - id: 18
+        type: integer
+        name: sensor
+        unit: mA
+        class: measurement
+      - id: 23
+        type: integer
+        name: calibration
+        optional: true
+  - entity: sensor
+    name: Power
+    class: power
+    category: diagnostic
+    dps:
+      - id: 19
+        type: integer
+        name: sensor
+        unit: W
+        class: measurement
+        mapping:
+          - scale: 10
+      - id: 24
+        type: integer
+        name: calibration
+        optional: true
+  - entity: sensor
+    name: Voltage
+    class: voltage
+    category: diagnostic
+    dps:
+      - id: 20
+        type: integer
+        name: sensor
+        unit: V
+        class: measurement
+        mapping:
+          - scale: 10
+      - id: 22
+        type: integer
+        name: calibration
+        optional: true
+  - entity: number
+    name: Timer
+    category: config
+    icon: "mdi:timer"
+    dps:
+      - id: 9
+        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: "on"
+            value: "On"
+          - dps_val: "off"
+            value: "Off"
+          - dps_val: memory
+            value: Last state
+  - entity: select
+    name: Light mode
+    icon: "mdi:lightbulb"
+    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"
+  - entity: lock
+    name: Child lock
+    icon: "mdi:hand-back-right-off"
+    category: config
+    dps:
+      - id: 40
+        type: boolean
+        name: lock
+
+        
+
+
+            
+

+ 15 - 0
util/config_match.py

@@ -0,0 +1,15 @@
+"""Find matching devices for the supplied dp list"""
+import sys
+import json
+
+from custom_components.tuya_local.helpers.device_config import possible_matches
+
+
+def main() -> int:
+    dps = json.loads(" ".join(sys.argv[1:]))
+    for match in possible_matches(dps):
+        print(f"{match.config_type} matched {match.match_quality(dps)}%")
+
+
+if __name__ == "__main__":
+    sys.exit(main())