فهرست منبع

BAC002 thermostat: rearrange to make off/cool/heat/fan the primary controls.

The AC in the name seems to indicate that this is a full AC controller.
So switching between heat, cool and fan is not an installation option as
originally configured, but a primary function of the device.

To make way for these controls, program/manual selection was moved to a
separate select control.

Issue #84
Jason Rumney 4 سال پیش
والد
کامیت
2359e8569b
2فایلهای تغییر یافته به همراه42 افزوده شده و 47 حذف شده
  1. 22 27
      custom_components/tuya_local/devices/beca_bac002_thermostat_c.yaml
  2. 20 20
      tests/devices/test_beca_bac002_thermostat.py

+ 22 - 27
custom_components/tuya_local/devices/beca_bac002_thermostat_c.yaml

@@ -23,7 +23,15 @@ primary_entity:
         max: 70
       mapping:
         - scale: 2
-    - id: 4
+    - id: 5
+      type: boolean
+      name: preset_mode
+      mapping:
+        - dps_val: true
+          value: eco 
+        - dps_val: false
+          value: comfort
+    - id: 102
       type: string
       name: hvac_mode
       mapping:
@@ -31,7 +39,7 @@ primary_entity:
           constraint: power
           conditions:
             - dps_val: true
-              value: auto
+              value: cool
             - dps_val: false
               value_redirect: power
               value: "off"
@@ -39,29 +47,18 @@ primary_entity:
           constraint: power
           conditions:
             - dps_val: true
-              value_mirror: installation_type
+              value: heat
             - dps_val: false
               value_redirect: power
               value: "off"
-    - id: 5
-      type: boolean
-      name: preset_mode
-      mapping:
-        - dps_val: true
-          value: eco 
-        - dps_val: false
-          value: comfort
-    - id: 102
-      type: string
-      name: installation_type
-      mapping:
-        - dps_val: "0"
-          value: cool
-        - dps_val: "1"
-          value: heat
         - dps_val: "2"
-          value: fan_only
-      hidden: true
+          constraint: power
+          conditions:
+            - dps_val: true
+              value: fan_only
+            - dps_val: false
+              value_redirect: power
+              value: "off"
     - id: 103
       type: string
       name: fan_mode
@@ -88,15 +85,13 @@ secondary_entities:
           - dps_val: false
             icon: "mdi:hand-back-right"
   - entity: select
-    name: Installation
+    name: Schedule
     dps:
-      - id: 102
+      - id: 4
         type: string
         name: option
         mapping:
           - dps_val: "0"
-            value: Cooling
+            value: program
           - dps_val: "1"
-            value: Heating
-          - dps_val: "2"
-            value: Fan
+            value: manual

+ 20 - 20
tests/devices/test_beca_bac002_thermostat.py

@@ -3,7 +3,6 @@ from homeassistant.components.climate.const import (
     FAN_HIGH,
     FAN_LOW,
     FAN_MEDIUM,
-    HVAC_MODE_AUTO,
     HVAC_MODE_COOL,
     HVAC_MODE_HEAT,
     HVAC_MODE_FAN_ONLY,
@@ -26,10 +25,10 @@ from .base_device_tests import TuyaDeviceTestCase
 SWITCH_DPS = "1"
 CURRENTTEMP_DPS = "2"
 TEMPERATURE_DPS = "3"
-HVACMODE_DPS = "4"
+PROGRAM_DPS = "4"
 PRESET_DPS = "5"
 LOCK_DPS = "6"
-INSTALL_DPS = "102"
+HVACMODE_DPS = "102"
 FAN_DPS = "103"
 
 
@@ -53,12 +52,11 @@ class TestBecaBAC002Thermostat(
         )
         self.setUpBasicLock(LOCK_DPS, self.entities.get("lock_child_lock"))
         self.setUpBasicSelect(
-            INSTALL_DPS,
-            self.entities.get("select_installation"),
+            PROGRAM_DPS,
+            self.entities.get("select_schedule"),
             {
-                "0": "Cooling",
-                "1": "Heating",
-                "2": "Fan",
+                "0": "program",
+                "1": "manual",
             },
         )
         self.mark_secondary(["lock_child_lock"])
@@ -96,47 +94,49 @@ class TestBecaBAC002Thermostat(
 
     def test_hvac_mode(self):
         self.dps[SWITCH_DPS] = True
-        self.dps[INSTALL_DPS] = "0"
-        self.dps[HVACMODE_DPS] = "1"
+        self.dps[HVACMODE_DPS] = "0"
         self.assertEqual(self.subject.hvac_mode, HVAC_MODE_COOL)
-        self.dps[INSTALL_DPS] = "1"
+        self.dps[HVACMODE_DPS] = "1"
         self.assertEqual(self.subject.hvac_mode, HVAC_MODE_HEAT)
-        self.dps[INSTALL_DPS] = "2"
+        self.dps[HVACMODE_DPS] = "2"
         self.assertEqual(self.subject.hvac_mode, HVAC_MODE_FAN_ONLY)
-        self.dps[HVACMODE_DPS] = "0"
-        self.assertEqual(self.subject.hvac_mode, HVAC_MODE_AUTO)
         self.dps[SWITCH_DPS] = False
         self.assertEqual(self.subject.hvac_mode, HVAC_MODE_OFF)
         self.dps[HVACMODE_DPS] = None
         self.assertEqual(self.subject.hvac_mode, STATE_UNAVAILABLE)
 
     def test_hvac_modes(self):
-        self.dps[INSTALL_DPS] = "1"
         self.assertCountEqual(
             self.subject.hvac_modes,
             [
-                HVAC_MODE_AUTO,
+                HVAC_MODE_COOL,
+                HVAC_MODE_FAN_ONLY,
                 HVAC_MODE_HEAT,
                 HVAC_MODE_OFF,
             ],
         )
 
-    async def test_set_hvac_mode_to_auto(self):
-        self.dps[INSTALL_DPS] = "1"
+    async def test_set_hvac_mode_to_cool(self):
         async with assert_device_properties_set(
             self.subject._device,
             {SWITCH_DPS: True, HVACMODE_DPS: "0"},
         ):
-            await self.subject.async_set_hvac_mode(HVAC_MODE_AUTO)
+            await self.subject.async_set_hvac_mode(HVAC_MODE_COOL)
 
     async def test_set_hvac_mode_to_heat(self):
-        self.dps[INSTALL_DPS] = "1"
         async with assert_device_properties_set(
             self.subject._device,
             {SWITCH_DPS: True, HVACMODE_DPS: "1"},
         ):
             await self.subject.async_set_hvac_mode(HVAC_MODE_HEAT)
 
+    async def test_set_hvac_mode_to_fan(self):
+        async with assert_device_properties_set(
+            self.subject._device,
+            {SWITCH_DPS: True, HVACMODE_DPS: "2"},
+        ):
+            await self.subject.async_set_hvac_mode(HVAC_MODE_FAN_ONLY)
+
     async def test_set_hvac_mode_to_off(self):
         async with assert_device_properties_set(
             self.subject._device, {SWITCH_DPS: False}