Browse Source

Hysen HY08ACF: fix config issues and improve compatibility

- fix naming of minimum temperature entity. Was duplicating maximum.
- make program optional, as it appears missing in a second variant
- add hvac_actions with long names as used by second variant (only
  heatvalve is confirmed, coolvalve is a guess).
- rearrange conditions to be more concise, using nested map.
Jason Rumney 3 years ago
parent
commit
a46373b5c1

+ 16 - 18
custom_components/tuya_local/devices/hysen_hy08acf_thermostat.yaml

@@ -77,30 +77,28 @@ primary_entity:
       name: hvac_action
       type: string
       mapping:
-        - dps_val: "0"
-          constraint: hvac_mode
+        - constraint: hvac_mode
           conditions:
             - dps_val: false
               value: "off"
             - dps_val: true
-              value: idle
-        - dps_val: "1"
-          constraint: hvac_mode
-          conditions:
-            - dps_val: false
-              value: "off"
-            - dps_val: true
-              value: heating
-        - dps_val: "2"
-          constraint: hvac_mode
-          conditions:
-            - dps_val: false
-              value: "off"
-            - dps_val: true
-              value: cooling
+              mapping:
+                - dps_val: "0"
+                  value: idle
+                - dps_val: "1"
+                  value: heating
+                - dps_val: "2"
+                  value: cooling
+                # another variant uses long names
+                - dps_val: heatvalve
+                  value: heating
+                - dps_val: coolvalve
+                  value: cooling
+                - value: idle
     - id: 121
       name: program
       type: integer
+      optional: true
 secondary_entities:
   - entity: lock
     name: Child lock
@@ -169,7 +167,7 @@ secondary_entities:
           min: 16
           max: 50
   - entity: number
-    name: Maximum temperature
+    name: Minimum temperature
     category: config
     icon: "mdi:temperature-chevron-down"
     dps:

+ 4 - 0
tests/test_device_config.py

@@ -266,6 +266,7 @@ class TestDeviceConfig(IsolatedAsyncioTestCase):
         All configs should be parsable and meet certain criteria
         """
         for cfg in available_configs():
+            entities = []
             parsed = TuyaDeviceConfig(cfg)
             # Check for error messages or unparsed config
             if isinstance(parsed, str) or isinstance(parsed._config, str):
@@ -280,8 +281,11 @@ class TestDeviceConfig(IsolatedAsyncioTestCase):
                 f"primary_entity missing from {cfg}",
             )
             self.check_entity(parsed.primary_entity, cfg)
+            entities.append(parsed.primary_entity.config_id)
             for entity in parsed.secondary_entities():
                 self.check_entity(entity, cfg)
+                entities.append(entity.config_id)
+            self.assertCountEqual(entities, set(entities))
 
     # Most of the device_config functionality is exercised during testing of
     # the various supported devices.  These tests concentrate only on the gaps.