Просмотр исходного кода

ElectriQ Airflex 15W: make temp_f and temp_set_f dps optional.

- add some unknown dps based on the actual data returned from the device.

Issue #175
Jason Rumney 3 лет назад
Родитель
Сommit
c9c64af5c9

+ 36 - 18
custom_components/tuya_local/devices/electriq_airflex15w_heatpump.yaml

@@ -14,22 +14,22 @@ primary_entity:
         - dps_val: true
           constraint: preset_mode
           conditions:
-            - dps_val: auto
+            - dps_val: "0" # auto
               value: heat_cool
               icon: "mdi:hvac"
-            - dps_val: cold
+            - dps_val: "1" # cold
               value: cool
               icon: "mdi:snowflake"
-            - dps_val: hot
+            - dps_val: "2" # hot
               value: heat
               icon: "mdi:fire"
-            - dps_val: wet
+            - dps_val: "3" # wet
               value: dry
               icon: "mdi:water"
-            - dps_val: wind
+            - dps_val: "4" # wind
               value: fan_only
               icon: "mdi:fan"
-            - dps_val: eco
+            - dps_val: "5" # eco
               value: heat_cool
               icon: "mdi:leaf"
     - id: 2
@@ -41,7 +41,7 @@ primary_entity:
       mapping:
         - constraint: temperature_unit
           conditions:
-            - dps_val: F
+            - dps_val: true
               value_redirect: temp_set_f
               range:
                 min: 62
@@ -52,7 +52,7 @@ primary_entity:
       mapping:
         - constraint: temperature_unit
           conditions:
-            - dps_val: F
+            - dps_val: true
               value_redirect: temp_current_f
     - id: 17
       type: integer
@@ -60,22 +60,28 @@ primary_entity:
       range:
         min: 0
         max: 100
+    - id: 20
+      type: integer
+      name: unknown_20
     - id: 101
       type: string
       name: preset_mode
       mapping:
-        - dps_val: auto
+        - dps_val: "0" # auto
           value: Auto
-        - dps_val: cold
+        - dps_val: "1" # cold
           value: Cool
-        - dps_val: hot
+        - dps_val: "2" # hot
           value: Heat
-        - dps_val: wet
+        - dps_val: "3" # wet
           value: Dry
-        - dps_val: wind
+        - dps_val: "4" # wind
           value: Fan
-        - dps_val: eco
+        - dps_val: "5" # eco
           value: eco
+    - id: 103
+      type: boolean
+      name: unknown_103
     - id: 104
       type: string
       name: fan_mode
@@ -86,9 +92,19 @@ primary_entity:
           value: medium
         - dps_val: "3"
           value: high
+    - id: 105
+      type: integer
+      name: unknown_105
+    - id: 106
+      type: boolean
+      name: unknown_106
     - id: 109
-      type: string
+      type: boolean
       name: temperature_unit
+      mapping:
+        - dps_val: true
+          value: F
+        - value: C
     - id: 110
       type: integer
       name: temp_set_f
@@ -96,10 +112,12 @@ primary_entity:
         min: 62
         max: 90
       hidden: true
+      optional: true
     - id: 111
       type: integer
       name: temp_current_f
       hidden: true
+      optional: true
     - id: 112
       type: integer
       name: current_humidity
@@ -109,10 +127,10 @@ secondary_entities:
     category: config
     dps:
       - id: 109
-        type: string
+        type: boolean
         name: option
         mapping:
-          - dps_val: C
+          - dps_val: false
             value: Celsius
-          - dps_val: F
+          - dps_val: true
             value: Fahrenheit

+ 10 - 8
tests/const.py

