瀏覽代碼

Allow BHT-6000 thermometer to be turned off.

Initial misunderstanding separated out the power control as a "Display" on/off.
But later feedback is that this turns off the whole system, so it should be rolled into hvac_mode like other devices.

Issue #57
Jason Rumney 4 年之前
父節點
當前提交
74f006b468

+ 21 - 2
custom_components/tuya_local/devices/beca_bht6000_thermostat_c.yaml

@@ -2,6 +2,13 @@ name: Beca BHT-6000 Thermostat (C)
 primary_entity:
   entity: climate
   dps:
+    - id: 1
+      type: boolean
+      name: power
+      mapping:
+        - dps_val: false
+          value: "off"
+      hidden: true
     - id: 2
       type: integer
       name: temperature
@@ -20,9 +27,20 @@ primary_entity:
       name: hvac_mode
       mapping:
         - dps_val: "0"
-          value: auto
+          constraint: power
+          conditions:
+            - dps_val: true
+              value: auto
+            - dps_val: false
+              value_redirect: power
+              value: "off"
         - dps_val: "1"
-          value: heat
+          constraint: power
+          conditions:
+            - dps_val: true
+              value: heat
+            - dps_val: false
+              value_redirect: power
     - id: 5
       type: boolean
       name: preset_mode
@@ -44,6 +62,7 @@ primary_entity:
       name: unknown_104
 secondary_entities:
   - entity: light
+    deprecated: climate hvac_mode
     name: Display
     dps:
       - id: 1

+ 9 - 4
tests/devices/test_beca_bht6000_thermostat.py

@@ -1,6 +1,7 @@
 from homeassistant.components.climate.const import (
     HVAC_MODE_AUTO,
     HVAC_MODE_HEAT,
+    HVAC_MODE_OFF,
     PRESET_ECO,
     PRESET_COMFORT,
     SUPPORT_PRESET_MODE,
@@ -12,7 +13,7 @@ from ..const import BECA_BHT6000_PAYLOAD
 from ..helpers import assert_device_properties_set
 from .base_device_tests import BasicLightTests, BasicLockTests, TuyaDeviceTestCase
 
-LIGHT_DPS = "1"
+POWER_DPS = "1"
 TEMPERATURE_DPS = "2"
 CURRENTTEMP_DPS = "3"
 HVACMODE_DPS = "4"
@@ -32,7 +33,7 @@ class TestBecaBHT6000Thermostat(BasicLightTests, BasicLockTests, TuyaDeviceTestC
             BECA_BHT6000_PAYLOAD,
         )
         self.subject = self.entities.get("climate")
-        self.setUpBasicLight(LIGHT_DPS, self.entities.get("light_display"))
+        self.setUpBasicLight(POWER_DPS, self.entities.get("light_display"))
         self.setUpBasicLock(LOCK_DPS, self.entities.get("lock_child_lock"))
 
     def test_supported_features(self):
@@ -113,7 +114,10 @@ class TestBecaBHT6000Thermostat(BasicLightTests, BasicLockTests, TuyaDeviceTestC
         self.assertEqual(self.subject.current_temperature, 22)
 
     def test_hvac_mode(self):
+        self.dps[POWER_DPS] = False
         self.dps[HVACMODE_DPS] = "0"
+        self.assertEqual(self.subject.hvac_mode, HVAC_MODE_OFF)
+        self.dps[POWER_DPS] = True
         self.assertEqual(self.subject.hvac_mode, HVAC_MODE_AUTO)
 
         self.dps[HVACMODE_DPS] = "1"
@@ -128,6 +132,7 @@ class TestBecaBHT6000Thermostat(BasicLightTests, BasicLockTests, TuyaDeviceTestC
             [
                 HVAC_MODE_HEAT,
                 HVAC_MODE_AUTO,
+                HVAC_MODE_OFF,
             ],
         )
 
@@ -142,9 +147,9 @@ class TestBecaBHT6000Thermostat(BasicLightTests, BasicLockTests, TuyaDeviceTestC
         )
 
     def test_icons(self):
-        self.dps[LIGHT_DPS] = True
+        self.dps[POWER_DPS] = True
         self.assertEqual(self.basicLight.icon, "mdi:led-on")
-        self.dps[LIGHT_DPS] = False
+        self.dps[POWER_DPS] = False
         self.assertEqual(self.basicLight.icon, "mdi:led-off")
 
         self.dps[LOCK_DPS] = True