Parcourir la source

Conditional mappings do not support default mappings.

Defaults for conditions have to be set one level up in the mapping,
as the conditions only look for matches, not keep track of defaults.
There may be some side-effect to changing this, and setting one level
up is an acceptable workaround.

In read-write situations that need to control which options are set
for a specific value, it is sometimes better to list all conditions
rather than use a default.

Main effect is on climate hvac_action, swing_mode where more than just
two options for vertical and horizontal are available, cover actions
where opened/opening, closed/closing need to distinguished based on
position, and complex logic to handle optional vacuum activate and
pause switches.

Issue #1709
Jason Rumney il y a 1 an
Parent
commit
aabc4e8ed5
31 fichiers modifiés avec 117 ajouts et 71 suppressions
  1. 11 0
      custom_components/tuya_local/devices/README.md
  2. 2 1
      custom_components/tuya_local/devices/avatto_me81_thermostat.yaml
  3. 2 2
      custom_components/tuya_local/devices/avatto_roller_blinds.yaml
  4. 1 1
      custom_components/tuya_local/devices/becool_heatpump.yaml
  5. 2 1
      custom_components/tuya_local/devices/beok_tgm50_thermostat.yaml
  6. 1 1
      custom_components/tuya_local/devices/beok_tr8b_thermostat.yaml
  7. 2 2
      custom_components/tuya_local/devices/ccb11_blind_controller.yaml
  8. 4 4
      custom_components/tuya_local/devices/daizuki_heatpump.yaml
  9. 2 2
      custom_components/tuya_local/devices/dongguan_electric_curtain.yaml
  10. 3 3
      custom_components/tuya_local/devices/evotherm_eti_heatpump.yaml
  11. 2 3
      custom_components/tuya_local/devices/greenmigo_alpha_q25_pro_wifi.yaml
  12. 8 5
      custom_components/tuya_local/devices/idea_heatingbelt_airconditioner.yaml
  13. 4 6
      custom_components/tuya_local/devices/inkbird_itc306a_thermostat.yaml
  14. 2 1
      custom_components/tuya_local/devices/jiahong_et72w_thermostat.yaml
  15. 10 2
      custom_components/tuya_local/devices/kabum_smart700_v2023_vaccum.yaml
  16. 2 2
      custom_components/tuya_local/devices/m027_curtain.yaml
  17. 1 1
      custom_components/tuya_local/devices/madimack_eco_heatpump.yaml
  18. 0 2
      custom_components/tuya_local/devices/me80_thermostat.yaml
  19. 5 1
      custom_components/tuya_local/devices/mellerware_comfy_radiator.yaml
  20. 0 1
      custom_components/tuya_local/devices/poolex_qline_heatpump.yaml
  21. 2 1
      custom_components/tuya_local/devices/qlima_d820a_dehumidifier.yaml
  22. 9 4
      custom_components/tuya_local/devices/rotenso_ronix_heatpump.yaml
  23. 2 1
      custom_components/tuya_local/devices/royalclima_rcb150_ventilation.yaml
  24. 2 2
      custom_components/tuya_local/devices/sherko_curtain.yaml
  25. 8 10
      custom_components/tuya_local/devices/starlight_heatpump.yaml
  26. 2 1
      custom_components/tuya_local/devices/taurus_agadir_heater.yaml
  27. 10 2
      custom_components/tuya_local/devices/ttec_reobipro_vacuum.yaml
  28. 9 5
      custom_components/tuya_local/devices/vivax_heatpump.yaml
  29. 6 2
      custom_components/tuya_local/devices/vivion_airconditioner.yaml
  30. 2 2
      custom_components/tuya_local/devices/zemismart_roller_shade.yaml
  31. 1 0
      tests/test_device_config.py

+ 11 - 0
custom_components/tuya_local/devices/README.md

@@ -511,6 +511,17 @@ If `constraint_dp` is readonly:
 | c | y | target_dp: 2 |
 | c | z | target_dp: 1 |
 
+Note that each condition must specify a `dps_val` to match againt. If you want to specify a default match, do it outside the conditions.
+
+```
+    mapping:
+      - dps_val: some_value
+        value: defaulted
+        constraint: other_dp
+        conditions:
+          - dps_val: other_value
+            value: overridden
+```
 
 
 ## Entity types

