Przeglądaj źródła

Tests: add a check for inconsistent marking as optional.

Issues fixed in:
  - beok_tgr81_thermostat.yaml
  - ble_water_valve.yaml
  - ble_ysgbs01_lock.yaml
  - blitzwolf_bw_lt31.yaml
  - comon_lights.yaml
  - eurom_sani_bathroom_towel_radiator.yaml
  - ezaiot_thermostat_smartplug.yaml (renamed lower case, as not yet released)
  - hyd_weair_plus_fan.yaml
  - ironzon_fingerprint_lock.yaml
  - loratap_relay.yaml
  - mellerware_citymove_vacuum.yaml
  - moes_wht009_thermostat.yaml
  - nedis_zbrc10wt_remotecontrol.yaml
  - puppy_kitty_pet_feeder.yaml
  - sensei_airconditioner.yaml
  - wdyk_2p63a_energy_meter.yaml
  - wdyk_4p100a_energymeter.yaml
  - zym100_presence_sensor.yaml
Jason Rumney 1 rok temu
rodzic
commit
71aebc1f9a

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

@@ -31,6 +31,7 @@ primary_entity:
         max: 90
     - id: 19
       type: integer
+      optional: true
       name: max_temperature
     - id: 24
       type: integer
@@ -110,6 +111,7 @@ secondary_entities:
           - value: true
       - id: 45
         name: fault_code
+        optional: true
         type: bitfield
   - entity: number
     name: High temperature limit

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

@@ -61,6 +61,7 @@ secondary_entities:
           - value: true
       - id: 4
         type: bitfield
+        optional: true
         name: fault_code
   - entity: sensor
     name: Operation

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

@@ -98,6 +98,7 @@ secondary_entities:
     dps:
       - id: 21
         type: string
+        optional: true
         name: sensor
         mapping:
           - dps_val: low_battery

+ 0 - 3
custom_components/tuya_local/devices/blitzwolf_bw_lt31.yaml

@@ -51,9 +51,6 @@ primary_entity:
     - id: 103
       name: line_sequence_adjustment
       type: integer
-    - id: 104
-      name: strip_points
-      type: integer
 secondary_entities:
   - entity: select
     name: Music

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

@@ -56,6 +56,7 @@ secondary_entities:
       - id: 102
         type: string
         name: option
+        optional: true
         mapping:
           - dps_val: "1e03e801f40000000"
             value: Combination - All

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

@@ -105,6 +105,7 @@ secondary_entities:
     dps:
       - id: 105
         type: integer
+        optional: true
         name: sensor
         unit: C
   - entity: sensor

+ 4 - 1
custom_components/tuya_local/devices/EZAIOT_thermostat_smartplug.yaml → custom_components/tuya_local/devices/ezaiot_thermostat_smartplug.yaml

@@ -25,8 +25,8 @@ primary_entity:
         - scale: 10
     - id: 9
       type: integer
-      name: max_temperature
       optional: true
+      name: max_temperature
       mapping:
         - scale: 10
     - id: 12
@@ -41,6 +41,9 @@ primary_entity:
       unit: C
       mapping:
         - scale: 10
+      range:
+        min: -30
+        max: 110
     - id: 114
       type: integer
       name: hvac_action

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

@@ -125,6 +125,7 @@ secondary_entities:
           - value: true
       - id: 13
         type: bitfield
+        optional: true
         name: fault_code
   - entity: switch
     name: Beep

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

@@ -99,6 +99,7 @@ secondary_entities:
           - value: true
       - id: 21
         type: string
+        optional: true
         name: details
   - entity: binary_sensor
     class: lock

+ 0 - 6
custom_components/tuya_local/devices/loratap_relay.yaml

@@ -46,12 +46,6 @@ secondary_entities:
             value: "on"
           - dps_val: 2
             value: memory
-      - id: 42
-        type: string
-        name: cycle_time
-      - id: 43
-        type: string
-        name: random_time
   - entity: select
     name: Light Mode
     category: config

+ 5 - 0
custom_components/tuya_local/devices/mellerware_citymove_vacuum.yaml

@@ -10,6 +10,7 @@ primary_entity:
       name: power
     - id: 17
       type: bitfield
