Explorar o código

Add support for 4 way power monitoring strip.

Issue #206
Jason Rumney %!s(int64=3) %!d(string=hai) anos
pai
achega
95a93e3b77

+ 2 - 0
ACKNOWLEDGEMENTS.md

@@ -104,3 +104,5 @@ Further device support has been made with the assistance of users.  Please consi
 - [RichardMawdsley](https://github.com/RichardMawdsley) for assistance supporting ElectriQ Airflex 15W heatpumps.
 - [fwelvering](https://github.com/fwelvering) for assistance supporting a second variant of W'eau pool heatpumps. 
 - [illuzn](https://github.com/illuzn) for contributing support for Kogan Tower Heaters.
+- [vnkorol](https://github.com/vnkorol) for assistance supporting 4-way power monitoring strip.
+

+ 1 - 0
README.md

@@ -162,6 +162,7 @@ the device will not work despite being listed below.
 Other brands may work with the above configurations
 - MoesHouse Smartplug with RGBW nightlight
 - Logicom Strippy 4 way power strip with USB
+- 4 way power monitoring strip
 
 - 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.

+ 79 - 0
custom_components/tuya_local/devices/energy_monitoring_powerstrip.yaml

@@ -0,0 +1,79 @@
+name: Energy Monitoring Powerstrip
+products:
+  - id: 7hBwPPNdDP1xHrWv
+primary_entity:
+  entity: switch
+  name: Switch 1
+  dps:
+    - id: 1
+      type: boolean
+      name: switch
+    - id: 105
+      type: integer
+      name: unknown_105
+    - id: 106
+      type: integer
+      name: unknown_106
+    - id: 107
+      type: integer
+      name: unknown_107
+    - id: 108
+      type: integer
+      name: unknown_108
+    - id: 109
+      type: integer
+      name: unknown_109
+secondary_entities:
+  - entity: switch
+    name: Switch 2
+    dps:
+      - id: 2
+        type: boolean
+        name: switch
+  - entity: switch
+    name: Switch 3
+    dps:
+      - id: 3
+        type: boolean
+        name: switch
+  - entity: switch
+    name: Switch 4
+    dps:
+      - id: 4
+        type: boolean
+        name: switch
+
+  - entity: sensor
+    name: Current
+    class: current
+    category: diagnostic
+    dps:
+      - id: 102
+        type: integer
+        name: sensor
+        unit: mA
+        class: measurement
+  - entity: sensor
+    name: Power
+    class: power
+    category: diagnostic
+    dps:
+      - id: 103
+        type: integer
+        name: sensor
+        unit: W
+        class: measurement
+        mapping:
+          - scale: 10
+  - entity: sensor
+    name: Voltage
+    class: voltage
+    category: diagnostic
+    dps:
+      - id: 104
+        type: integer
+        name: sensor
+        unit: V
+        class: measurement
+        mapping:
+          - scale: 10

+ 15 - 0
tests/const.py

@@ -1406,3 +1406,18 @@ PC321TY_POWERCLAMP_PAYLOAD = {
     "135": 50,
     "136": 390,
 }
+
+ENERGY_POWERSTRIP_PAYLOAD = {
+    "1": False,
+    "2": False,
+    "3": False,
+    "4": False,
+    "102": 0,
+    "103": 0,
+    "104": 2240,
+    "105": 1,
+    "106": 1709,
+    "107": 34620,
+    "108": 101000,
+    "109": 205,
+}

+ 87 - 0
tests/devices/test_energy_monitoring_powerstrip.py

@@ -0,0 +1,87 @@
+"""Tests for the energy monitoring powerstrip."""
+from homeassistant.components.switch import SwitchDeviceClass
+
+from ..const import ES01_POWERSTRIP_PAYLOAD
+from ..mixins.number import MultiNumberTests
+from ..mixins.switch import MultiSwitchTests
+from .base_device_tests import TuyaDeviceTestCase
+
+SWITCH1_DPS = "1"
+SWITCH2_DPS = "2"
+SWITCH3_DPS = "3"
+SWITCHUSB_DPS = "4"
+TIMER1_DPS = "5"
+TIMER2_DPS = "6"
+TIMER3_DPS = "7"
+TIMERUSB_DPS = "8"
+
+
+class TestES01Powerstrip(
+    MultiNumberTests,
+    MultiSwitchTests,
+    TuyaDeviceTestCase,
+):
+    __test__ = True
+
+    def setUp(self):
+        self.setUpForConfig("es01_powerstrip.yaml", ES01_POWERSTRIP_PAYLOAD)
+        self.setUpMultiSwitch(
+            [
+                {
+                    "dps": SWITCH1_DPS,
+                    "name": "switch_switch_1",
+                    "device_class": SwitchDeviceClass.OUTLET,
+                },
+                {
+                    "dps": SWITCH2_DPS,
+                    "name": "switch_switch_2",
+                    "device_class": SwitchDeviceClass.OUTLET,
+                },
+                {
+                    "dps": SWITCH3_DPS,
+                    "name": "switch_switch_3",
+                    "device_class": SwitchDeviceClass.OUTLET,
+                },
+                {"dps": SWITCHUSB_DPS, "name": "switch_usb_switch"},
+            ]
+        )
+        self.setUpMultiNumber(
+            [
+                {
+                    "dps": TIMER1_DPS,
+                    "name": "number_timer_socket_1",
+                    "max": 1440,
+                    "scale": 60,
+                    "unit": TIME_MINUTES,
+                },
+                {
+                    "dps": TIMER2_DPS,
+                    "name": "number_timer_socket_2",
+                    "max": 1440,
+                    "scale": 60,
+                    "unit": TIME_MINUTES,
+                },
+                {
+                    "dps": TIMER3_DPS,
+                    "name": "number_timer_socket_3",
+                    "max": 1440,
+                    "scale": 60,
+                    "unit": TIME_MINUTES,
+                },
+                {
+                    "dps": TIMERUSB_DPS,
+                    "name": "number_usb_timer",
+                    "max": 1440,
+                    "scale": 60,
+                    "unit": TIME_MINUTES,
+                },
+            ]
+        )
+        self.mark_secondary(
+            [
+                "number_timer_socket_1",
+                "number_timer_socket_2",
+                "number_timer_socket_3",
+                "number_usb_timer",
+            ]
+        )