瀏覽代碼

Duux Blizzard: use feature flags to enable heat and ionizer.

- add tests for available flags.

Issue #2312, #2337
Jason Rumney 1 年之前
父節點
當前提交
22f4b4814d

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

@@ -24,6 +24,9 @@ primary_entity:
               value: dry
             - dps_val: fan
               value: fan_only
+            - dps_val: heat
+              value: heat
+              available: heat_available
     - id: 2
       type: string
       name: mode

+ 16 - 0
tests/const.py

@@ -1655,3 +1655,19 @@ AM25_ROLLERBLIND_PAYLOAD = {
     "105": True,
     "109": 4,
 }
+
+DUUX_BLIZZARD_PAYLOAD = {
+    "1": False,
+    "2": "fan",
+    "3": "high",
+    "4": 0,
+    "6": False,
+    "7": False,
+    "8": 22,
+    "9": 0,
+    "11": 72,
+    "12": True,
+    "13": False,
+    "14": False,
+    "15": 0,
+}

+ 86 - 0
tests/devices/test_duux_blizzard.py

@@ -0,0 +1,86 @@
+from homeassistant.components.climate.const import ClimateEntityFeature, HVACMode
+from homeassistant.const import UnitOfTemperature
+
+from ..const import DUUX_BLIZZARD_PAYLOAD
+from ..helpers import assert_device_properties_set
+from ..mixins.climate import TargetTemperatureTests
+from .base_device_tests import TuyaDeviceTestCase
+
+POWER_DP = "1"
+MODE_DP = "2"
+SPEED_DP = "3"
+TIMER_DP = "4"
+TEMPERATURE_DP = "5"
+SLEEP_DP = "6"
+ION_DP = "7"
+CURRENTTEMP_DP = "8"
+FAULT_DP = "9"
+SETTEMPF_DP = "10"
+CURTEMPF_DP = "11"
+IONSHOW_DP = "12"
+HEATSHOW_DP = "13"
+UNIT_DP = "14"
+COUNTDOWN_DP = "15"
+
+
+class TestDuuxBlizzard(TargetTemperatureTests, TuyaDeviceTestCase):
+    __test__ = True
+
+    def setUp(self):
+        self.setUpForConfig(
+            "duux_blizzard_portable_aircon.yaml",
+            DUUX_BLIZZARD_PAYLOAD,
+        )
+        self.subject = self.entities.get("climate")
+        self.ionizer = self.entities.get("switch_ionizer")
+        self.setUpTargetTemperature(
+            TEMPERATURE_DP,
+            self.subject,
+            min=18.0,
+            max=32.0,
+        )
+        self.mark_secondary(
+            [
+                "number_timer",
+                "switch_sleep",
+                "switch_ionizer",
+                "binary_sensor_tank_full",
+                "binary_sensor_problem",
+                "select_temperature_unit",
+                "sensor_time_remaining",
+            ]
+        )
+
+    def test_hvac_modes_with_heat_disabled(self):
+        self.dps[HEATSHOW_DP] = False
+        self.assertCountEqual(
+            self.subject.hvac_modes,
+            [
+                HVACMode.OFF,
+                HVACMode.COOL,
+                HVACMode.DRY,
+                HVACMode.FAN_ONLY,
+                HVACMode.AUTO,
+            ],
+        )
+
+    def test_hvac_modes_with_heat_enabled(self):
+        self.dps[HEATSHOW_DP] = True
+        self.assertCountEqual(
+            self.subject.hvac_modes,
+            [
+                HVACMode.OFF,
+                HVACMode.COOL,
+                HVACMode.DRY,
+                HVACMode.FAN_ONLY,
+                HVACMode.AUTO,
+                HVACMode.HEAT,
+            ],
+        )
+
+    def test_ionizer_availability(self):
+        self.dps[IONSHOW_DP] = False
+        self.dps[ION_DP] = True
+        self.assertFalse(self.ionizer.available)
+        self.dps[IONSHOW_DP] = True
+        self.assertTrue(self.ionizer.available)