+      optional: true
       name: error
       hidden: true
     - id: 101
@@ -127,13 +128,17 @@ secondary_entities:
     dps:
       - id: 17
         type: bitfield
+        optional: true
         name: sensor
         mapping:
           - dps_val: 0
             value: false
+          - dps_val: null
+            value: false
           - value: true
       - id: 17
         type: bitfield
+        optional: true
         name: fault_code
       - id: 17
         type: bitfield

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

@@ -40,11 +40,13 @@ primary_entity:
           step: 5
     - id: 19
       type: integer
+      optional: true
       name: max_temperature
       mapping:
         - scale: 10
     - id: 26
       type: integer
+      optional: true
       name: min_temperature
       mapping:
         - scale: 10

+ 4 - 0
custom_components/tuya_local/devices/nedis_zbrc10wt_remotecontrol.yaml

@@ -17,6 +17,7 @@ primary_entity:
         - value: pressed
     - id: 29
       type: string
+      optional: true
       name: code
 secondary_entities:
   - entity: event
@@ -33,6 +34,7 @@ secondary_entities:
           - value: pressed
       - id: 27
         type: string
+        optional: true
         name: code
   - entity: event
     name: Button A
@@ -48,6 +50,7 @@ secondary_entities:
           - value: pressed
       - id: 28
         type: string
+        optional: true
         name: code
   - entity: event
     name: Button B
@@ -63,6 +66,7 @@ secondary_entities:
           - value: pressed
       - id: 26
         type: string
+        optional: true
         name: code
   - entity: sensor
     class: battery

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

@@ -60,4 +60,5 @@ secondary_entities:
           - value: false
       - id: 4
         type: string
+        optional: true
         name: raw

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

@@ -242,6 +242,7 @@ secondary_entities:
     dps:
       - id: 105
         type: string
+        optional: true
         name: option
         mapping:
           - dps_val: c

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

@@ -100,12 +100,13 @@ secondary_entities:
         type: boolean
         name: switch
   - entity: button
-    name: Reset energy
+    name: Reset balance energy
     category: config
     class: restart
     dps:
       - id: 12
         type: boolean
+        optional: true
         name: button
   - entity: sensor
     name: Energy balance
@@ -336,12 +337,3 @@ secondary_entities:
         type: boolean
         name: button
         optional: true
-  - entity: button
-    name: Reset balance energy
-    class: restart
-    category: config
-    dps:
-      - id: 12
-        type: boolean
-        name: button
-        optional: true

+ 0 - 8
custom_components/tuya_local/devices/wdyk_4p100a_energymeter.yaml

@@ -99,14 +99,6 @@ secondary_entities:
       - id: 11
         type: boolean
         name: switch
-  - entity: button
-    name: Reset energy
-    category: config
-    class: restart
-    dps:
-      - id: 12
-        type: boolean
-        name: button
   - entity: sensor
     name: Energy balance
     class: energy_storage

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

@@ -99,6 +99,7 @@ secondary_entities:
           - value: true
       - id: 6
         type: string
+        optional: true
         name: description
   - entity: sensor
     name: Target distance

+ 15 - 4
tests/test_device_config.py

@@ -531,18 +531,29 @@ class TestDeviceConfig(IsolatedAsyncioTestCase):
     def test_configs_can_be_matched(self):
         """Test that the config files can be matched to a device."""
         for cfg in available_configs():
-            required_dps = 0
+            optional = set()
+            required = set()
             parsed = TuyaDeviceConfig(cfg)
             for entity in parsed.all_entities():
                 for dp in entity.dps():
-                    if not dp.optional:
-                        required_dps += 1
+                    if dp.optional:
+                        optional.add(dp.id)
+                    else:
+                        required.add(dp.id)
+
             self.assertGreater(
-                required_dps,
+                len(required),
                 0,
                 msg=f"No required dps found in {cfg}",
             )
 
+            for dp in required:
+                self.assertNotIn(
+                    dp,
+                    optional,
+                    msg=f"Optional dp {dp} is required in {cfg}",
+                )
+
     # Most of the device_config functionality is exercised during testing of
     # the various supported devices.  These tests concentrate only on the gaps.