@@ -1354,15 +1354,17 @@ ORION_SMARTLOCK_PAYLOAD = {
 
 ELECTRIQ_AIRFLEX15W_PAYLOAD = {
     "1": True,
-    "2": 22,
+    "2": 16,
     "3": 27,
-    "17": 50,
-    "101": "cold",
-    "104": "2",
-    "109": "C",
-    "110": 72,
-    "111": 80,
-    "112": 68,
+    "17": 90,
+    "20": 0,
+    "101": "1",
+    "103": False,
+    "104": "1",
+    "105": 0,
+    "106": False,
+    "109": False,
+    "112": 42,
 }
 
 PC321TY_POWERCLAMP_PAYLOAD = {

+ 35 - 22
tests/devices/test_electriq_airflex15w_heatpump.py

@@ -14,8 +14,12 @@ POWER_DPS = "1"
 TEMPERATURE_DPS = "2"
 CURRENTTEMP_DPS = "3"
 HUMIDITY_DPS = "17"
+UNKNOWN20_DPS = "20"
 HVACMODE_DPS = "101"
+UNKNOWN103_DPS = "103"
 FAN_DPS = "104"
+UNKNOWN105_DPS = "105"
+UNKNOWN106_DPS = "106"
 UNIT_DPS = "109"
 TEMPF_DPS = "110"
 CURTEMPF_DPS = "111"
@@ -45,8 +49,8 @@ class TestElectriqAirflex15WHeatpump(
             UNIT_DPS,
             self.entities.get("select_temperature_unit"),
             {
-                "C": "Celsius",
-                "F": "Fahrenheit",
+                False: "Celsius",
+                True: "Fahrenheit",
             },
         )
         self.mark_secondary(["select_temperature_unit"])
@@ -64,42 +68,42 @@ class TestElectriqAirflex15WHeatpump(
 
     def test_icon(self):
         self.dps[POWER_DPS] = True
-        self.dps[HVACMODE_DPS] = "auto"
+        self.dps[HVACMODE_DPS] = "0"
         self.assertEqual(self.subject.icon, "mdi:hvac")
-        self.dps[HVACMODE_DPS] = "cold"
+        self.dps[HVACMODE_DPS] = "1"
         self.assertEqual(self.subject.icon, "mdi:snowflake")
-        self.dps[HVACMODE_DPS] = "hot"
+        self.dps[HVACMODE_DPS] = "2"
         self.assertEqual(self.subject.icon, "mdi:fire")
-        self.dps[HVACMODE_DPS] = "wet"
+        self.dps[HVACMODE_DPS] = "3"
         self.assertEqual(self.subject.icon, "mdi:water")
-        self.dps[HVACMODE_DPS] = "wind"
+        self.dps[HVACMODE_DPS] = "4"
         self.assertEqual(self.subject.icon, "mdi:fan")
-        self.dps[HVACMODE_DPS] = "eco"
+        self.dps[HVACMODE_DPS] = "5"
         self.assertEqual(self.subject.icon, "mdi:leaf")
         self.dps[POWER_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:hvac-off")
 
     def test_temperature_unit(self):
-        self.dps[UNIT_DPS] = "C"
+        self.dps[UNIT_DPS] = False
         self.assertEqual(self.subject.temperature_unit, TEMP_CELSIUS)
-        self.dps[UNIT_DPS] = "F"
+        self.dps[UNIT_DPS] = True
         self.assertEqual(self.subject.temperature_unit, TEMP_FAHRENHEIT)
 
     def test_current_temperature(self):
-        self.dps[UNIT_DPS] = "C"
+        self.dps[UNIT_DPS] = False
         self.dps[CURRENTTEMP_DPS] = 25
         self.assertEqual(self.subject.current_temperature, 25)
-        self.dps[UNIT_DPS] = "F"
+        self.dps[UNIT_DPS] = True
         self.dps[CURTEMPF_DPS] = 78
         self.assertEqual(self.subject.current_temperature, 78)
 
     def test_temperature_f(self):
-        self.dps[UNIT_DPS] = "F"
+        self.dps[UNIT_DPS] = True
         self.dps[TEMPF_DPS] = 90
         self.assertEqual(self.subject.target_temperature, 90)
 
     async def test_set_temperature_f(self):
-        self.dps[UNIT_DPS] = "F"
+        self.dps[UNIT_DPS] = True
         async with assert_device_properties_set(
             self.subject._device,
             {TEMPF_DPS: 85},
@@ -108,17 +112,17 @@ class TestElectriqAirflex15WHeatpump(
 
     def test_hvac_mode(self):
         self.dps[POWER_DPS] = True
-        self.dps[HVACMODE_DPS] = "hot"
+        self.dps[HVACMODE_DPS] = "2"
         self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
-        self.dps[HVACMODE_DPS] = "cold"
+        self.dps[HVACMODE_DPS] = "1"
         self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
-        self.dps[HVACMODE_DPS] = "wet"
+        self.dps[HVACMODE_DPS] = "3"
         self.assertEqual(self.subject.hvac_mode, HVACMode.DRY)
-        self.dps[HVACMODE_DPS] = "wind"
+        self.dps[HVACMODE_DPS] = "4"
         self.assertEqual(self.subject.hvac_mode, HVACMode.FAN_ONLY)
-        self.dps[HVACMODE_DPS] = "auto"
+        self.dps[HVACMODE_DPS] = "0"
         self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT_COOL)
-        self.dps[HVACMODE_DPS] = "eco"
+        self.dps[HVACMODE_DPS] = "5"
         self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT_COOL)
         self.dps[POWER_DPS] = False
         self.assertEqual(self.subject.hvac_mode, HVACMode.OFF)
@@ -138,7 +142,7 @@ class TestElectriqAirflex15WHeatpump(
 
     async def test_turn_on(self):
         async with assert_device_properties_set(
-            self.subject._device, {POWER_DPS: True, HVACMODE_DPS: "hot"}
+            self.subject._device, {POWER_DPS: True, HVACMODE_DPS: "2"}
         ):
             await self.subject.async_set_hvac_mode(HVACMode.HEAT)
 
@@ -199,7 +203,16 @@ class TestElectriqAirflex15WHeatpump(
             await self.subject.async_set_humidity(40)
 
     def test_extra_state_attribures(self):
+        self.dps[UNKNOWN20_DPS] = 20
+        self.dps[UNKNOWN103_DPS] = True
+        self.dps[UNKNOWN105_DPS] = 105
+        self.dps[UNKNOWN106_DPS] = True
         self.assertEqual(
             self.subject.extra_state_attributes,
-            {},
+            {
+                "unknown_20": 20,
+                "unknown_103": True,
+                "unknown_105": 105,
+                "unknown_106": True,
+            },
         )