Przeglądaj źródła

W'eau v2: add preset modes.

This has the same set of modes as many other pool heatpumps, so implement them
as preset modes.
Set the translation_key to make use of custom translations for pool heatpump presets.

Issue #808
Jason Rumney 2 lat temu
rodzic
commit
cd1d9245b8

+ 24 - 3
custom_components/tuya_local/devices/weau_pool_heatpump_v2.yaml

@@ -3,6 +3,7 @@ products:
   - id: zqwet1zcvj2wcxzw
 primary_entity:
   entity: climate
+  translation_key: pool_heatpump
   dps:
     - id: 1
       type: boolean
@@ -11,12 +12,18 @@ primary_entity:
         - dps_val: false
           value: "off"
         - dps_val: true
-          constraint: mode
+          constraint: preset_mode
           conditions:
             - dps_val: eheat
               value: heat
             - dps_val: ecool
               value: cool
+            - dps_val: auto
+              value: heat_cool
+            - dps_val: [bheat, sheat]
+              value: heat
+            - dps_val: [bcool, scool]
+              value: cool
     - id: 9
       type: integer
       name: temperature
@@ -30,8 +37,22 @@ primary_entity:
         - scale: 10
     - id: 2
       type: string
-      name: mode
-      hidden: true
+      name: preset_mode
+      mapping:
+        - dps_val: sheat
+          value: quiet_heat
+        - dps_val: bheat
+          value: quick_heat
+        - dps_val: eheat
+          value: smart_heat
+        - dps_val: scool
+          value: quiet_cool
+        - dps_val: bcool
+          value: quick_cool
+        - dps_val: ecool
+          value: smart_cool
+        - dps_val: auto
+          value: auto
     - id: 20
       type: bitfield
       name: fault

+ 13 - 2
tests/devices/test_weau_pool_heatpumpv2.py

@@ -47,7 +47,8 @@ class TestWeauPoolHeatpumpV2(
 
     def test_supported_features(self):
         self.assertEqual(
-            self.subject.supported_features, ClimateEntityFeature.TARGET_TEMPERATURE
+            self.subject.supported_features,
+            ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE,
         )
 
     def test_current_temperature(self):
@@ -60,13 +61,23 @@ class TestWeauPoolHeatpumpV2(
         self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
         self.dps[MODE_DPS] = "ecool"
         self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
+        self.dps[MODE_DPS] = "sheat"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
+        self.dps[MODE_DPS] = "scool"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
+        self.dps[MODE_DPS] = "bheat"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
+        self.dps[MODE_DPS] = "bcool"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
+        self.dps[MODE_DPS] = "auto"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT_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],
+            [HVACMode.OFF, HVACMode.COOL, HVACMode.HEAT, HVACMode.HEAT_COOL],
         )
 
     async def test_turn_off(self):