Преглед на файлове

Simple switch timer v2: Mark dp 38 optional in available check.

The check is against null, but the dp was not marked optional, as it
was in the original location.

Update unit test to check the available logic correctly for this file.
Jason Rumney преди 1 година
родител
ревизия
cca905ae81
променени са 2 файла, в които са добавени 10 реда и са изтрити 0 реда
  1. 1 0
      custom_components/tuya_local/devices/simple_switch_timerv2.yaml
  2. 9 0
      tests/devices/test_simple_switch_with_timerv2.py

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

@@ -49,6 +49,7 @@ secondary_entities:
       - id: 38
         type: string
         name: available
+        optional: true
         mapping:
           - dps_val: null
             value: false

+ 9 - 0
tests/devices/test_simple_switch_with_timerv2.py

@@ -9,6 +9,7 @@ from .base_device_tests import TuyaDeviceTestCase
 
 SWITCH_DPS = "1"
 TIMER_DPS = "9"
+INITIAL_STATE_DPS = "38"
 
 
 class TestTimedSwitch(BasicNumberTests, SwitchableTests, TuyaDeviceTestCase):
@@ -32,3 +33,11 @@ class TestTimedSwitch(BasicNumberTests, SwitchableTests, TuyaDeviceTestCase):
             self.subject.extra_state_attributes,
             {},
         )
+
+    def test_available(self):
+        for id, e in self.entities.items():
+            if id == "select_initial_state":
+                self.dps[INITIAL_STATE_DPS] = None
+                self.assertFalse(e.available)
+                self.dps[INITIAL_STATE_DPS] = "on"
+            self.assertTrue(e.available)