+ 2 - 1
custom_components/tuya_local/devices/avatto_me81_thermostat.yaml

@@ -50,7 +50,8 @@ primary_entity:
           conditions:
             - dps_val: false
               value: "off"
-            - mapping:
+            - dps_val: true
+              mapping:
                 - dps_val: open
                   value: heating
                 - value: idle

+ 2 - 2
custom_components/tuya_local/devices/avatto_roller_blinds.yaml

@@ -35,21 +35,21 @@ primary_entity:
       type: string
       mapping:
         - dps_val: opening
+          value: opening
           constraint: current_position
           conditions:
             - dps_val: 100
               value: opened
             - dps_val: null
               value: opened
-            - value: opening
         - dps_val: closing
+          value: closing
           constraint: current_position
           conditions:
             - dps_val: 0
               value: closed
             - dps_val: null
               value: closed
-            - value: closing
 secondary_entities:
   - entity: select
     translation_key: timer

+ 1 - 1
custom_components/tuya_local/devices/becool_heatpump.yaml

@@ -9,6 +9,7 @@ primary_entity:
         - dps_val: false
           value: "off"
         - dps_val: true
+          value: fan_only
           constraint: mode
           conditions:
             - dps_val: "0"
@@ -21,7 +22,6 @@ primary_entity:
               value: cool
             - dps_val: "5"
               value: heat
-            - value: fan_only
     - id: 4
       type: integer
       name: unknown_4

+ 2 - 1
custom_components/tuya_local/devices/beok_tgm50_thermostat.yaml

@@ -20,7 +20,8 @@ primary_entity:
               hidden: true
             - dps_val: home
               value: heat
-            - value: heat
+            - dps_val: leave
+              value: heat
               hidden: true
         - dps_val: false
           value: "off"

+ 1 - 1
custom_components/tuya_local/devices/beok_tr8b_thermostat.yaml

@@ -89,13 +89,13 @@ primary_entity:
       name: hvac_action
       mapping:
         - dps_val: open
+          value: idle
           constraint: preset_mode
           conditions:
             - dps_val: [cool, floor]
               value: cooling
             - dps_val: [heat, floor_heat]
               value: heating
-            - value: idle
         - dps_val: close
           constraint: hvac_mode
           conditions:

+ 2 - 2
custom_components/tuya_local/devices/ccb11_blind_controller.yaml

@@ -32,17 +32,17 @@ primary_entity:
       name: action
       mapping:
         - dps_val: opening
+          value: opening
           constraint: current_position
           conditions:
             - dps_val: 100
               value: opened
-            - value: opening
         - dps_val: closing
+          value: closing
           constraint: current_position
           conditions:
             - dps_val: 0
               value: closed
-            - value: closing
     - id: 11
       type: string
       name: unknown_11

+ 4 - 4
custom_components/tuya_local/devices/daizuki_heatpump.yaml

@@ -70,26 +70,26 @@ primary_entity:
       name: swing_mode
       mapping:
         - dps_val: "0"
+          value: horizontal
           constraint: horizontal_swing
           conditions:
             - dps_val: "0"
               value: "off"
             - dps_val: "1"
               value: horizontal
-            - value: horizontal
         - dps_val: "1"
+          value: both
           constraint: horizontal_swing
           conditions:
             - dps_val: "0"
               value: vertical
             - dps_val: "1"
               value: both
-            - value: both
-        - constraint: horizontal_swing
+        - value: both
+          constraint: horizontal_swing
           conditions:
             - dps_val: "0"
               value: vertical
-            - value: both
     - id: 114
       type: string
       name: horizontal_swing

+ 2 - 2
custom_components/tuya_local/devices/dongguan_electric_curtain.yaml

@@ -32,19 +32,19 @@ primary_entity:
       type: string
       mapping:
         - dps_val: opening
+          value: opening
           constraint: current_position
           conditions:
             - dps_val: 0
               value: opened
-            - value: opening
         - dps_val: closing
+          value: closing
           constraint: current_position
           conditions:
             - dps_val: 100
               value: closed
             - dps_val: null
               value: closed
-            - value: closing
     - id: 12
       name: fault_code
       type: bitfield

+ 3 - 3
custom_components/tuya_local/devices/evotherm_eti_heatpump.yaml

@@ -62,18 +62,18 @@ primary_entity:
       type: string
       mapping:
         - dps_val: Running
