Jelajahi Sumber

Add support for Be Cool heatpump.

Issue #207
Jason Rumney 3 tahun lalu
induk
melakukan
f2d0e36052

+ 1 - 1
ACKNOWLEDGEMENTS.md

@@ -105,4 +105,4 @@ Further device support has been made with the assistance of users.  Please consi
 - [fwelvering](https://github.com/fwelvering) for assistance supporting a second variant of W'eau pool heatpumps. 
 - [illuzn](https://github.com/illuzn) for contributing support for Kogan Tower Heaters.
 - [vnkorol](https://github.com/vnkorol) for assistance supporting 4-way power monitoring strip.
-
+- [OmegaKill](https://github.com/OmegaKill) for assistance supporting Be Cool heatpumps.

+ 1 - 0
README.md

@@ -61,6 +61,7 @@ the device will not work despite being listed below.
 - Eberg Cooly C35HD
 - Star-Light air conditioner
 - TroniTechnik Hellnar Klimagerät
+- Be Cool BC14KL2101F
 
 ### Pool heaters / heatpumps
 

+ 89 - 0
custom_components/tuya_local/devices/becool_heatpump.yaml

@@ -0,0 +1,89 @@
+name: Be Cool BC14KL2101F
+primary_entity:
+  entity: climate
+  dps:
+    - id: 1
+      type: boolean
+      name: hvac_mode
+      mapping:
+        - dps_val: false
+          value: "off"
+        - dps_val: true
+          constraint: mode
+          conditions:
+            - dps_val: "0"
+              value: heat_cool
+            - dps_val: "1"
+              value: cool
+            - dps_val: "2"
+              value: heat
+            - dps_val: "3"
+              value: dry
+            - dps_val: "4"
+              value: fan_only
+    - id: 4
+      type: integer
+      name: unknown_4
+    - id: 5
+      type: string
+      name: mode
+# unhide for debugging      hidden: true
+    - id: 6
+      type: integer
+      name: temperature
+      range:
+        min: 13
+        max: 32
+      mapping:
+        - constraint: temperature_unit
+          conditions:
+            - dps_val: true
+              value_redirect: temp_set_f
+              range:
+                min: 55
+                max: 90
+    - id: 8
+      type: string
+      name: fan_mode
+      mapping:
+        - dps_val: "1"
+          value: low
+        - dps_val: "2"
+          value: medium
+        - dps_val: "3"
+          value: high
+    - id: 10
+      type: boolean
+      name: temperature_unit
+      mapping:
+        - dps_val: false
+          value: C
+        - dps_val: true
+          value: F
+    - id: 13
+      type: integer
+      name: unknown_13
+    - id: 14
+      type: integer
+      name: unknown_14
+    - id: 15
+      type: integer
+      name: unknown_15
+    - id: 16
+      type: boolean
+      name: unknown_16
+    - id: 17
+      type: boolean
+      name: unknown_17
+    - id: 18
+      name: temp_set_f
+      type: integer
+      range:
+        min: 55
+        max: 90
+      hidden: true
+      optional: true
+    - id: 19
+      type: boolean
+      name: unknown_19
+

+ 15 - 0
tests/const.py

@@ -1434,3 +1434,18 @@ COMPTEUR_SMARTMETER_PAYLOAD = {
     "25": 0,
     "26": 0,
 }
+
+BECOOL_HEATPUMP_PAYLOAD = {
+    "1": False,
+    "4": 0,
+    "5": "4",
+    "6": 24,
+    "8": "0",
+    "10": False,
+    "13": 0,
+    "14": 0,
+    "15": 0,
+    "16": True,
+    "17": False,
+    "19": False,
+}

+ 120 - 0
tests/devices/test_becool_heatpump.py

@@ -0,0 +1,120 @@
+from homeassistant.components.climate.const import (
+    ClimateEntityFeature,
+    HVACMode,
+)
+from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
+
+from ..const import BECOOL_HEATPUMP_PAYLOAD
+from ..helpers import assert_device_properties_set
+from ..mixins.climate import TargetTemperatureTests
+from .base_device_tests import TuyaDeviceTestCase
+
+HVACMODE_DPS = "1"
+UNKNOWN4_DPS = "4"
+MODE_DPS = "5"
+TEMPERATURE_DPS = "6"
+FAN_DPS = "8"
+UNIT_DPS = "10"
+UNKNOWN13_DPS = "13"
+UNKNOWN14_DPS = "14"
+UNKNOWN15_DPS = "15"
+UNKNOWN16_DPS = "16"
+UNKNOWN17_DPS = "17"
+TEMPF_DPS = "18"
+UNKNOWN19_DPS = "19"
+
+
+class TestBWTHeatpump(
+    TargetTemperatureTests,
+    TuyaDeviceTestCase,
+):
+    __test__ = True
+
+    def setUp(self):
+        self.setUpForConfig("becool_heatpump.yaml", BECOOL_HEATPUMP_PAYLOAD)
+        self.subject = self.entities["climate"]
+        self.setUpTargetTemperature(
+            TEMPERATURE_DPS,
+            self.subject,
+            min=13,
+            max=32,
+        )
+
+    def test_supported_features(self):
+        self.assertEqual(
+            self.subject.supported_features,
+            (ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.FAN_MODE),
+        )
+
+    def test_temperature_unit(self):
+        self.dps[UNIT_DPS] = False
+        self.assertEqual(self.subject.temperature_unit, TEMP_CELSIUS)
+        self.dps[UNIT_DPS] = True
+        self.assertEqual(self.subject.temperature_unit, TEMP_FAHRENHEIT)
+
+    def test_hvac_mode(self):
+        self.dps[HVACMODE_DPS] = False
+        self.assertEqual(self.subject.hvac_mode, HVACMode.OFF)
+        self.dps[HVACMODE_DPS] = True
+        self.dps[MODE_DPS] = "0"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT_COOL)
+        self.dps[MODE_DPS] = "1"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
+        self.dps[MODE_DPS] = "2"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
+        self.dps[MODE_DPS] = "3"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.DRY)
+        self.dps[MODE_DPS] = "4"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.FAN_ONLY)
+
+    def test_hvac_modes(self):
+        self.assertCountEqual(
+            self.subject.hvac_modes,
+            [
+                HVACMode.OFF,
+                HVACMode.COOL,
+                HVACMode.DRY,
+                HVACMode.FAN_ONLY,
+                HVACMode.HEAT,
+                HVACMode.HEAT_COOL,
+            ],
+        )
+
+    async def test_turn_on_to_auto(self):
+        async with assert_device_properties_set(
+            self.subject._device, {HVACMODE_DPS: True, MODE_DPS: "0"}
+        ):
+            await self.subject.async_set_hvac_mode(HVACMode.HEAT_COOL)
+
+    async def test_turn_on_to_cool(self):
+        async with assert_device_properties_set(
+            self.subject._device, {HVACMODE_DPS: True, MODE_DPS: "1"}
+        ):
+            await self.subject.async_set_hvac_mode(HVACMode.COOL)
+
+    async def test_turn_on_to_heat(self):
+        async with assert_device_properties_set(
+            self.subject._device, {HVACMODE_DPS: True, MODE_DPS: "2"}
+        ):
+            await self.subject.async_set_hvac_mode(HVACMode.HEAT)
+
+    async def test_turn_on_to_dry(self):
+        async with assert_device_properties_set(
+            self.subject._device, {HVACMODE_DPS: True, MODE_DPS: "3"}
+        ):
+            await self.subject.async_set_hvac_mode(HVACMode.DRY)
+
+    async def test_turn_on_to_fan(self):
+        async with assert_device_properties_set(
+            self.subject._device, {HVACMODE_DPS: True, MODE_DPS: "4"}
+        ):
+            await self.subject.async_set_hvac_mode(HVACMode.FAN_ONLY)
+
+    async def test_turn_off(self):
+        async with assert_device_properties_set(
+            self.subject._device, {HVACMODE_DPS: False}
+        ):
+            await self.subject.async_set_hvac_mode(HVACMode.OFF)
+
+    def test_fan_modes(self):
+        self.assertCountEqual(self.subject.fan_modes, ["low", "medium", "high"])