Sfoglia il codice sorgente

Add support for second variant of W'eau Pool heatpump

Issue #152 (comments by @fwelvering)
Jason Rumney 3 anni fa
parent
commit
d608b1f9ab

+ 108 - 0
custom_components/tuya_local/devices/weau_pool_heatpump_v2.yaml

@@ -0,0 +1,108 @@
+name: W'Eau Pool Heatpump
+product:
+  - id: zqwet1zcvj2wcxzw
+primary_entity:
+  entity: climate
+  dps:
+    - id: 1
+      type: boolean
+      name: power
+      hidden: true
+      mapping:
+        - dps_val: false
+          value: "off"
+    - id: 9
+      type: integer
+      name: temperature
+      range:
+        min: 7
+        max: 60
+    - id: 10
+      type: integer
+      name: current_temperature
+      mapping:
+        - scale: 10
+    - id: 2
+      type: string
+      name: hvac_mode
+      mapping:
+        - dps_val: eheat
+          constraint: power
+          conditions:
+            - dps_val: false
+              value_redirect: power
+              value: "off"
+            - dps_val: true
+              value: heat
+        - dps_val: ecool
+          constraint: power
+          conditions:
+            - dps_val: false
+              value_redirect: power
+            - dps_val: true
+              value: cool
+    - id: 20
+      type: bitfield
+      name: fault
+      mapping:
+        - dps_val: 0
+          value: OK
+        - dps_val: 1
+          value: sys_high_fault
+        - dps_val: 2
+          value: sys_low_fault
+        - dps_val: 4
+          value: flow_fault
+        - dps_val: 8
+          value: power_fault
+        - dps_val: 16
+          value: cooling_fault
+        - dps_val: 32
+          value: heating_fault
+        - dps_val: 64
+          value: temp_dif_fault
+        - dps_val: 128
+          value: in_temp_fault
+        - dps_val: 256
+          value: eff_temp_fault
+        - dps_val: 512
+          value: coil_temp_fault
+        - dps_val: 1024
+          value: ret_temp_fault
+        - dps_val: 2048
+          value: news_fault
+        - dps_val: 4096
+          value: amb_temp_fault
+        - dps_val: 8192
+          value: lack_water
+        - dps_val: 16384
+          value: serious_fault
+        - dps_val: 32768
+          value: sensor_fault
+        - dps_val: 65536
+          value: motor_fault
+    - id: 101
+      type: integer
+      name: unknown_101
+    - id: 102
+      type: integer
+      name: unknown_102
+    - id: 103
+      type: integer
+      name: unknown_103
+    - id: 104
+      type: boolean
+      name: unknown_104
+secondary_entities:
+  - entity: binary_sensor
+    class: problem
+    name: Fault
+    category: diagnostic
+    dps:
+      - id: 20
+        type: bitfield
+        name: sensor
+        mapping:
+          - dps_val: 0
+            value: false
+          - value: true

+ 12 - 0
tests/const.py

@@ -1202,6 +1202,18 @@ WEAU_POOL_HEATPUMP_PAYLOAD = {
     "6": 0,
 }
 
+WEAU_POOL_HEATPUMPV2_PAYLOAD = {
+    "1": True,
+    "2": "eheat",
+    "9": 15,
+    "10": 260,
+    "20": 0,
+    "101": 0,
+    "102": 40,
+    "103": 15,
+    "104": True,
+}
+
 SMARTPLUG_ENCODED_PAYLOAD = {
     "1": True,
     "11": 0,

+ 108 - 0
tests/devices/test_weau_pool_heatpumpv2.py

@@ -0,0 +1,108 @@
+from homeassistant.components.binary_sensor import BinarySensorDeviceClass
+from homeassistant.components.climate.const import (
+    ClimateEntityFeature,
+    HVACMode,
+)
+
+from ..const import WEAU_POOL_HEATPUMPV2_PAYLOAD
+from ..helpers import assert_device_properties_set
+from ..mixins.binary_sensor import BasicBinarySensorTests
+from ..mixins.climate import TargetTemperatureTests
+from .base_device_tests import TuyaDeviceTestCase
+
+POWER_DPS = "1"
+MODE_DPS = "2"
+TEMPERATURE_DPS = "9"
+CURRENTTEMP_DPS = "10"
+FAULT_DPS = "20"
+UNKNOWN101_DPS = "101"
+UNKNOWN102_DPS = "102"
+UNKNOWN103_DPS = "103"
+UNKNOWN104_DPS = "104"
+
+
+class TestWeauPoolHeatpumpV2(
+    BasicBinarySensorTests,
+    TargetTemperatureTests,
+    TuyaDeviceTestCase,
+):
+    __test__ = True
+
+    def setUp(self):
+        self.setUpForConfig("weau_pool_heatpump_v2.yaml", WEAU_POOL_HEATPUMPV2_PAYLOAD)
+        self.subject = self.entities.get("climate")
+        self.setUpTargetTemperature(
+            TEMPERATURE_DPS,
+            self.subject,
+            min=7,
+            max=60,
+        )
+        self.setUpBasicBinarySensor(
+            FAULT_DPS,
+            self.entities.get("binary_sensor_fault"),
+            device_class=BinarySensorDeviceClass.PROBLEM,
+            testdata=(4, 0),
+        )
+        self.mark_secondary(["binary_sensor_fault"])
+
+    def test_supported_features(self):
+        self.assertEqual(
+            self.subject.supported_features, ClimateEntityFeature.TARGET_TEMPERATURE
+        )
+
+    def test_current_temperature(self):
+        self.dps[CURRENTTEMP_DPS] = 194
+        self.assertEqual(self.subject.current_temperature, 19.4)
+
+    def test_hvac_mode(self):
+        self.dps[POWER_DPS] = True
+        self.dps[MODE_DPS] = "eheat"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
+        self.dps[MODE_DPS] = "ecool"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
+        self.dps[POWER_DPS] = False
+        self.assertEqual(self.subject.hvac_mode, HVACMode.OFF)
+
+    def test_hvac_modes(self):
+        self.assertCountEqual(
+            self.subject.hvac_modes,
+            [HVACMode.OFF, HVACMode.COOL, HVACMode.HEAT],
+        )
+
+    async def test_turn_off(self):
+        async with assert_device_properties_set(
+            self.subject._device,
+            {POWER_DPS: False},
+        ):
+            await self.subject.async_set_hvac_mode(HVACMode.OFF)
+
+    async def test_set_cool(self):
+        async with assert_device_properties_set(
+            self.subject._device,
+            {POWER_DPS: True, MODE_DPS: "ecool"},
+        ):
+            await self.subject.async_set_hvac_mode(HVACMode.COOL)
+
+    async def test_set_heat(self):
+        async with assert_device_properties_set(
+            self.subject._device,
+            {POWER_DPS: True, MODE_DPS: "eheat"},
+        ):
+            await self.subject.async_set_hvac_mode(HVACMode.HEAT)
+
+    def test_extra_state_attributes(self):
+        self.dps[FAULT_DPS] = 4
+        self.dps[UNKNOWN101_DPS] = 101
+        self.dps[UNKNOWN102_DPS] = 102
+        self.dps[UNKNOWN103_DPS] = 103
+        self.dps[UNKNOWN104_DPS] = True
+        self.assertDictEqual(
+            self.subject.extra_state_attributes,
+            {
+                "fault": "flow_fault",
+                "unknown_101": 101,
+                "unknown_102": 102,
+                "unknown_103": 103,
+                "unknown_104": True,
+            },
+        )