Răsfoiți Sursa

Add Logicom Strippy 4 socket powerstrip with USB

Issue #138
Jason Rumney 3 ani în urmă
părinte
comite
2b649caee4

+ 113 - 0
custom_components/tuya_local/devices/logicom_powerstrip.yaml

@@ -0,0 +1,113 @@
+name: 4 outlet + USB powerstrip
+primary_entity:
+  entity: switch
+  name: Outlet 1
+  class: outlet
+  dps:
+    - id: 1
+      type: boolean
+      name: switch
+secondary_entities:
+  - entity: switch
+    name: Outlet 2
+    class: outlet
+    dps:
+      - id: 2
+        type: boolean
+        name: switch
+  - entity: switch
+    name: Outlet 3
+    class: outlet
+    dps:
+      - id: 3
+        type: boolean
+        name: switch
+  - entity: switch
+    name: Outlet 4
+    class: outlet
+    dps:
+      - id: 4
+        type: boolean
+        name: switch
+  - entity: switch
+    name: USB switch
+    class: switch
+    dps:
+      - id: 5
+        type: boolean
+        name: switch
+  - entity: number
+    category: config
+    name: Timer 1
+    icon: "mdi:timer"
+    dps:
+      - id: 9
+        name: value
+        type: integer
+        unit: min
+        range:
+          min: 0
+          max: 86400
+        mapping:
+          - scale: 60
+            step: 60
+  - entity: number
+    category: config
+    name: Timer 2
+    icon: "mdi:timer"
+    dps:
+      - id: 10
+        name: value
+        type: integer
+        unit: min
+        range:
+          min: 0
+          max: 86400
+        mapping:
+          - scale: 60
+            step: 60
+  - entity: number
+    category: config
+    name: Timer 3
+    icon: "mdi:timer"
+    dps:
+      - id: 11
+        name: value
+        type: integer
+        unit: min
+        range:
+          min: 0
+          max: 86400
+        mapping:
+          - scale: 60
+            step: 60
+  - entity: number
+    category: config
+    name: Timer 4
+    icon: "mdi:timer"
+    dps:
+      - id: 12
+        name: value
+        type: integer
+        unit: min
+        range:
+          min: 0
+          max: 86400
+        mapping:
+          - scale: 60
+            step: 60
+  - entity: number
+    category: config
+    name: USB Timer
+    icon: "mdi:timer"
+    dps:
+      - id: 13
+        name: value
+        type: integer
+        unit: min
+        range:
+          min: 0
+          max: 86400
+        mapping:
+          - scale: 60
+            step: 60

+ 4 - 0
custom_components/tuya_local/translations/en.json

@@ -91,6 +91,7 @@
                     "number_timer_1": "Include timer 1 as a number entity",
                     "number_timer_2": "Include timer 2 as a number entity",
                     "number_timer_3": "Include timer 3 as a number entity",
+                    "number_timer_4": "Include timer 4 as a number entity",
                     "number_usb_timer": "Include timer USB as a number entity",
                     "select_configuration": "Include configuration as a select entity",
                     "select_initial_state": "Include initial state as a select entity",
@@ -150,6 +151,7 @@
                     "switch_outlet_1": "Include outlet 1 as a switch entity",
                     "switch_outlet_2": "Include outlet 2 as a switch entity",
                     "switch_outlet_3": "Include outlet 3 as a switch entity",
+                    "switch_outlet_4": "Include outlet 4 as a switch entity",
                     "switch_overcharge_cutoff": "Include overcharge cutoff as a switch entity",
 		    "switch_prepay": "Include prepay as a switch entity",
                     "switch_sleep": "Include sleep mode as a switch entity",
@@ -246,6 +248,7 @@
                     "number_timer_1": "Include timer 1 as a number entity",
                     "number_timer_2": "Include timer 2 as a number entity",
                     "number_timer_3": "Include timer 3 as a number entity",