+          value: heating
           constraint: preset_mode
           conditions:
             - dps_val: ["Cooling_Powerful", "Cooling_Smart", "Cooling_Silent"]
               value: cooling
-            - value: heating
         - dps_val: Defrosting
           value: preheating
-        - constraint: hvac_mode
+        - value: idle
+          constraint: hvac_mode
           conditions:
             - dps_val: false
               value: "off"
-            - value: idle
     - id: 101
       name: temperature
       type: integer

+ 2 - 3
custom_components/tuya_local/devices/greenmigo_alpha_q25_pro_wifi.yaml

@@ -108,9 +108,8 @@ secondary_entities:
         mapping:
           - constraint: dehumidifier_mode
             conditions:
-              - dps_val: Manual
-              - dps_val: Purifier
-              - invalid: true
+              - dps_val: [Auto, Laundrydrying, Sleeping]
+                invalid: true
       - id: 4
         name: speed
         type: string

+ 8 - 5
custom_components/tuya_local/devices/idea_heatingbelt_airconditioner.yaml

@@ -78,7 +78,8 @@ primary_entity:
               value: "off"
             - dps_val: true
               value: horizontal
-            - value: "off"
+            - dps_val: null
+              value: "off"
               hidden: true
         - dps_val: true
           constraint: swing_horiz
@@ -87,14 +88,16 @@ primary_entity:
               value: vertical
             - dps_val: true
               value: both
-            - value: vertical
+            - dps_val: null
+              value: vertical
               hidden: true
         - constraint: swing_horiz
           conditions:
             - dps_val: true
               value: horizontal
               hidden: true
-            - value: "off"
+            - dps_val: null
+              value: "off"
               hidden: true
     - id: 33
       type: boolean
@@ -130,21 +133,21 @@ secondary_entities:
         optional: true
         mapping:
           - dps_val: 0
+            value: true
             constraint: fault_code_2
             conditions:
               - dps_val: null
                 value: false
               - dps_val: 0
                 value: false
-              - value: true
           - dps_val: null
+            value: true
             constraint: fault_code_2
             conditions:
               - dps_val: null
                 value: false
               - dps_val: 0
                 value: false
-              - value: true
           - value: true
       - id: 22
         type: bitfield

+ 4 - 6
custom_components/tuya_local/devices/inkbird_itc306a_thermostat.yaml

@@ -91,7 +91,10 @@ primary_entity:
       type: boolean
       name: hvac_action
       mapping:
-        - constraint: hvac_mode
+        - icon: "mdi:thermometer-off"
+          icon_priority: 5
+          value: "off"
+          constraint: hvac_mode
           conditions:
             - dps_val: "on"
               mapping:
@@ -100,12 +103,7 @@ primary_entity:
                   icon_priority: 6
                   value: heating
                 - dps_val: false
-                  icon: "mdi:thermometer-off"
-                  icon_priority: 5
                   value: idle
-            - icon: "mdi:thermometer-off"
-              icon_priority: 5
-              value: "off"
     - id: 116
       type: integer
       name: current_temperature_f

+ 2 - 1
custom_components/tuya_local/devices/jiahong_et72w_thermostat.yaml

@@ -75,7 +75,8 @@ primary_entity:
           conditions:
             - dps_val: false
               value: "off"
-            - mapping:
+            - dps_val: true
+              mapping:
                 - dps_val: true
                   value: heating
                 - dps_val: false

+ 10 - 2
custom_components/tuya_local/devices/kabum_smart700_v2023_vaccum.yaml

@@ -15,14 +15,22 @@ primary_entity:
           conditions:
             - dps_val: true
               value: false
-            - value: false
+            - dps_val: false
+              value: false
+              hidden: true
+            - dps_val: null
+              value: false
               hidden: true
         - dps_val: true
           constraint: pause
           conditions:
             - dps_val: false
               value: true
-            - value: true
+            - dps_val: true
+              value: true
+              hidden: true
+            - dps_val: null
+              value: true
               hidden: true
         - dps_val: null
           value: false

+ 2 - 2
custom_components/tuya_local/devices/m027_curtain.yaml

@@ -32,21 +32,21 @@ primary_entity:
       persist: false
       mapping:
         - dps_val: opening
+          value: opening
           constraint: current_position
           conditions:
             - dps_val: 100
               value: opened
             - dps_val: null
               value: opened