+                    "number_timer_4": "Include timer 4 as a number entity",
                     "number_usb_timer": "Include timer USB as a number entity",
                     "select_configuration": "Include configuration as a select entity",
                     "select_initial_state": "Include initial state as a select entity",
@@ -305,6 +308,7 @@
                     "switch_outlet_1": "Include outlet 1 as a switch entity",
                     "switch_outlet_2": "Include outlet 2 as a switch entity",
                     "switch_outlet_3": "Include outlet 3 as a switch entity",
+                    "switch_outlet_4": "Include outlet 4 as a switch entity",
                     "switch_overcharge_cutoff": "Include overcharge cutoff as a switch entity",
 		    "switch_prepay": "Include prepay as a switch entity",
                     "switch_sleep": "Include sleep mode as a switch entity",

+ 13 - 0
tests/const.py

@@ -1056,3 +1056,16 @@ MOES_RGB_SOCKET_PAYLOAD = {
     "105": 0,
     "106": 2332,
 }
+
+LOGICOM_STRIPPY_PAYLOAD = {
+    "1": False,
+    "2": False,
+    "3": False,
+    "4": False,
+    "5": False,
+    "9": 0,
+    "10": 0,
+    "11": 0,
+    "12": 0,
+    "13": 0,
+}

+ 103 - 0
tests/devices/test_logicom_powerstrip.py

@@ -0,0 +1,103 @@
+"""Tests for the Logicom Strippy 4-way+USB powerstrip."""
+from homeassistant.components.switch import DEVICE_CLASS_OUTLET
+from homeassistant.const import TIME_MINUTES
+
+from ..const import LOGICOM_STRIPPY_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"
+SWITCH4_DPS = "4"
+SWITCHUSB_DPS = "5"
+TIMER1_DPS = "9"
+TIMER2_DPS = "10"
+TIMER3_DPS = "11"
+TIMER4_DPS = "12"
+TIMERUSB_DPS = "13"
+
+
+class TestLogicomPowerstrip(
+    MultiNumberTests,
+    MultiSwitchTests,
+    TuyaDeviceTestCase,
+):
+    __test__ = True
+
+    def setUp(self):
+        self.setUpForConfig("logicom_powerstrip.yaml", LOGICOM_STRIPPY_PAYLOAD)
+        self.setUpMultiSwitch(
+            [
+                {
+                    "dps": SWITCH1_DPS,
+                    "name": "switch_outlet_1",
+                    "device_class": DEVICE_CLASS_OUTLET,
+                },
+                {
+                    "dps": SWITCH2_DPS,
+                    "name": "switch_outlet_2",
+                    "device_class": DEVICE_CLASS_OUTLET,
+                },
+                {
+                    "dps": SWITCH3_DPS,
+                    "name": "switch_outlet_3",
+                    "device_class": DEVICE_CLASS_OUTLET,
+                },
+                {
+                    "dps": SWITCH4_DPS,
+                    "name": "switch_outlet_4",
+                    "device_class": DEVICE_CLASS_OUTLET,
+                },
+                {"dps": SWITCHUSB_DPS, "name": "switch_usb_switch"},
+            ]
+        )
+        self.setUpMultiNumber(
+            [
+                {
+                    "dps": TIMER1_DPS,
+                    "name": "number_timer_1",
+                    "max": 1440,
+                    "scale": 60,
+                    "unit": TIME_MINUTES,
+                },
+                {
+                    "dps": TIMER2_DPS,
+                    "name": "number_timer_2",
+                    "max": 1440,
+                    "scale": 60,
+                    "unit": TIME_MINUTES,
+                },
+                {
+                    "dps": TIMER3_DPS,
+                    "name": "number_timer_3",
+                    "max": 1440,
+                    "scale": 60,
+                    "unit": TIME_MINUTES,
+                },
+                {
+                    "dps": TIMER4_DPS,
+                    "name": "number_timer_4",
+                    "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_1",
+                "number_timer_2",
+                "number_timer_3",
+                "number_timer_4",
+                "number_usb_timer",
+            ]
+        )