-            - value: opening
         - dps_val: closing
+          value: closing
           constraint: current_position
           conditions:
             - dps_val: 0
               value: closed
             - dps_val: null
               value: closed
-            - value: closing
     - id: 12
       name: fault_code
       type: bitfield

+ 1 - 1
custom_components/tuya_local/devices/madimack_eco_heatpump.yaml

@@ -107,11 +107,11 @@ secondary_entities:
         name: sensor
         mapping:
           - dps_val: 0
+            value: true
             constraint: fault_2
             conditions:
               - dps_val: 0
                 value: false
-              - value: true
           - value: true
   - entity: sensor
     name: Compressor strength

+ 0 - 2
custom_components/tuya_local/devices/me80_thermostat.yaml

@@ -14,8 +14,6 @@ primary_entity:
               value: auto
             - dps_val: manual
               value: heat
-              # in case of unknown presets
-            - value: heat
         - dps_val: false
           value: "off"
     - id: 2

+ 5 - 1
custom_components/tuya_local/devices/mellerware_comfy_radiator.yaml

@@ -21,7 +21,11 @@ primary_entity:
               hidden: true
             - dps_val: CF
               value: heat
-            - value: heat
+            - dps_val: [EC, AF]
+              value: heat
+              hidden: true
+            - dps_val: ST
+              value: "off"
               hidden: true
     - id: 2
       type: integer

+ 0 - 1
custom_components/tuya_local/devices/poolex_qline_heatpump.yaml

@@ -19,7 +19,6 @@ primary_entity:
               value: heat
             - dps_val: mute
               value: heat_cool
-            - value: heat_cool
     - id: 2
       name: heating_mode
       hidden: true

+ 2 - 1
custom_components/tuya_local/devices/qlima_d820a_dehumidifier.yaml

@@ -49,7 +49,8 @@ secondary_entities:
             conditions:
               - dps_val: airpurify
                 value_redirect: purify_speed
-              - mapping:
+              - dps_val: [dehum_air, dehum30_air]
+                mapping:
                   - dps_val: low
                     value: 33
                   - dps_val: mid

+ 9 - 4
custom_components/tuya_local/devices/rotenso_ronix_heatpump.yaml

@@ -81,7 +81,9 @@ primary_entity:
               value: "off"
             - dps_val: "1"
               value: horizontal
-            - value: horizontal
+            - dps_val: ["2", "3", "4"]
+              value: horizontal
+              hidden: true
         - dps_val: "1"
           constraint: horizontal_swing
           conditions:
@@ -89,12 +91,15 @@ primary_entity:
               value: vertical
             - dps_val: "1"
               value: both
-            - value: both
-        - constraint: horizontal_swing
+            - dps_val: ["2", "3", "4"]
+              value: both
+              hidden: true
+        - hidden: true
+          value: both
+          constraint: horizontal_swing
           conditions:
             - dps_val: "0"
               value: vertical
-            - value: both
     - id: 114
       type: string
       name: horizontal_swing

+ 2 - 1
custom_components/tuya_local/devices/royalclima_rcb150_ventilation.yaml

@@ -133,7 +133,8 @@ secondary_entities:
             conditions:
               - dps_val: true
                 value: heat
-              - value: "off"
+              - dps_val: false
+                value: "off"
       - id: 102
         name: temperature
         type: integer

+ 2 - 2
custom_components/tuya_local/devices/sherko_curtain.yaml

@@ -35,21 +35,21 @@ primary_entity:
       name: action
       mapping:
         - dps_val: opening
+          value: opening
           constraint: current_position
           conditions:
             - dps_val: 100
               value: opened
             - dps_val: null
               value: opened
-            - value: opening
         - dps_val: closing
+          value: closing
           constraint: current_position
           conditions:
             - dps_val: 0
               value: closed
             - dps_val: null
               value: closed
-            - value: closing
 secondary_entities:
   - entity: switch
     category: config

+ 8 - 10
custom_components/tuya_local/devices/starlight_heatpump.yaml

@@ -84,7 +84,9 @@ primary_entity:
               value: "off"
             - dps_val: "1"
               value: horizontal
-            - value: horizontal
+            - dps_val: ["2", "3", "4"]
+              value: horizontal
+              hidden: true
         - dps_val: "1"
           constraint: horizontal_swing
           conditions:
@@ -92,19 +94,15 @@ primary_entity:
               value: vertical
             - dps_val: "1"
               value: both
-            - value: both
-        - dps_val: "2"
-          constraint: horizontal_swing
-          conditions:
-            - dps_val: "0"
-              value: vertical
-            - value: both
-        - dps_val: "3"
+            - dps_val: ["2", "3", "4"]
+              value: both
+              hidden: true
+        - value: both
+          hidden: true
           constraint: horizontal_swing
           conditions:
             - dps_val: "0"
               value: vertical
-            - value: both
     - id: 114
       name: horizontal_swing
       type: string

+ 2 - 1
custom_components/tuya_local/devices/taurus_agadir_heater.yaml

@@ -37,7 +37,8 @@ primary_entity:
           conditions:
             - dps_val: false
               value: "off"
-            - mapping:
+            - dps_val: true
+              mapping:
                 - dps_val: working
                   value: heating
                 - dps_val: standby

+ 10 - 2
custom_components/tuya_local/devices/ttec_reobipro_vacuum.yaml

@@ -15,14 +15,22 @@ primary_entity:
           conditions:
             - dps_val: true
               value: false
-            - value: false
+            - dps_val: false
+              value: false
+              hidden: true
+            - dps_val: null
+              value: false
               hidden: true
         - dps_val: true
           constraint: pause
           conditions:
             - dps_val: false
               value: true
-            - value: true
+            - dps_val: true
+              value: true
+              hidden: true
+            - dps_val: null
+              value: true
               hidden: true
         - dps_val: null
           value: false

+ 9 - 5
custom_components/tuya_local/devices/vivax_heatpump.yaml

@@ -138,7 +138,9 @@ primary_entity:
               value: both
             - dps_val: lr_00
               value: vertical
-            - value: vertical
+            - dps_val: [lr_01, lr_02, lr_03, lr_04]
+              value: vertical
+              hidden: true
         - dps_val: ud_00
           constraint: horizontal_swing
           conditions:
@@ -146,16 +148,18 @@ primary_entity:
               value: horizontal
             - dps_val: lr_00
               value: "off"
-            - value: "off"
-        - constraint: horizontal_swing
+            - dps_val: [lr_01, lr_02, lr_03, lr_04]
+              value: "off"
+              hidden: true
+        - value: "off"
+          hidden: true
+          constraint: horizontal_swing
           conditions:
             - dps_val: lr_0c
               value: horizontal
-            - value: "off"
     - id: 118
       type: string
       name: horizontal_swing
-      # From Tadiran Apollo
     - id: 101
       type: boolean
       name: mood_lighting

+ 6 - 2
custom_components/tuya_local/devices/vivion_airconditioner.yaml

@@ -82,7 +82,9 @@ primary_entity:
               value: "off"
             - dps_val: same
               value: vertical
-            - value: "off"
+            - dps_val: [vane_1, vane_2, vane_3, vane_4, vane_5]
+              value: "off"
+              hidden: true
         - dps_val: true
           constraint: vertical
           conditions:
@@ -90,7 +92,9 @@ primary_entity:
               value: horizontal
             - dps_val: same
               value: both
-            - value: horizontal
+            - dps_val: [vane_1, vane_2, vane_3, vane_4, vane_5]
+              value: horizontal
+              hidden: true
     - id: 103
       type: string
       name: unknown_103

+ 2 - 2
custom_components/tuya_local/devices/zemismart_roller_shade.yaml

@@ -39,17 +39,17 @@ primary_entity:
       type: string
       mapping:
         - dps_val: opening
+          value: opening
           constraint: current_position
           conditions:
             - dps_val: 0
               value: opened
-            - value: opening
         - dps_val: closing
+          value: closing
           constraint: current_position
           conditions:
             - dps_val: 100
               value: closed
-            - value: closing
     - id: 12
       name: fault_code
       type: bitfield

+ 1 - 0
tests/test_device_config.py

@@ -56,6 +56,7 @@ CONDMAP_SCHEMA = vol.Schema(
 )
 COND_SCHEMA = CONDMAP_SCHEMA.extend(
     {
+        vol.Required("dps_val"): vol.Maybe(vol.Any(str, int, bool, list)),
         vol.Optional("mapping"): [CONDMAP_SCHEMA],
     }
 )